Browse Source

Don't create a REMOVED alert event after a REMOVED. (#13871)

dont create REMOVED after a REMOVED
Emmanuel Vasilakis 2 years ago
parent
commit
d7346bcfe4
1 changed files with 29 additions and 27 deletions
  1. 29 27
      database/rrdcalc.c

+ 29 - 27
database/rrdcalc.c

@@ -289,33 +289,35 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
 
     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->context,
-        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_add_entry(host, ae);
+    if (likely(rc->status != RRDCALC_STATUS_REMOVED)) {
+        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->context,
+            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_add_entry(host, ae);
+    }
 
     debug(D_HEALTH, "Health unlinking alarm '%s.%s' from chart '%s' of host '%s'", rrdcalc_chart_name(rc), rrdcalc_name(rc), rrdset_id(st), rrdhost_hostname(host));