@cryptotaxi247 / netdata-1 / commits / 0ca007837

Fix incorrect health log entries (#10822)

Stelios Fragkakis committed Apr 7, 2021 at 11:12 UTC 0ca00783783ebeae2e049a0efefe0d896a2871f2
1 file changed +16
health/health_json.c
+16
@@ -349,6 +349,18 @@ void health_alarms_values2json(RRDHOST *host, BUFFER *wb, int all) {
349 rrdhost_unlock(host);
350 }
351
352 +static int have_recent_alarm(RRDHOST *host, uint32_t alarm_id, time_t mark)
353 +{
354 + ALARM_ENTRY *ae = host->health_log.alarms;
355 +
356 + while(ae) {
357 + if (ae->alarm_id == alarm_id && ae->unique_id > mark &&
358 + (ae->new_status != RRDCALC_STATUS_WARNING && ae->new_status != RRDCALC_STATUS_CRITICAL))
359 + return 1;
360 + ae = ae->next;
361 + }
362 + return 0;
363 +}
364
365 void health_active_log_alarms_2json(RRDHOST *host, BUFFER *wb) {
366 netdata_rwlock_rdlock(&host->health_log.alarm_log_rwlock);
@@ -363,6 +375,10 @@ void health_active_log_alarms_2json(RRDHOST *host, BUFFER *wb) {
375 ((ae->new_status == RRDCALC_STATUS_WARNING || ae->new_status == RRDCALC_STATUS_CRITICAL) ||
376 ((ae->old_status == RRDCALC_STATUS_WARNING || ae->old_status == RRDCALC_STATUS_CRITICAL) &&
377 ae->new_status == RRDCALC_STATUS_REMOVED))) {
378 +
379 + if (have_recent_alarm(host, ae->alarm_id, ae->unique_id))
380 + continue;
381 +
382 if (likely(count))
383 buffer_strcat(wb, ",");
384 health_alarm_entry2json_nolock(wb, ae, host);