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 /health | |
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 'health')
-rw-r--r-- | health/health.c | 27 | ||||
-rw-r--r-- | health/health_json.c | 2 | ||||
-rw-r--r-- | health/health_log.c | 4 |
3 files changed, 16 insertions, 17 deletions
diff --git a/health/health.c b/health/health.c index 528238d749..5ac88fec71 100644 --- a/health/health.c +++ b/health/health.c @@ -1041,19 +1041,19 @@ void *health_main(void *ptr) { rc->delay_last = delay; rc->delay_up_to_timestamp = now + delay; - if(likely(!rrdcalc_isrepeating(rc))) { - 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, status, rc->source, rc->units, rc->info, - rc->delay_last, - ( - ((rc->options & RRDCALC_FLAG_NO_CLEAR_NOTIFICATION)? HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION : 0) | - ((rc->rrdcalc_flags & RRDCALC_FLAG_SILENCED)? HEALTH_ENTRY_FLAG_SILENCED : 0) - ) - ); - health_alarm_log(host, ae); - } + + 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, status, rc->source, rc->units, rc->info, + rc->delay_last, + ( + ((rc->options & RRDCALC_FLAG_NO_CLEAR_NOTIFICATION)? HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION : 0) | + ((rc->rrdcalc_flags & RRDCALC_FLAG_SILENCED)? HEALTH_ENTRY_FLAG_SILENCED : 0) + ) + ); + health_alarm_log(host, ae); + rc->last_status_change = now; rc->old_status = rc->status; rc->status = status; @@ -1092,6 +1092,7 @@ void *health_main(void *ptr) { if(unlikely(repeat_every > 0 && (rc->last_repeat + repeat_every) <= now)) { rc->last_repeat = now; + if (likely(rc->times_repeat < UINT32_MAX)) rc->times_repeat++; 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, diff --git a/health/health_json.c b/health/health_json.c index be95100bc2..56318472b7 100644 --- a/health/health_json.c +++ b/health/health_json.c @@ -227,6 +227,7 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC "\t\t\t\"crit_repeat_every\": \"%u\",\n" "\t\t\t\"value_string\": \"%s\",\n" "\t\t\t\"last_repeat\": \"%lu\",\n" + "\t\t\t\"times_repeat\": %lu,\n" , rc->chart, rc->name , (unsigned long)rc->id , hash_id @@ -259,6 +260,7 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC , rc->crit_repeat_every , value_string , (unsigned long)rc->last_repeat + , (unsigned long)rc->times_repeat ); if(unlikely(rc->options & RRDCALC_FLAG_NO_CLEAR_NOTIFICATION)) { diff --git a/health/health_log.c b/health/health_log.c index 6d63966c78..4959aa179a 100644 --- a/health/health_log.c +++ b/health/health_log.c @@ -560,10 +560,6 @@ inline void health_alarm_log( ) { debug(D_HEALTH, "Health adding alarm log entry with id: %u", ae->unique_id); - if(unlikely(alarm_entry_isrepeating(host, ae))) { - error("Repeating alarms cannot be added to host's alarm log entries. It seems somewhere in the logic, API is being misused. Alarm id: %u", ae->alarm_id); - return; - } // link it netdata_rwlock_wrlock(&host->health_log.alarm_log_rwlock); ae->next = host->health_log.alarms; |