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 /database/rrdcalc.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 'database/rrdcalc.c')
-rw-r--r-- | database/rrdcalc.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/database/rrdcalc.c b/database/rrdcalc.c index 2360df00f4..448ab23fbb 100644 --- a/database/rrdcalc.c +++ b/database/rrdcalc.c @@ -98,7 +98,7 @@ uint32_t rrdcalc_get_unique_id(RRDHOST *host, STRING *chart, STRING *name, uint3 } // ---------------------------------------------------------------------------- -// RRDCALC replacing info text variables with RRDSET labels +// RRDCALC replacing info/summary text variables with RRDSET labels static STRING *rrdcalc_replace_variables_with_rrdset_labels(const char *line, RRDCALC *rc) { if (!line || !*line) @@ -158,9 +158,17 @@ void rrdcalc_update_info_using_rrdset_labels(RRDCALC *rc) { size_t labels_version = rrdlabels_version(rc->rrdset->rrdlabels); if(rc->labels_version != labels_version) { - STRING *old = rc->info; - rc->info = rrdcalc_replace_variables_with_rrdset_labels(rrdcalc_original_info(rc), rc); - string_freez(old); + if (rc->original_info) { + STRING *old = rc->info; + rc->info = rrdcalc_replace_variables_with_rrdset_labels(rrdcalc_original_info(rc), rc); + string_freez(old); + } + + if (rc->original_summary) { + STRING *old = rc->summary; + rc->summary = rrdcalc_replace_variables_with_rrdset_labels(rrdcalc_original_summary(rc), rc); + string_freez(old); + } rc->labels_version = labels_version; } @@ -285,6 +293,11 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) { rrdcalc_update_info_using_rrdset_labels(rc); + if(!rc->summary) { + rc->summary = string_dup(rc->name); + rc->original_summary = string_dup(rc->name); + } + time_t now = now_realtime_sec(); ALARM_ENTRY *ae = health_create_alarm_entry( @@ -310,6 +323,7 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) { rc->status, rc->source, rc->units, + rc->summary, rc->info, 0, rrdcalc_isrepeating(rc)?HEALTH_ENTRY_FLAG_IS_REPEATING:0); @@ -356,6 +370,7 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) { RRDCALC_STATUS_REMOVED, rc->source, rc->units, + rc->summary, rc->info, 0, 0); @@ -512,6 +527,11 @@ static void rrdcalc_rrdhost_insert_callback(const DICTIONARY_ITEM *item __maybe_ rc->info = string_dup(rt->info); rc->original_info = string_dup(rt->info); + if (!rt->summary) + rt->summary = string_dup(rc->name); + rc->summary = string_dup(rt->summary); + rc->original_summary = string_dup(rt->summary); + rc->classification = string_dup(rt->classification); rc->component = string_dup(rt->component); rc->type = string_dup(rt->type); |