summaryrefslogtreecommitdiffstats
path: root/lib/output.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output.h')
-rw-r--r--lib/output.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/lib/output.h b/lib/output.h
index ffc36f53..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
@@ -36,16 +42,35 @@ typedef enum output_format {
36#define MP_FORMAT_DEFAULT MP_FORMAT_MULTI_LINE 42#define MP_FORMAT_DEFAULT MP_FORMAT_MULTI_LINE
37 43
38/* 44/*
45 * Format related functions
46 */
47void mp_set_format(mp_output_format format);
48mp_output_format mp_get_format(void);
49
50// Output detail level
51
52typedef enum output_detail_level {
53 MP_DETAIL_ALL,
54 MP_DETAIL_NON_OK_ONLY,
55} mp_output_detail_level;
56
57void mp_set_level_of_detail(mp_output_detail_level level);
58mp_output_detail_level mp_get_level_of_detail(void);
59
60/*
39 * The main state object of a plugin. Exists only ONCE per plugin. 61 * The main state object of a plugin. Exists only ONCE per plugin.
40 * This is the "root" of a tree of singular checks. 62 * This is the "root" of a tree of singular checks.
41 * 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
42 * in the first layer of subchecks 64 * in the first layer of subchecks
43 */ 65 */
44typedef struct { 66typedef struct mp_check mp_check;
45 mp_output_format format; // The output format 67struct mp_check {
46 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
47 mp_subcheck_list *subchecks; 69 mp_subcheck_list *subchecks;
48} mp_check; 70
71 // the evaluation_functions computes the state of check
72 mp_state_enum (*evaluation_function)(mp_check);
73};
49 74
50mp_check mp_check_init(void); 75mp_check mp_check_init(void);
51mp_subcheck mp_subcheck_init(void); 76mp_subcheck mp_subcheck_init(void);
@@ -63,6 +88,13 @@ void mp_add_summary(mp_check check[static 1], char *summary);
63mp_state_enum mp_compute_check_state(mp_check); 88mp_state_enum mp_compute_check_state(mp_check);
64mp_state_enum mp_compute_subcheck_state(mp_subcheck); 89mp_state_enum mp_compute_subcheck_state(mp_subcheck);
65 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
66typedef struct { 98typedef struct {
67 bool parsing_success; 99 bool parsing_success;
68 mp_output_format output_format; 100 mp_output_format output_format;