diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/output.c | 7 | ||||
| -rw-r--r-- | lib/output.h | 4 | ||||
| -rw-r--r-- | lib/perfdata.c | 11 | ||||
| -rw-r--r-- | lib/utils_base.h | 2 |
4 files changed, 22 insertions, 2 deletions
diff --git a/lib/output.c b/lib/output.c index bfd43195..54d505d9 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -61,6 +61,8 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) { | |||
| 61 | mp_check mp_check_init(void) { | 61 | mp_check mp_check_init(void) { |
| 62 | mp_check check = { | 62 | mp_check check = { |
| 63 | .evaluation_function = &mp_eval_check_default, | 63 | .evaluation_function = &mp_eval_check_default, |
| 64 | .default_output_override = NULL, | ||
| 65 | .default_output_override_content = NULL, | ||
| 64 | }; | 66 | }; |
| 65 | return check; | 67 | return check; |
| 66 | } | 68 | } |
| @@ -283,6 +285,11 @@ char *mp_fmt_output(mp_check check) { | |||
| 283 | 285 | ||
| 284 | switch (output_format) { | 286 | switch (output_format) { |
| 285 | case MP_FORMAT_MULTI_LINE: { | 287 | case MP_FORMAT_MULTI_LINE: { |
| 288 | if (check.default_output_override != NULL) { | ||
| 289 | result = check.default_output_override(check.default_output_override_content); | ||
| 290 | break; | ||
| 291 | } | ||
| 292 | |||
| 286 | if (check.summary == NULL) { | 293 | if (check.summary == NULL) { |
| 287 | check.summary = get_subcheck_summary(check); | 294 | check.summary = get_subcheck_summary(check); |
| 288 | } | 295 | } |
diff --git a/lib/output.h b/lib/output.h index c63c8e3f..f5011268 100644 --- a/lib/output.h +++ b/lib/output.h | |||
| @@ -70,6 +70,10 @@ struct mp_check { | |||
| 70 | 70 | ||
| 71 | // the evaluation_functions computes the state of check | 71 | // the evaluation_functions computes the state of check |
| 72 | mp_state_enum (*evaluation_function)(mp_check); | 72 | mp_state_enum (*evaluation_function)(mp_check); |
| 73 | |||
| 74 | // override for the default output format | ||
| 75 | char *(*default_output_override)(void *); | ||
| 76 | void *default_output_override_content; | ||
| 73 | }; | 77 | }; |
| 74 | 78 | ||
| 75 | mp_check mp_check_init(void); | 79 | mp_check mp_check_init(void); |
diff --git a/lib/perfdata.c b/lib/perfdata.c index f4eaf843..e3710ec7 100644 --- a/lib/perfdata.c +++ b/lib/perfdata.c | |||
| @@ -251,7 +251,16 @@ char *mp_range_to_string(const mp_range input) { | |||
| 251 | if (input.start_infinity) { | 251 | if (input.start_infinity) { |
| 252 | asprintf(&result, "%s~:", result); | 252 | asprintf(&result, "%s~:", result); |
| 253 | } else { | 253 | } else { |
| 254 | asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); | 254 | // check for zeroes, so we can use the short form |
| 255 | if ((input.start.type == PD_TYPE_NONE) || | ||
| 256 | ((input.start.type == PD_TYPE_INT) && (input.start.pd_int == 0)) || | ||
| 257 | ((input.start.type == PD_TYPE_UINT) && (input.start.pd_uint == 0)) || | ||
| 258 | ((input.start.type == PD_TYPE_DOUBLE) && (input.start.pd_double == 0))){ | ||
| 259 | // nothing to do here | ||
| 260 | } else { | ||
| 261 | // Start value is an actual value | ||
| 262 | asprintf(&result, "%s%s:", result, pd_value_to_string(input.start)); | ||
| 263 | } | ||
| 255 | } | 264 | } |
| 256 | 265 | ||
| 257 | if (!input.end_infinity) { | 266 | if (!input.end_infinity) { |
diff --git a/lib/utils_base.h b/lib/utils_base.h index 27884bf0..1da96f78 100644 --- a/lib/utils_base.h +++ b/lib/utils_base.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "./thresholds.h" | 9 | #include "./thresholds.h" |
| 10 | #include "states.h" | 10 | #include "states.h" |
| 11 | 11 | ||
| 12 | #ifndef USE_OPENSSL | 12 | #ifndef MOPL_USE_OPENSSL |
| 13 | # include "sha256.h" | 13 | # include "sha256.h" |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
