diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2021-04-07 11:12:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-07 11:12:59 +0300 |
commit | 0ca00783783ebeae2e049a0efefe0d896a2871f2 (patch) | |
tree | b14ba1f61deccace4e20680d6d62bc71e7b8670e | |
parent | f85c28edf5330260e086d71642b55d28e78470c6 (diff) |
Fix incorrect health log entries (#10822)
-rw-r--r-- | health/health_json.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/health/health_json.c b/health/health_json.c index 2a81d1c024..74a384a3b2 100644 --- a/health/health_json.c +++ b/health/health_json.c @@ -349,6 +349,18 @@ void health_alarms_values2json(RRDHOST *host, BUFFER *wb, int all) { rrdhost_unlock(host); } +static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark) +{ + ALARM_ENTRY *ae = host->health_log.alarms; + + while(ae) { + if (ae->alarm_id == alarm_id && ae->unique_id > mark && + (ae->new_status != RRDCALC_STATUS_WARNING && ae->new_status != RRDCALC_STATUS_CRITICAL)) + return 1; + ae = ae->next; + } + return 0; +} void health_active_log_alarms_2json(RRDHOST *host, BUFFER *wb) { netdata_rwlock_rdlock(&host->health_log.alarm_log_rwlock); @@ -363,6 +375,10 @@ void health_active_log_alarms_2json(RRDHOST *host, BUFFER *wb) { ((ae->new_status == RRDCALC_STATUS_WARNING || ae->new_status == RRDCALC_STATUS_CRITICAL) || ((ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL) && ae->new_status == RRDCALC_STATUS_REMOVED))) { + + if (have_recent_alarm(host, ae->alarm_id, ae->unique_id)) + continue; + if (likely(count)) buffer_strcat(wb, ","); health_alarm_entry2json_nolock(wb, ae, host); |