diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2022-04-20 14:32:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-20 14:32:59 +0300 |
commit | 6caab18c2e7c8b142b0fac3e0087cb3b67862410 (patch) | |
tree | 538898076d6206ef112e615a6607e84254a7fd54 /database | |
parent | fce09f9c899f10c5d39125c93b111b3fc4b7aaa6 (diff) |
Store alert log entries even if alert is repeating. (#12226)
* store alarm log entries even if it is repeating
* log times repeated for an alert
Diffstat (limited to 'database')
-rw-r--r-- | database/rrdcalc.c | 112 | ||||
-rw-r--r-- | database/rrdcalc.h | 1 |
2 files changed, 55 insertions, 58 deletions
diff --git a/database/rrdcalc.c b/database/rrdcalc.c index 1b1a149603..6734a11764 100644 --- a/database/rrdcalc.c +++ b/database/rrdcalc.c @@ -81,35 +81,32 @@ static void rrdsetcalc_link(RRDSET *st, RRDCALC *rc) { if(!rc->units) rc->units = strdupz(st->units); - if(!rrdcalc_isrepeating(rc)) { - time_t now = now_realtime_sec(); - ALARM_ENTRY *ae = health_create_alarm_entry( - host, - rc->id, - rc->next_event_id++, - rc->config_hash_id, - now, - rc->name, - rc->rrdset->id, - rc->rrdset->family, - rc->classification, - rc->component, - rc->type, - rc->exec, - rc->recipient, - now - rc->last_status_change, - rc->old_value, - rc->value, - rc->status, - RRDCALC_STATUS_UNINITIALIZED, - rc->source, - rc->units, - rc->info, - 0, - 0 - ); - health_alarm_log(host, ae); - } + time_t now = now_realtime_sec(); + ALARM_ENTRY *ae = health_create_alarm_entry( + host, + rc->id, + rc->next_event_id++, + rc->config_hash_id, + now, + rc->name, + rc->rrdset->id, + rc->rrdset->family, + rc->classification, + rc->component, + rc->type, + rc->exec, + rc->recipient, + now - rc->last_status_change, + rc->old_value, + rc->value, + rc->status, + RRDCALC_STATUS_UNINITIALIZED, + rc->source, + rc->units, + rc->info, + 0, + 0); + health_alarm_log(host, ae); } static inline int rrdcalc_test_additional_restriction(RRDCALC *rc, RRDSET *st){ @@ -159,35 +156,32 @@ inline void rrdsetcalc_unlink(RRDCALC *rc) { RRDHOST *host = st->rrdhost; - if(!rrdcalc_isrepeating(rc)) { - time_t now = now_realtime_sec(); - ALARM_ENTRY *ae = health_create_alarm_entry( - host, - rc->id, - rc->next_event_id++, - rc->config_hash_id, - now, - rc->name, - rc->rrdset->id, - rc->rrdset->family, - rc->classification, - rc->component, - rc->type, - rc->exec, - rc->recipient, - now - rc->last_status_change, - rc->old_value, - rc->value, - rc->status, - RRDCALC_STATUS_REMOVED, - rc->source, - rc->units, - rc->info, - 0, - 0 - ); - health_alarm_log(host, ae); - } + time_t now = now_realtime_sec(); + ALARM_ENTRY *ae = health_create_alarm_entry( + host, + rc->id, + rc->next_event_id++, + rc->config_hash_id, + now, + rc->name, + rc->rrdset->id, + rc->rrdset->family, + rc->classification, + rc->component, + rc->type, + rc->exec, + rc->recipient, + now - rc->last_status_change, + rc->old_value, + rc->value, + rc->status, + RRDCALC_STATUS_REMOVED, + rc->source, + rc->units, + rc->info, + 0, + 0); + health_alarm_log(host, ae); debug(D_HEALTH, "Health unlinking alarm '%s.%s' from chart '%s' of host '%s'", rc->chart?rc->chart:"NOCHART", rc->name, st->id, host->hostname); @@ -422,6 +416,7 @@ inline RRDCALC *rrdcalc_create_from_template(RRDHOST *host, RRDCALCTEMPLATE *rt, rc->delay_multiplier = rt->delay_multiplier; rc->last_repeat = 0; + rc->times_repeat = 0; rc->warn_repeat_every = rt->warn_repeat_every; rc->crit_repeat_every = rt->crit_repeat_every; @@ -534,6 +529,7 @@ inline RRDCALC *rrdcalc_create_from_rrdcalc(RRDCALC *rc, RRDHOST *host, const ch newrc->delay_multiplier = rc->delay_multiplier; newrc->last_repeat = 0; + newrc->times_repeat = 0; newrc->warn_repeat_every = rc->warn_repeat_every; newrc->crit_repeat_every = rc->crit_repeat_every; diff --git a/database/rrdcalc.h b/database/rrdcalc.h index d7446f63ad..2ae47788e3 100644 --- a/database/rrdcalc.h +++ b/database/rrdcalc.h @@ -121,6 +121,7 @@ struct rrdcalc { time_t next_update; // the next update timestamp of the alarm time_t last_status_change; // the timestamp of the last time this alarm changed status time_t last_repeat; // the last time the alarm got repeated + uint32_t times_repeat; // number of times the alarm got repeated time_t db_after; // the first timestamp evaluated by the db lookup time_t db_before; // the last timestamp evaluated by the db lookup |