summaryrefslogtreecommitdiffstats
path: root/plugins/check_pgsql.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_pgsql.c')
-rw-r--r--plugins/check_pgsql.c18
1 files changed, 16 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."));