diff options
| -rw-r--r-- | plugins/check_smtp.c | 22 | ||||
| -rw-r--r-- | plugins/check_smtp.d/config.h | 6 |
2 files changed, 27 insertions, 1 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index f2c7f05c..cb92421c 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
| @@ -115,6 +115,10 @@ int main(int argc, char **argv) { | |||
| 115 | 115 | ||
| 116 | const check_smtp_config config = tmp_config.config; | 116 | const check_smtp_config config = tmp_config.config; |
| 117 | 117 | ||
| 118 | if (config.output_format_is_set) { | ||
| 119 | mp_set_format(config.output_format); | ||
| 120 | } | ||
| 121 | |||
| 118 | /* If localhostname not set on command line, use gethostname to set */ | 122 | /* If localhostname not set on command line, use gethostname to set */ |
| 119 | char *localhostname = config.localhostname; | 123 | char *localhostname = config.localhostname; |
| 120 | if (!localhostname) { | 124 | if (!localhostname) { |
| @@ -578,7 +582,8 @@ int main(int argc, char **argv) { | |||
| 578 | /* process command-line arguments */ | 582 | /* process command-line arguments */ |
| 579 | check_smtp_config_wrapper process_arguments(int argc, char **argv) { | 583 | check_smtp_config_wrapper process_arguments(int argc, char **argv) { |
| 580 | enum { | 584 | enum { |
| 581 | SNI_OPTION = CHAR_MAX + 1 | 585 | SNI_OPTION = CHAR_MAX + 1, |
| 586 | output_format_index, | ||
| 582 | }; | 587 | }; |
| 583 | 588 | ||
| 584 | int option = 0; | 589 | int option = 0; |
| @@ -608,6 +613,7 @@ check_smtp_config_wrapper process_arguments(int argc, char **argv) { | |||
| 608 | {"certificate", required_argument, 0, 'D'}, | 613 | {"certificate", required_argument, 0, 'D'}, |
| 609 | {"ignore-quit-failure", no_argument, 0, 'q'}, | 614 | {"ignore-quit-failure", no_argument, 0, 'q'}, |
| 610 | {"proxy", no_argument, 0, 'r'}, | 615 | {"proxy", no_argument, 0, 'r'}, |
| 616 | {"output-format", required_argument, 0, output_format_index}, | ||
| 611 | {0, 0, 0, 0}}; | 617 | {0, 0, 0, 0}}; |
| 612 | 618 | ||
| 613 | check_smtp_config_wrapper result = { | 619 | check_smtp_config_wrapper result = { |
| @@ -809,6 +815,18 @@ check_smtp_config_wrapper process_arguments(int argc, char **argv) { | |||
| 809 | exit(STATE_UNKNOWN); | 815 | exit(STATE_UNKNOWN); |
| 810 | case '?': /* help */ | 816 | case '?': /* help */ |
| 811 | usage5(); | 817 | usage5(); |
| 818 | case output_format_index: { | ||
| 819 | parsed_output_format parser = mp_parse_output_format(optarg); | ||
| 820 | if (!parser.parsing_success) { | ||
| 821 | // TODO List all available formats here, maybe add anothoer usage function | ||
| 822 | printf("Invalid output format: %s\n", optarg); | ||
| 823 | exit(STATE_UNKNOWN); | ||
| 824 | } | ||
| 825 | |||
| 826 | result.config.output_format_is_set = true; | ||
| 827 | result.config.output_format = parser.output_format; | ||
| 828 | break; | ||
| 829 | } | ||
| 812 | } | 830 | } |
| 813 | } | 831 | } |
| 814 | 832 | ||
| @@ -1015,6 +1033,8 @@ void print_help(void) { | |||
| 1015 | 1033 | ||
| 1016 | printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); | 1034 | printf(UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); |
| 1017 | 1035 | ||
| 1036 | printf(UT_OUTPUT_FORMAT); | ||
| 1037 | |||
| 1018 | printf(UT_VERBOSE); | 1038 | printf(UT_VERBOSE); |
| 1019 | 1039 | ||
| 1020 | printf("\n"); | 1040 | printf("\n"); |
diff --git a/plugins/check_smtp.d/config.h b/plugins/check_smtp.d/config.h index bc433093..11d7fe56 100644 --- a/plugins/check_smtp.d/config.h +++ b/plugins/check_smtp.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 <string.h> | 7 | #include <string.h> |
| @@ -46,6 +47,9 @@ typedef struct { | |||
| 46 | bool use_starttls; | 47 | bool use_starttls; |
| 47 | bool use_sni; | 48 | bool use_sni; |
| 48 | #endif | 49 | #endif |
| 50 | |||
| 51 | bool output_format_is_set; | ||
| 52 | mp_output_format output_format; | ||
| 49 | } check_smtp_config; | 53 | } check_smtp_config; |
| 50 | 54 | ||
| 51 | check_smtp_config check_smtp_config_init() { | 55 | check_smtp_config check_smtp_config_init() { |
| @@ -83,6 +87,8 @@ check_smtp_config check_smtp_config_init() { | |||
| 83 | .use_starttls = false, | 87 | .use_starttls = false, |
| 84 | .use_sni = false, | 88 | .use_sni = false, |
| 85 | #endif | 89 | #endif |
| 90 | |||
| 91 | .output_format_is_set = false, | ||
| 86 | }; | 92 | }; |
| 87 | return tmp; | 93 | return tmp; |
| 88 | } | 94 | } |
