diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2023-09-19 15:35:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 15:35:44 +0300 |
commit | 9f0fbff5b8d014235b44d4460291d56128855f1d (patch) | |
tree | e791cdf9841e0121e50798183fff8c7519f05cbc /health/health.c | |
parent | f07a55346a888fe4928522b6ae5381cde14667b6 (diff) |
Add a summary field to alerts (#15886)
* add a summary field to alerts
* add summary field to db
* rebase
* better migration
* rebase
* change email notification
* revert to silent
* use macro
* add the summary field to some alerts
* add more summary fields
* change migration function
* add to postgres alerts
* add summary to vernemq
* more summary fields
* more summary fields
* fixes
* add doc
Diffstat (limited to 'health/health.c')
-rw-r--r-- | health/health.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/health/health.c b/health/health.c index 2fe6836b16..0194bf589e 100644 --- a/health/health.c +++ b/health/health.c @@ -82,7 +82,8 @@ static bool prepare_command(BUFFER *wb, const char *classification, const char *edit_command, const char *machine_guid, - uuid_t *transition_id + uuid_t *transition_id, + const char *summary ) { char buf[8192]; size_t n = 8192 - 1; @@ -195,6 +196,10 @@ static bool prepare_command(BUFFER *wb, return false; buffer_sprintf(wb, " '%s'", buf); + if (!sanitize_command_argument_string(buf, summary, n)) + return false; + buffer_sprintf(wb, " '%s'", buf); + return true; } @@ -581,7 +586,8 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) { ae->classification?ae_classification(ae):"Unknown", edit_command, host->machine_guid, - &ae->transition_id); + &ae->transition_id, + host->health.use_summary_for_notifications && ae->summary?ae_summary(ae):ae_name(ae)); const char *command_to_run = buffer_tostring(wb); if (ok) { @@ -835,6 +841,7 @@ static void initialize_health(RRDHOST *host) snprintfz(filename, FILENAME_MAX, "%s/alarm-notify.sh", netdata_configured_primary_plugins_dir); host->health.health_default_exec = string_strdupz(config_get(CONFIG_SECTION_HEALTH, "script to execute on alarm", filename)); host->health.health_default_recipient = string_strdupz("root"); + host->health.use_summary_for_notifications = config_get_boolean(CONFIG_SECTION_HEALTH, "use summary for notifications", CONFIG_BOOLEAN_YES); sql_health_alarm_log_load(host); @@ -1157,6 +1164,7 @@ void *health_main(void *ptr) { RRDCALC_STATUS_REMOVED, rc->source, rc->units, + rc->summary, rc->info, 0, rrdcalc_isrepeating(rc)?HEALTH_ENTRY_FLAG_IS_REPEATING:0); @@ -1424,6 +1432,7 @@ void *health_main(void *ptr) { status, rc->source, rc->units, + rc->summary, rc->info, rc->delay_last, ( @@ -1511,6 +1520,7 @@ void *health_main(void *ptr) { rc->status, rc->source, rc->units, + rc->summary, rc->info, rc->delay_last, ( |