summaryrefslogtreecommitdiffstats
path: root/plugins/check_dbi.c
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-10-29 23:27:31 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-10-29 23:27:31 +0100
commit408783f53d0baaf7341c7c584ca64a9073d66ee2 (patch)
tree7a8c5124384471e9d327c06051ec4b310d69cb58 /plugins/check_dbi.c
parent071de8a73a283ac7e262194c2c08fabfef4473b1 (diff)
downloadmonitoring-plugins-408783f53d0baaf7341c7c584ca64a9073d66ee2.tar.gz
check_dbi: add output format parameter
Diffstat (limited to 'plugins/check_dbi.c')
-rw-r--r--plugins/check_dbi.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/plugins/check_dbi.c b/plugins/check_dbi.c
index ddd0b328..286635cc 100644
--- a/plugins/check_dbi.c
+++ b/plugins/check_dbi.c
@@ -100,6 +100,10 @@ int main(int argc, char **argv) {
100 100
101 const check_dbi_config config = tmp.config; 101 const check_dbi_config config = tmp.config;
102 102
103 if (config.output_format_is_set) {
104 mp_set_format(config.output_format);
105 }
106
103 /* Set signal handling and alarm */ 107 /* Set signal handling and alarm */
104 if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) { 108 if (signal(SIGALRM, timeout_alarm_handler) == SIG_ERR) {
105 usage4(_("Cannot catch SIGALRM")); 109 usage4(_("Cannot catch SIGALRM"));
@@ -421,6 +425,9 @@ int main(int argc, char **argv) {
421 425
422/* process command-line arguments */ 426/* process command-line arguments */
423check_dbi_config_wrapper process_arguments(int argc, char **argv) { 427check_dbi_config_wrapper process_arguments(int argc, char **argv) {
428 enum {
429 output_format_index = CHAR_MAX + 1,
430 };
424 431
425 int option = 0; 432 int option = 0;
426 static struct option longopts[] = {STD_LONG_OPTS, 433 static struct option longopts[] = {STD_LONG_OPTS,
@@ -432,6 +439,7 @@ check_dbi_config_wrapper process_arguments(int argc, char **argv) {
432 {"option", required_argument, 0, 'o'}, 439 {"option", required_argument, 0, 'o'},
433 {"query", required_argument, 0, 'q'}, 440 {"query", required_argument, 0, 'q'},
434 {"database", required_argument, 0, 'D'}, 441 {"database", required_argument, 0, 'D'},
442 {"output-format", required_argument, 0, output_format_index},
435 {0, 0, 0, 0}}; 443 {0, 0, 0, 0}};
436 444
437 check_dbi_config_wrapper result = { 445 check_dbi_config_wrapper result = {
@@ -556,6 +564,18 @@ check_dbi_config_wrapper process_arguments(int argc, char **argv) {
556 case 'D': 564 case 'D':
557 result.config.dbi_database = optarg; 565 result.config.dbi_database = optarg;
558 break; 566 break;
567 case output_format_index: {
568 parsed_output_format parser = mp_parse_output_format(optarg);
569 if (!parser.parsing_success) {
570 // TODO List all available formats here, maybe add anothoer usage function
571 printf("Invalid output format: %s\n", optarg);
572 exit(STATE_UNKNOWN);
573 }
574
575 result.config.output_format_is_set = true;
576 result.config.output_format = parser.output_format;
577 break;
578 }
559 } 579 }
560 } 580 }
561 581