diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_dbi.c | 2 | ||||
| -rw-r--r-- | plugins/check_mysql.c | 19 | ||||
| -rw-r--r-- | plugins/check_mysql.d/config.h | 5 | ||||
| -rw-r--r-- | plugins/check_mysql_query.c | 22 | ||||
| -rw-r--r-- | plugins/check_mysql_query.d/config.h | 6 |
5 files changed, 54 insertions, 0 deletions
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c index 9bc68eb3..81d92952 100644 --- a/plugins/check_dbi.c +++ b/plugins/check_dbi.c | |||
| @@ -688,6 +688,8 @@ void print_help(void) { | |||
| 688 | 688 | ||
| 689 | printf(UT_VERBOSE); | 689 | printf(UT_VERBOSE); |
| 690 | 690 | ||
| 691 | printf(UT_OUTPUT_FORMAT); | ||
| 692 | |||
| 691 | printf("\n"); | 693 | printf("\n"); |
| 692 | printf(" %s\n", _("A DBI driver (-d option) is required. If the specified metric operates")); | 694 | printf(" %s\n", _("A DBI driver (-d option) is required. If the specified metric operates")); |
| 693 | printf(" %s\n\n", _("on a query, one has to be specified (-q option).")); | 695 | printf(" %s\n\n", _("on a query, one has to be specified (-q option).")); |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 9d8094c0..009c9908 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
| @@ -96,6 +96,10 @@ int main(int argc, char **argv) { | |||
| 96 | 96 | ||
| 97 | const check_mysql_config config = tmp_config.config; | 97 | const check_mysql_config config = tmp_config.config; |
| 98 | 98 | ||
| 99 | if (config.output_format_is_set) { | ||
| 100 | mp_set_format(config.output_format); | ||
| 101 | } | ||
| 102 | |||
| 99 | MYSQL mysql; | 103 | MYSQL mysql; |
| 100 | /* initialize mysql */ | 104 | /* initialize mysql */ |
| 101 | mysql_init(&mysql); | 105 | mysql_init(&mysql); |
| @@ -471,6 +475,7 @@ check_mysql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 471 | 475 | ||
| 472 | enum { | 476 | enum { |
| 473 | CHECK_REPLICA_OPT = CHAR_MAX + 1, | 477 | CHECK_REPLICA_OPT = CHAR_MAX + 1, |
| 478 | output_format_index, | ||
| 474 | }; | 479 | }; |
| 475 | 480 | ||
| 476 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, | 481 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, |
| @@ -495,6 +500,7 @@ check_mysql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 495 | {"cert", required_argument, 0, 'a'}, | 500 | {"cert", required_argument, 0, 'a'}, |
| 496 | {"ca-dir", required_argument, 0, 'D'}, | 501 | {"ca-dir", required_argument, 0, 'D'}, |
| 497 | {"ciphers", required_argument, 0, 'L'}, | 502 | {"ciphers", required_argument, 0, 'L'}, |
| 503 | {"output-format", required_argument, 0, output_format_index}, | ||
| 498 | {0, 0, 0, 0}}; | 504 | {0, 0, 0, 0}}; |
| 499 | 505 | ||
| 500 | check_mysql_config_wrapper result = { | 506 | check_mysql_config_wrapper result = { |
| @@ -605,6 +611,17 @@ check_mysql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 605 | break; | 611 | break; |
| 606 | case '?': /* help */ | 612 | case '?': /* help */ |
| 607 | usage5(); | 613 | usage5(); |
| 614 | case output_format_index: { | ||
| 615 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 616 | if (!parser.parsing_success) { | ||
| 617 | printf("Invalid output format: %s\n", optarg); | ||
| 618 | exit(STATE_UNKNOWN); | ||
| 619 | } | ||
| 620 | |||
| 621 | result.config.output_format_is_set = true; | ||
| 622 | result.config.output_format = parser.output_format; | ||
| 623 | break; | ||
| 624 | } | ||
| 608 | } | 625 | } |
| 609 | } | 626 | } |
| 610 | 627 | ||
| @@ -711,6 +728,8 @@ void print_help(void) { | |||
| 711 | printf(" %s\n", "-L, --ciphers=STRING"); | 728 | printf(" %s\n", "-L, --ciphers=STRING"); |
| 712 | printf(" %s\n", _("List of valid SSL ciphers")); | 729 | printf(" %s\n", _("List of valid SSL ciphers")); |
| 713 | 730 | ||
| 731 | printf(UT_OUTPUT_FORMAT); | ||
| 732 | |||
| 714 | printf("\n"); | 733 | printf("\n"); |
| 715 | printf(" %s\n", | 734 | printf(" %s\n", |
| 716 | _("There are no required arguments. By default, the local database is checked")); | 735 | _("There are no required arguments. By default, the local database is checked")); |
diff --git a/plugins/check_mysql.d/config.h b/plugins/check_mysql.d/config.h index ef086cfc..1d8c82bb 100644 --- a/plugins/check_mysql.d/config.h +++ b/plugins/check_mysql.d/config.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "../../config.h" | 3 | #include "../../config.h" |
| 4 | #include "output.h" | ||
| 4 | #include "thresholds.h" | 5 | #include "thresholds.h" |
| 5 | #include <stddef.h> | 6 | #include <stddef.h> |
| 6 | #include <mysql.h> | 7 | #include <mysql.h> |
| @@ -26,6 +27,8 @@ typedef struct { | |||
| 26 | 27 | ||
| 27 | mp_thresholds replica_thresholds; | 28 | mp_thresholds replica_thresholds; |
| 28 | 29 | ||
| 30 | bool output_format_is_set; | ||
| 31 | mp_output_format output_format; | ||
| 29 | } check_mysql_config; | 32 | } check_mysql_config; |
| 30 | 33 | ||
| 31 | check_mysql_config check_mysql_config_init() { | 34 | check_mysql_config check_mysql_config_init() { |
| @@ -49,6 +52,8 @@ check_mysql_config check_mysql_config_init() { | |||
| 49 | .ignore_auth = false, | 52 | .ignore_auth = false, |
| 50 | 53 | ||
| 51 | .replica_thresholds = mp_thresholds_init(), | 54 | .replica_thresholds = mp_thresholds_init(), |
| 55 | |||
| 56 | .output_format_is_set = false, | ||
| 52 | }; | 57 | }; |
| 53 | return tmp; | 58 | return tmp; |
| 54 | } | 59 | } |
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 8af378d5..ae6cc15d 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
| @@ -73,6 +73,10 @@ int main(int argc, char **argv) { | |||
| 73 | 73 | ||
| 74 | const check_mysql_query_config config = tmp_config.config; | 74 | const check_mysql_query_config config = tmp_config.config; |
| 75 | 75 | ||
| 76 | if (config.output_format_is_set) { | ||
| 77 | mp_set_format(config.output_format); | ||
| 78 | } | ||
| 79 | |||
| 76 | MYSQL mysql; | 80 | MYSQL mysql; |
| 77 | /* initialize mysql */ | 81 | /* initialize mysql */ |
| 78 | mysql_init(&mysql); | 82 | mysql_init(&mysql); |
| @@ -185,6 +189,10 @@ int main(int argc, char **argv) { | |||
| 185 | 189 | ||
| 186 | /* process command-line arguments */ | 190 | /* process command-line arguments */ |
| 187 | check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | 191 | check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { |
| 192 | enum { | ||
| 193 | output_format_index = CHAR_MAX + 1, | ||
| 194 | }; | ||
| 195 | |||
| 188 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, | 196 | static struct option longopts[] = {{"hostname", required_argument, 0, 'H'}, |
| 189 | {"socket", required_argument, 0, 's'}, | 197 | {"socket", required_argument, 0, 's'}, |
| 190 | {"database", required_argument, 0, 'd'}, | 198 | {"database", required_argument, 0, 'd'}, |
| @@ -199,6 +207,7 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | |||
| 199 | {"query", required_argument, 0, 'q'}, | 207 | {"query", required_argument, 0, 'q'}, |
| 200 | {"warning", required_argument, 0, 'w'}, | 208 | {"warning", required_argument, 0, 'w'}, |
| 201 | {"critical", required_argument, 0, 'c'}, | 209 | {"critical", required_argument, 0, 'c'}, |
| 210 | {"output-format", required_argument, 0, output_format_index}, | ||
| 202 | {0, 0, 0, 0}}; | 211 | {0, 0, 0, 0}}; |
| 203 | 212 | ||
| 204 | check_mysql_query_config_wrapper result = { | 213 | check_mysql_query_config_wrapper result = { |
| @@ -282,6 +291,17 @@ check_mysql_query_config_wrapper process_arguments(int argc, char **argv) { | |||
| 282 | } break; | 291 | } break; |
| 283 | case '?': /* help */ | 292 | case '?': /* help */ |
| 284 | usage5(); | 293 | usage5(); |
| 294 | case output_format_index: { | ||
| 295 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 296 | if (!parser.parsing_success) { | ||
| 297 | printf("Invalid output format: %s\n", optarg); | ||
| 298 | exit(STATE_UNKNOWN); | ||
| 299 | } | ||
| 300 | |||
| 301 | result.config.output_format_is_set = true; | ||
| 302 | result.config.output_format = parser.output_format; | ||
| 303 | break; | ||
| 304 | } | ||
| 285 | } | 305 | } |
| 286 | } | 306 | } |
| 287 | 307 | ||
| @@ -344,6 +364,8 @@ void print_help(void) { | |||
| 344 | printf(" ==> %s <==\n", _("IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!")); | 364 | printf(" ==> %s <==\n", _("IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!!")); |
| 345 | printf(" %s\n", _("Your clear-text password could be visible as a process table entry")); | 365 | printf(" %s\n", _("Your clear-text password could be visible as a process table entry")); |
| 346 | 366 | ||
| 367 | printf(UT_OUTPUT_FORMAT); | ||
| 368 | |||
| 347 | printf("\n"); | 369 | printf("\n"); |
| 348 | printf(" %s\n", _("A query is required. The result from the query should be numeric.")); | 370 | printf(" %s\n", _("A query is required. The result from the query should be numeric.")); |
| 349 | printf(" %s\n", _("For extra security, create a user with minimal access.")); | 371 | printf(" %s\n", _("For extra security, create a user with minimal access.")); |
diff --git a/plugins/check_mysql_query.d/config.h b/plugins/check_mysql_query.d/config.h index 1c9952e5..32ab455a 100644 --- a/plugins/check_mysql_query.d/config.h +++ b/plugins/check_mysql_query.d/config.h | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "../../config.h" | 3 | #include "../../config.h" |
| 4 | #include "output.h" | ||
| 4 | #include "thresholds.h" | 5 | #include "thresholds.h" |
| 5 | #include <mysql.h> | 6 | #include <mysql.h> |
| 6 | 7 | ||
| @@ -16,6 +17,9 @@ typedef struct { | |||
| 16 | 17 | ||
| 17 | char *sql_query; | 18 | char *sql_query; |
| 18 | mp_thresholds thresholds; | 19 | mp_thresholds thresholds; |
| 20 | |||
| 21 | bool output_format_is_set; | ||
| 22 | mp_output_format output_format; | ||
| 19 | } check_mysql_query_config; | 23 | } check_mysql_query_config; |
| 20 | 24 | ||
| 21 | check_mysql_query_config check_mysql_query_config_init() { | 25 | check_mysql_query_config check_mysql_query_config_init() { |
| @@ -31,6 +35,8 @@ check_mysql_query_config check_mysql_query_config_init() { | |||
| 31 | 35 | ||
| 32 | .sql_query = NULL, | 36 | .sql_query = NULL, |
| 33 | .thresholds = mp_thresholds_init(), | 37 | .thresholds = mp_thresholds_init(), |
| 38 | |||
| 39 | .output_format_is_set = false, | ||
| 34 | }; | 40 | }; |
| 35 | return tmp; | 41 | return tmp; |
| 36 | } | 42 | } |
