diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2025-03-31 23:58:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-31 23:58:02 +0200 |
| commit | 4924bc877f714ec00ac8b02378d11f1508bbe8b4 (patch) | |
| tree | 276d2c7b746e593133cf1fc6ca548e10f71e1b5f /lib/output.c | |
| parent | 922d16ab2e44594d0ae4e4ac0c2b095cb1a1003f (diff) | |
| parent | d0647ec7e1500c0e6164ac9820a7d623582bdde2 (diff) | |
| download | monitoring-plugins-4924bc877f714ec00ac8b02378d11f1508bbe8b4.tar.gz | |
Merge pull request #2113 from RincewindsHat/refactor/check_disk
Refactor/check disk
Diffstat (limited to 'lib/output.c')
| -rw-r--r-- | lib/output.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/output.c b/lib/output.c index 61fbf832..c408a2f5 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | // == Global variables | 14 | // == Global variables |
| 15 | static mp_output_format output_format = MP_FORMAT_DEFAULT; | 15 | static mp_output_format output_format = MP_FORMAT_DEFAULT; |
| 16 | static mp_output_detail_level level_of_detail = MP_DETAIL_ALL; | ||
| 16 | 17 | ||
| 17 | // == Prototypes == | 18 | // == Prototypes == |
| 18 | static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation); | 19 | static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation); |
| @@ -202,7 +203,12 @@ mp_state_enum mp_compute_subcheck_state(const mp_subcheck check) { | |||
| 202 | } | 203 | } |
| 203 | 204 | ||
| 204 | mp_subcheck_list *scl = check.subchecks; | 205 | mp_subcheck_list *scl = check.subchecks; |
| 205 | mp_state_enum result = check.default_state; | 206 | |
| 207 | if (scl == NULL) { | ||
| 208 | return check.default_state; | ||
| 209 | } | ||
| 210 | |||
| 211 | mp_state_enum result = STATE_OK; | ||
| 206 | 212 | ||
| 207 | while (scl != NULL) { | 213 | while (scl != NULL) { |
| 208 | result = max_state_alt(result, mp_compute_subcheck_state(scl->subcheck)); | 214 | result = max_state_alt(result, mp_compute_subcheck_state(scl->subcheck)); |
| @@ -247,7 +253,9 @@ char *mp_fmt_output(mp_check check) { | |||
| 247 | mp_subcheck_list *subchecks = check.subchecks; | 253 | mp_subcheck_list *subchecks = check.subchecks; |
| 248 | 254 | ||
| 249 | while (subchecks != NULL) { | 255 | while (subchecks != NULL) { |
| 250 | asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1)); | 256 | if (level_of_detail == MP_DETAIL_ALL || mp_compute_subcheck_state(subchecks->subcheck) != STATE_OK) { |
| 257 | asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1)); | ||
| 258 | } | ||
| 251 | subchecks = subchecks->next; | 259 | subchecks = subchecks->next; |
| 252 | } | 260 | } |
| 253 | 261 | ||
| @@ -539,3 +547,7 @@ parsed_output_format mp_parse_output_format(char *format_string) { | |||
| 539 | void mp_set_format(mp_output_format format) { output_format = format; } | 547 | void mp_set_format(mp_output_format format) { output_format = format; } |
| 540 | 548 | ||
| 541 | mp_output_format mp_get_format(void) { return output_format; } | 549 | mp_output_format mp_get_format(void) { return output_format; } |
| 550 | |||
| 551 | void mp_set_level_of_detail(mp_output_detail_level level) { level_of_detail = level; } | ||
| 552 | |||
| 553 | mp_output_detail_level mp_get_level_of_detail(void) { return level_of_detail; } | ||
