diff options
Diffstat (limited to 'lib/output.h')
| -rw-r--r-- | lib/output.h | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/lib/output.h b/lib/output.h index 2bdfa074..37486925 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,19 @@ 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 | ||
| 69 | char *ok_summary; // (optional) Summary if the overall state is OK | ||
| 52 | mp_subcheck_list *subchecks; | 70 | mp_subcheck_list *subchecks; |
| 53 | } mp_check; | 71 | |
| 72 | // the evaluation_functions computes the state of check | ||
| 73 | mp_state_enum (*evaluation_function)(mp_check); | ||
| 74 | |||
| 75 | // override for the default output format | ||
| 76 | char *(*default_output_override)(void *); | ||
| 77 | void *default_output_override_content; | ||
| 78 | }; | ||
| 54 | 79 | ||
| 55 | mp_check mp_check_init(void); | 80 | mp_check mp_check_init(void); |
| 56 | mp_subcheck mp_subcheck_init(void); | 81 | mp_subcheck mp_subcheck_init(void); |
| @@ -63,11 +88,19 @@ int mp_add_subcheck_to_subcheck(mp_subcheck check[static 1], mp_subcheck); | |||
| 63 | 88 | ||
| 64 | void mp_add_perfdata_to_subcheck(mp_subcheck check[static 1], mp_perfdata); | 89 | void mp_add_perfdata_to_subcheck(mp_subcheck check[static 1], mp_perfdata); |
| 65 | 90 | ||
| 66 | void mp_add_summary(mp_check check[static 1], char *summary); | 91 | void mp_set_summary(mp_check check[static 1], char *summary); |
| 92 | void mp_set_ok_summary(mp_check check[static 1], char *ok_summary); | ||
| 67 | 93 | ||
| 68 | mp_state_enum mp_compute_check_state(mp_check); | 94 | mp_state_enum mp_compute_check_state(mp_check); |
| 69 | mp_state_enum mp_compute_subcheck_state(mp_subcheck); | 95 | mp_state_enum mp_compute_subcheck_state(mp_subcheck); |
| 70 | 96 | ||
| 97 | mp_state_enum mp_eval_ok(mp_check overall); | ||
| 98 | mp_state_enum mp_eval_warning(mp_check overall); | ||
| 99 | mp_state_enum mp_eval_critical(mp_check overall); | ||
| 100 | mp_state_enum mp_eval_unknown(mp_check overall); | ||
| 101 | mp_state_enum mp_eval_check_default(mp_check check); | ||
| 102 | mp_state_enum mp_eval_subcheck_default(mp_subcheck subcheck); | ||
| 103 | |||
| 71 | typedef struct { | 104 | typedef struct { |
| 72 | bool parsing_success; | 105 | bool parsing_success; |
| 73 | mp_output_format output_format; | 106 | mp_output_format output_format; |
