diff options
Diffstat (limited to 'plugins/check_ldap.c')
| -rw-r--r-- | plugins/check_ldap.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c index c3f83901..8ee0e617 100644 --- a/plugins/check_ldap.c +++ b/plugins/check_ldap.c | |||
| @@ -82,6 +82,10 @@ int main(int argc, char *argv[]) { | |||
| 82 | 82 | ||
| 83 | const check_ldap_config config = tmp_config.config; | 83 | const check_ldap_config config = tmp_config.config; |
| 84 | 84 | ||
| 85 | if (config.output_format_is_set) { | ||
| 86 | mp_set_format(config.output_format); | ||
| 87 | } | ||
| 88 | |||
| 85 | /* initialize alarm signal handling */ | 89 | /* initialize alarm signal handling */ |
| 86 | signal(SIGALRM, socket_timeout_alarm_handler); | 90 | signal(SIGALRM, socket_timeout_alarm_handler); |
| 87 | 91 | ||
| @@ -306,6 +310,10 @@ int main(int argc, char *argv[]) { | |||
| 306 | 310 | ||
| 307 | /* process command-line arguments */ | 311 | /* process command-line arguments */ |
| 308 | check_ldap_config_wrapper process_arguments(int argc, char **argv) { | 312 | check_ldap_config_wrapper process_arguments(int argc, char **argv) { |
| 313 | enum { | ||
| 314 | output_format_index = CHAR_MAX + 1, | ||
| 315 | }; | ||
| 316 | |||
| 309 | /* initialize the long option struct */ | 317 | /* initialize the long option struct */ |
| 310 | static struct option longopts[] = {{"help", no_argument, 0, 'h'}, | 318 | static struct option longopts[] = {{"help", no_argument, 0, 'h'}, |
| 311 | {"version", no_argument, 0, 'V'}, | 319 | {"version", no_argument, 0, 'V'}, |
| @@ -329,6 +337,7 @@ check_ldap_config_wrapper process_arguments(int argc, char **argv) { | |||
| 329 | {"warn-entries", required_argument, 0, 'W'}, | 337 | {"warn-entries", required_argument, 0, 'W'}, |
| 330 | {"crit-entries", required_argument, 0, 'C'}, | 338 | {"crit-entries", required_argument, 0, 'C'}, |
| 331 | {"verbose", no_argument, 0, 'v'}, | 339 | {"verbose", no_argument, 0, 'v'}, |
| 340 | {"output-format", required_argument, 0, output_format_index}, | ||
| 332 | {0, 0, 0, 0}}; | 341 | {0, 0, 0, 0}}; |
| 333 | 342 | ||
| 334 | check_ldap_config_wrapper result = { | 343 | check_ldap_config_wrapper result = { |
| @@ -458,6 +467,18 @@ check_ldap_config_wrapper process_arguments(int argc, char **argv) { | |||
| 458 | usage(_("IPv6 support not available\n")); | 467 | usage(_("IPv6 support not available\n")); |
| 459 | #endif | 468 | #endif |
| 460 | break; | 469 | break; |
| 470 | case output_format_index: { | ||
| 471 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 472 | if (!parser.parsing_success) { | ||
| 473 | // TODO List all available formats here, maybe add anothoer usage function | ||
| 474 | printf("Invalid output format: %s\n", optarg); | ||
| 475 | exit(STATE_UNKNOWN); | ||
| 476 | } | ||
| 477 | |||
| 478 | result.config.output_format_is_set = true; | ||
| 479 | result.config.output_format = parser.output_format; | ||
| 480 | break; | ||
| 481 | } | ||
| 461 | default: | 482 | default: |
| 462 | usage5(); | 483 | usage5(); |
| 463 | } | 484 | } |
| @@ -553,6 +574,7 @@ void print_help(void) { | |||
| 553 | printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 574 | printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
| 554 | 575 | ||
| 555 | printf(UT_VERBOSE); | 576 | printf(UT_VERBOSE); |
| 577 | printf(UT_OUTPUT_FORMAT); | ||
| 556 | 578 | ||
| 557 | printf("\n"); | 579 | printf("\n"); |
| 558 | printf("%s\n", _("Notes:")); | 580 | printf("%s\n", _("Notes:")); |
