diff options
Diffstat (limited to 'lib/output.h')
-rw-r--r-- | lib/output.h | 47 |
1 files changed, 37 insertions, 10 deletions
diff --git a/lib/output.h b/lib/output.h index 2bdfa074..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 | */ |
10 | typedef struct { | 10 | typedef struct mp_subcheck mp_subcheck; |
11 | struct 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 |
@@ -38,8 +44,18 @@ typedef enum output_format { | |||
38 | /* | 44 | /* |
39 | * Format related functions | 45 | * Format related functions |
40 | */ | 46 | */ |
41 | void mp_set_format(mp_output_format format); | 47 | void mp_set_format(mp_output_format format); |
42 | mp_output_format mp_get_format(void); | 48 | mp_output_format mp_get_format(void); |
49 | |||
50 | // Output detail level | ||
51 | |||
52 | typedef enum output_detail_level { | ||
53 | MP_DETAIL_ALL, | ||
54 | MP_DETAIL_NON_OK_ONLY, | ||
55 | } mp_output_detail_level; | ||
56 | |||
57 | void mp_set_level_of_detail(mp_output_detail_level level); | ||
58 | mp_output_detail_level mp_get_level_of_detail(void); | ||
43 | 59 | ||
44 | /* | 60 | /* |
45 | * 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. |
@@ -47,10 +63,14 @@ typedef enum output_format { | |||
47 | * 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 |
48 | * in the first layer of subchecks | 64 | * in the first layer of subchecks |
49 | */ | 65 | */ |
50 | typedef struct { | 66 | typedef struct mp_check mp_check; |
51 | char *summary; // Overall summary, if not set a summary will be automatically generated | 67 | struct mp_check { |
68 | char *summary; // Overall summary, if not set a summary will be automatically generated | ||
52 | mp_subcheck_list *subchecks; | 69 | mp_subcheck_list *subchecks; |
53 | } mp_check; | 70 | |
71 | // the evaluation_functions computes the state of check | ||
72 | mp_state_enum (*evaluation_function)(mp_check); | ||
73 | }; | ||
54 | 74 | ||
55 | mp_check mp_check_init(void); | 75 | mp_check mp_check_init(void); |
56 | mp_subcheck mp_subcheck_init(void); | 76 | mp_subcheck mp_subcheck_init(void); |
@@ -68,6 +88,13 @@ void mp_add_summary(mp_check check[static 1], char *summary); | |||
68 | mp_state_enum mp_compute_check_state(mp_check); | 88 | mp_state_enum mp_compute_check_state(mp_check); |
69 | mp_state_enum mp_compute_subcheck_state(mp_subcheck); | 89 | mp_state_enum mp_compute_subcheck_state(mp_subcheck); |
70 | 90 | ||
91 | mp_state_enum mp_eval_ok(mp_check overall); | ||
92 | mp_state_enum mp_eval_warning(mp_check overall); | ||
93 | mp_state_enum mp_eval_critical(mp_check overall); | ||
94 | mp_state_enum mp_eval_unknown(mp_check overall); | ||
95 | mp_state_enum mp_eval_check_default(mp_check check); | ||
96 | mp_state_enum mp_eval_subcheck_default(mp_subcheck subcheck); | ||
97 | |||
71 | typedef struct { | 98 | typedef struct { |
72 | bool parsing_success; | 99 | bool parsing_success; |
73 | mp_output_format output_format; | 100 | mp_output_format output_format; |