mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-15 22:00:06 -04:00
Add selectable level of detail for output
This commit is contained in:
parent
f84f614f21
commit
f413ac38e3
2 changed files with 20 additions and 4 deletions
|
|
@ -253,7 +253,9 @@ char *mp_fmt_output(mp_check check) {
|
|||
mp_subcheck_list *subchecks = check.subchecks;
|
||||
|
||||
while (subchecks != NULL) {
|
||||
asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1));
|
||||
if (level_of_detail == MP_DETAIL_ALL || mp_compute_subcheck_state(subchecks->subcheck) != STATE_OK) {
|
||||
asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1));
|
||||
}
|
||||
subchecks = subchecks->next;
|
||||
}
|
||||
|
||||
|
|
@ -545,3 +547,7 @@ parsed_output_format mp_parse_output_format(char *format_string) {
|
|||
void mp_set_format(mp_output_format format) { output_format = format; }
|
||||
|
||||
mp_output_format mp_get_format(void) { return output_format; }
|
||||
|
||||
void mp_set_level_of_detail(mp_output_detail_level level) { level_of_detail = level; }
|
||||
|
||||
mp_output_detail_level mp_get_level_of_detail(void) { return level_of_detail; }
|
||||
|
|
|
|||
16
lib/output.h
16
lib/output.h
|
|
@ -38,8 +38,18 @@ typedef enum output_format {
|
|||
/*
|
||||
* Format related functions
|
||||
*/
|
||||
void mp_set_format(mp_output_format format);
|
||||
mp_output_format mp_get_format(void);
|
||||
void mp_set_format(mp_output_format format);
|
||||
mp_output_format mp_get_format(void);
|
||||
|
||||
// Output detail level
|
||||
|
||||
typedef enum output_detail_level {
|
||||
MP_DETAIL_ALL,
|
||||
MP_DETAIL_NON_OK_ONLY,
|
||||
} mp_output_detail_level;
|
||||
|
||||
void mp_set_level_of_detail(mp_output_detail_level level);
|
||||
mp_output_detail_level mp_get_level_of_detail(void);
|
||||
|
||||
/*
|
||||
* The main state object of a plugin. Exists only ONCE per plugin.
|
||||
|
|
@ -48,7 +58,7 @@ typedef enum output_format {
|
|||
* in the first layer of subchecks
|
||||
*/
|
||||
typedef struct {
|
||||
char *summary; // Overall summary, if not set a summary will be automatically generated
|
||||
char *summary; // Overall summary, if not set a summary will be automatically generated
|
||||
mp_subcheck_list *subchecks;
|
||||
} mp_check;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue