diff options
| author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2026-06-08 08:23:44 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-08 08:23:44 +0200 |
| commit | 9bbc76483888c9e2ef2f4ed281c0ab8f2aab7bb6 (patch) | |
| tree | c9f72dda47e082e9e2ce74377035b48c77415064 /lib/output.c | |
| parent | 992a4555ac975285f959dd2d3228b1d71ab23123 (diff) | |
| download | monitoring-plugins-9bbc76483888c9e2ef2f4ed281c0ab8f2aab7bb6.tar.gz | |
Ok summary (#2270)
* lib: implement functionality to set ok summary
* check_load: implement setting ok summary
* OK summary for ntp_peer, ntp_time and users
* check_apt: implement ok summary
* check_curl: implement ok summary
* check_disk: implement ok summary
* check_dbi: implement ok summary
* check_ldap: auto formatting
* check_ldap: implement ok summary
* check_ssh: implement ok summary
* check_tcp: implement ok summary
* fixup! check_curl: implement ok summary
* fixup! check_dbi: implement ok summary
* fixup! check_ldap: implement ok summary
* fixup! check_ssh: implement ok summary
* fixup! check_tcp: implement ok summary
* check_apt: remove illegal free
* check_mrtg: fix link
* check_mrtg: implement ok summary
* check_mrtgtraf: fix link
* check_mrtgtraf: implement ok summary
* check_mysql: implement ok summary
* check_mysql_query: implement ok summary
* check_pgsql: implement ok summary
* check_radius: implement ok summary
* check_real: implement ok summary
* check_smtp: implement ok summary
* check_snmp: implement ok summary
* check_swap: implement ok summary
* check_ups: add OK summary
---------
Co-authored-by: Lorenz Kästle <lorenz.kaestle@netways.de>
Diffstat (limited to 'lib/output.c')
| -rw-r--r-- | lib/output.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/output.c b/lib/output.c index 9bcd02d9..b1e91231 100644 --- a/lib/output.c +++ b/lib/output.c | |||
| @@ -105,6 +105,7 @@ static inline char *fmt_subcheck_perfdata(mp_subcheck check) { | |||
| 105 | */ | 105 | */ |
| 106 | mp_check mp_check_init(void) { | 106 | mp_check mp_check_init(void) { |
| 107 | mp_check check = { | 107 | mp_check check = { |
| 108 | .ok_summary = NULL, | ||
| 108 | .evaluation_function = &mp_eval_check_default, | 109 | .evaluation_function = &mp_eval_check_default, |
| 109 | .default_output_override = NULL, | 110 | .default_output_override = NULL, |
| 110 | .default_output_override_content = NULL, | 111 | .default_output_override_content = NULL, |
| @@ -212,6 +213,14 @@ int mp_add_subcheck_to_subcheck(mp_subcheck check[static 1], mp_subcheck subchec | |||
| 212 | void mp_set_summary(mp_check check[static 1], char *summary) { check->summary = strdup(summary); } | 213 | void mp_set_summary(mp_check check[static 1], char *summary) { check->summary = strdup(summary); } |
| 213 | 214 | ||
| 214 | /* | 215 | /* |
| 216 | * set the summary for the OK state | ||
| 217 | * this allows to set the content in the first line of the plugin | ||
| 218 | * if the overall state is OK | ||
| 219 | */ | ||
| 220 | void mp_set_ok_summary(mp_check check[static 1], char *ok_summary) { | ||
| 221 | check->ok_summary = strdup(ok_summary); | ||
| 222 | } | ||
| 223 | /* | ||
| 215 | * Generate the summary string of a mp_check object based on its subchecks | 224 | * Generate the summary string of a mp_check object based on its subchecks |
| 216 | */ | 225 | */ |
| 217 | char *get_subcheck_summary(mp_check check) { | 226 | char *get_subcheck_summary(mp_check check) { |
| @@ -255,21 +264,12 @@ char *get_subcheck_summary(mp_check check) { | |||
| 255 | } | 264 | } |
| 256 | 265 | ||
| 257 | if (result == NULL) { | 266 | if (result == NULL) { |
| 258 | if (ok_count > 0) { | 267 | // Nothing in result yet, we must be in an OK state |
| 268 | if (check.ok_summary != NULL) { | ||
| 269 | asprintf(&result, "%s", check.ok_summary); | ||
| 270 | } else if (ok_count > 0) { | ||
| 259 | asprintf(&result, "ok=%d", ok_count); | 271 | asprintf(&result, "ok=%d", ok_count); |
| 260 | } | 272 | } |
| 261 | |||
| 262 | if (warning_count > 0) { | ||
| 263 | asprintf(&result, "%swarning=%d", (result == NULL ? "" : ", "), warning_count); | ||
| 264 | } | ||
| 265 | |||
| 266 | if (critical_count > 0) { | ||
| 267 | asprintf(&result, "%scritical=%d", (result == NULL ? "" : ", "), critical_count); | ||
| 268 | } | ||
| 269 | |||
| 270 | if (unknown_count > 0) { | ||
| 271 | asprintf(&result, "%sunknown=%d", (result == NULL ? "" : ", "), unknown_count); | ||
| 272 | } | ||
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | return result; | 275 | return result; |
