diff options
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/check_pgsql.c | 18 | ||||
| -rw-r--r-- | plugins/check_pgsql.d/config.h | 6 |
2 files changed, 22 insertions, 2 deletions
diff --git a/plugins/check_pgsql.c b/plugins/check_pgsql.c index cd314f29..5fbffa70 100644 --- a/plugins/check_pgsql.c +++ b/plugins/check_pgsql.c | |||
| @@ -150,8 +150,8 @@ int main(int argc, char **argv) { | |||
| 150 | 150 | ||
| 151 | const check_pgsql_config config = tmp_config.config; | 151 | const check_pgsql_config config = tmp_config.config; |
| 152 | 152 | ||
| 153 | if (verbose > 2) { | 153 | if (config.output_format_is_set) { |
| 154 | printf("Arguments initialized\n"); | 154 | mp_set_format(config.output_format); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | /* Set signal handling and alarm */ | 157 | /* Set signal handling and alarm */ |
| @@ -335,6 +335,7 @@ static check_pgsql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 335 | 335 | ||
| 336 | enum { | 336 | enum { |
| 337 | OPTID_QUERYNAME = CHAR_MAX + 1, | 337 | OPTID_QUERYNAME = CHAR_MAX + 1, |
| 338 | output_format_index, | ||
| 338 | }; | 339 | }; |
| 339 | 340 | ||
| 340 | static struct option longopts[] = {{"help", no_argument, 0, 'h'}, | 341 | static struct option longopts[] = {{"help", no_argument, 0, 'h'}, |
| @@ -354,6 +355,7 @@ static check_pgsql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 354 | {"query_critical", required_argument, 0, 'C'}, | 355 | {"query_critical", required_argument, 0, 'C'}, |
| 355 | {"query_warning", required_argument, 0, 'W'}, | 356 | {"query_warning", required_argument, 0, 'W'}, |
| 356 | {"verbose", no_argument, 0, 'v'}, | 357 | {"verbose", no_argument, 0, 'v'}, |
| 358 | {"output-format", required_argument, 0, output_format_index}, | ||
| 357 | {0, 0, 0, 0}}; | 359 | {0, 0, 0, 0}}; |
| 358 | 360 | ||
| 359 | check_pgsql_config_wrapper result = { | 361 | check_pgsql_config_wrapper result = { |
| @@ -371,6 +373,17 @@ static check_pgsql_config_wrapper process_arguments(int argc, char **argv) { | |||
| 371 | } | 373 | } |
| 372 | 374 | ||
| 373 | switch (option_char) { | 375 | switch (option_char) { |
| 376 | case output_format_index: { | ||
| 377 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 378 | if (!parser.parsing_success) { | ||
| 379 | printf("Invalid output format: %s\n", optarg); | ||
| 380 | exit(STATE_UNKNOWN); | ||
| 381 | } | ||
| 382 | |||
| 383 | result.config.output_format_is_set = true; | ||
| 384 | result.config.output_format = parser.output_format; | ||
| 385 | break; | ||
| 386 | } | ||
| 374 | case '?': /* usage */ | 387 | case '?': /* usage */ |
| 375 | usage5(); | 388 | usage5(); |
| 376 | case 'h': /* help */ | 389 | case 'h': /* help */ |
| @@ -557,6 +570,7 @@ void print_help(void) { | |||
| 557 | printf(" %s\n", _("SQL query value to result in critical status (double)")); | 570 | printf(" %s\n", _("SQL query value to result in critical status (double)")); |
| 558 | 571 | ||
| 559 | printf(UT_VERBOSE); | 572 | printf(UT_VERBOSE); |
| 573 | printf(UT_OUTPUT_FORMAT); | ||
| 560 | 574 | ||
| 561 | printf("\n"); | 575 | printf("\n"); |
| 562 | printf(" %s\n", _("All parameters are optional.")); | 576 | printf(" %s\n", _("All parameters are optional.")); |
diff --git a/plugins/check_pgsql.d/config.h b/plugins/check_pgsql.d/config.h index 7c1ff55a..7cf0637b 100644 --- a/plugins/check_pgsql.d/config.h +++ b/plugins/check_pgsql.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 "perfdata.h" | 5 | #include "perfdata.h" |
| 5 | #include "thresholds.h" | 6 | #include "thresholds.h" |
| 6 | #include <stddef.h> | 7 | #include <stddef.h> |
| @@ -27,6 +28,9 @@ typedef struct { | |||
| 27 | 28 | ||
| 28 | mp_thresholds time_thresholds; | 29 | mp_thresholds time_thresholds; |
| 29 | mp_thresholds qthresholds; | 30 | mp_thresholds qthresholds; |
| 31 | |||
| 32 | bool output_format_is_set; | ||
| 33 | mp_output_format output_format; | ||
| 30 | } check_pgsql_config; | 34 | } check_pgsql_config; |
| 31 | 35 | ||
| 32 | /* begin, by setting the parameters for a backend connection if the | 36 | /* begin, by setting the parameters for a backend connection if the |
| @@ -51,6 +55,8 @@ check_pgsql_config check_pgsql_config_init() { | |||
| 51 | 55 | ||
| 52 | .time_thresholds = mp_thresholds_init(), | 56 | .time_thresholds = mp_thresholds_init(), |
| 53 | .qthresholds = mp_thresholds_init(), | 57 | .qthresholds = mp_thresholds_init(), |
| 58 | |||
| 59 | .output_format_is_set = false, | ||
| 54 | }; | 60 | }; |
| 55 | 61 | ||
| 56 | mp_range tmp_range = mp_range_init(); | 62 | mp_range tmp_range = mp_range_init(); |
