summaryrefslogtreecommitdiffstats
path: root/lib/output.h
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-06-20 11:29:07 +0200
committerGitHub <noreply@github.com>2025-06-20 11:29:07 +0200
commitb8580c18e354b9070adbf464df186442d55dc120 (patch)
treec5d126ae124b6c48d34384472304803a01f0a7af /lib/output.h
parent916d3a52a0f01f05bbf42008fa5dddcee6ad7522 (diff)
parentd2735eecd4c44ba4a2504304963e861a427e393e (diff)
downloadmonitoring-plugins-b8580c18e354b9070adbf464df186442d55dc120.tar.gz
Merge pull request #2125 from RincewindsHat/refactor/check_icmp
Refactor check_icmp: - Far less global variables - Proper IPv6/legacy IP dual stack functionality (allowed mixed v4/v6 hosts) - Improved readability/understandability - General cleanup
Diffstat (limited to 'lib/output.h')
-rw-r--r--lib/output.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/output.h b/lib/output.h
index 3bd91f90..c63c8e3f 100644
--- a/lib/output.h
+++ b/lib/output.h
@@ -7,15 +7,21 @@
7/* 7/*
8 * A partial check result 8 * A partial check result
9 */ 9 */
10typedef struct { 10typedef struct mp_subcheck mp_subcheck;
11struct mp_subcheck {
11 mp_state_enum state; // OK, Warning, Critical ... set explicitly 12 mp_state_enum state; // OK, Warning, Critical ... set explicitly
12 mp_state_enum default_state; // OK, Warning, Critical .. if not set explicitly 13 mp_state_enum default_state; // OK, Warning, Critical .. if not set explicitly
13 bool state_set_explicitly; // was the state set explicitly (or should it be derived from subchecks) 14 bool state_set_explicitly; // was the state set explicitly (or should it be derived from
15 // subchecks)
14 16
15 char *output; // Text output for humans ("Filesystem xyz is fine", "Could not create TCP connection to..") 17 char *output; // Text output for humans ("Filesystem xyz is fine", "Could not create TCP
16 pd_list *perfdata; // Performance data for this check 18 // connection to..")
19 pd_list *perfdata; // Performance data for this check
17 struct subcheck_list *subchecks; // subchecks deeper in the hierarchy 20 struct subcheck_list *subchecks; // subchecks deeper in the hierarchy
18} mp_subcheck; 21
22 // the evaluation_functions computes the state of subcheck
23 mp_state_enum (*evaluation_function)(mp_subcheck);
24};
19 25
20/* 26/*
21 * A list of subchecks, used in subchecks and the main check 27 * A list of subchecks, used in subchecks and the main check
@@ -57,10 +63,14 @@ mp_output_detail_level mp_get_level_of_detail(void);
57 * The final result is always derived from the children and the "worst" state 63 * The final result is always derived from the children and the "worst" state
58 * in the first layer of subchecks 64 * in the first layer of subchecks
59 */ 65 */
60typedef struct { 66typedef struct mp_check mp_check;
67struct mp_check {
61 char *summary; // Overall summary, if not set a summary will be automatically generated 68 char *summary; // Overall summary, if not set a summary will be automatically generated
62 mp_subcheck_list *subchecks; 69 mp_subcheck_list *subchecks;
63} mp_check; 70
71 // the evaluation_functions computes the state of check
72 mp_state_enum (*evaluation_function)(mp_check);
73};
64 74
65mp_check mp_check_init(void); 75mp_check mp_check_init(void);
66mp_subcheck mp_subcheck_init(void); 76mp_subcheck mp_subcheck_init(void);
@@ -78,6 +88,13 @@ void mp_add_summary(mp_check check[static 1], char *summary);
78mp_state_enum mp_compute_check_state(mp_check); 88mp_state_enum mp_compute_check_state(mp_check);
79mp_state_enum mp_compute_subcheck_state(mp_subcheck); 89mp_state_enum mp_compute_subcheck_state(mp_subcheck);
80 90
91mp_state_enum mp_eval_ok(mp_check overall);
92mp_state_enum mp_eval_warning(mp_check overall);
93mp_state_enum mp_eval_critical(mp_check overall);
94mp_state_enum mp_eval_unknown(mp_check overall);
95mp_state_enum mp_eval_check_default(mp_check check);
96mp_state_enum mp_eval_subcheck_default(mp_subcheck subcheck);
97
81typedef struct { 98typedef struct {
82 bool parsing_success; 99 bool parsing_success;
83 mp_output_format output_format; 100 mp_output_format output_format;