From 0645c9fc2c7f801ba3c7d68a17c137a63ada299f Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Tue, 18 Feb 2025 21:58:34 +0100 Subject: Implement new output functionality --- plugins/utils.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'plugins/utils.h') diff --git a/plugins/utils.h b/plugins/utils.h index f939e337..c7073990 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -13,11 +13,11 @@ in order to resist overflow attacks. In addition, a few functions are provided to standardize version and error reporting across the entire suite of plugins. */ -/* now some functions etc are being defined in ../lib/utils_base.c */ -#include "utils_base.h" - +#include "../config.h" #include - +#include +#include +#include #ifdef NP_EXTRA_OPTS /* Include extra-opts functions if compiled in */ @@ -78,9 +78,6 @@ char *strpcat (char *, const char *, const char *); int xvasprintf (char **strp, const char *fmt, va_list ap); int xasprintf (char **strp, const char *fmt, ...); -int max_state (int a, int b); -int max_state_alt (int a, int b); - void usage (const char *) __attribute__((noreturn)); void usage2(const char *, const char *) __attribute__((noreturn)); void usage3(const char *, int) __attribute__((noreturn)); -- cgit v1.2.3-74-g34f1 From 07873c765b73c85482436880f122882dfccd7e1b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 20 Feb 2025 23:49:22 +0100 Subject: Place output-format help string with the other common ones --- plugins/check_swap.c | 3 +-- plugins/utils.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'plugins/utils.h') diff --git a/plugins/check_swap.c b/plugins/check_swap.c index 262d8d51..4d3b6099 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -381,8 +381,7 @@ void print_help(swap_config config) { _("Resulting state when there is no swap regardless of thresholds. " "Default:"), state_text(config.no_swap_state)); - printf(" %s\n", "--output-format"); - printf(" %s\n", _("Select output format. Valid values: \"icingaweb2\", \"mp-test-json\"")); + printf(UT_OUTPUT_FORMAT); printf(UT_VERBOSE); printf("\n"); diff --git a/plugins/utils.h b/plugins/utils.h index c7073990..bc26f704 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -195,4 +195,8 @@ The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\ copies of the plugins under the terms of the GNU General Public License.\n\ For more information about these matters, see the file named COPYING.\n") +#define UT_OUTPUT_FORMAT _("\ + --output-format=OUTPUT_FORMAT\n\ + Select output format. Valid values: \"icingaweb2\", \"mp-test-json\"\n") + #endif /* NP_UTILS_H */ -- cgit v1.2.3-74-g34f1 From 1d590a0efe4193ac9298d3eba448ab8bc3bb665b Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Thu, 20 Feb 2025 23:52:32 +0100 Subject: Rename icingaweb2 format to multi-line --- lib/output.c | 8 ++++---- lib/output.h | 4 ++-- plugins/utils.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'plugins/utils.h') diff --git a/lib/output.c b/lib/output.c index 07a77165..17919afc 100644 --- a/lib/output.c +++ b/lib/output.c @@ -235,7 +235,7 @@ char *mp_fmt_output(mp_check check) { char *result = NULL; switch (check.format) { - case MP_FORMAT_ICINGA_WEB_2: { + case MP_FORMAT_MULTI_LINE: { if (check.summary == NULL) { check.summary = get_subcheck_summary(check); } @@ -245,7 +245,7 @@ char *mp_fmt_output(mp_check check) { mp_subcheck_list *subchecks = check.subchecks; while (subchecks != NULL) { - asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_ICINGA_WEB_2, subchecks->subcheck, 1)); + asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1)); subchecks = subchecks->next; } @@ -330,7 +330,7 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch mp_subcheck_list *subchecks = NULL; switch (output_format) { - case MP_FORMAT_ICINGA_WEB_2: + case MP_FORMAT_MULTI_LINE: asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)), check.output); @@ -510,7 +510,7 @@ mp_subcheck mp_set_subcheck_default_state(mp_subcheck check, mp_state_enum state } char *mp_output_format_map[] = { - [MP_FORMAT_ICINGA_WEB_2] = "icingaweb2", + [MP_FORMAT_MULTI_LINE] = "multi-line", [MP_FORMAT_TEST_JSON] = "mp-test-json", }; diff --git a/lib/output.h b/lib/output.h index 14c4bcf4..ffc36f53 100644 --- a/lib/output.h +++ b/lib/output.h @@ -29,11 +29,11 @@ typedef struct subcheck_list { * Possible output formats */ typedef enum output_format { - MP_FORMAT_ICINGA_WEB_2, + MP_FORMAT_MULTI_LINE, MP_FORMAT_TEST_JSON, } mp_output_format; -#define MP_FORMAT_DEFAULT MP_FORMAT_ICINGA_WEB_2 +#define MP_FORMAT_DEFAULT MP_FORMAT_MULTI_LINE /* * The main state object of a plugin. Exists only ONCE per plugin. diff --git a/plugins/utils.h b/plugins/utils.h index bc26f704..029ae5a6 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -197,6 +197,6 @@ For more information about these matters, see the file named COPYING.\n") #define UT_OUTPUT_FORMAT _("\ --output-format=OUTPUT_FORMAT\n\ - Select output format. Valid values: \"icingaweb2\", \"mp-test-json\"\n") + Select output format. Valid values: \"multi-line\", \"mp-test-json\"\n") #endif /* NP_UTILS_H */ -- cgit v1.2.3-74-g34f1