fix decision making for sending alarms; to avoid attempting to send alarms for internal statuses and preventing duplicate alarm dispatch
Costa Tsaousis committed
Oct 17, 2016 at 11:16 UTC
e52971e69ac63cd88b3ec86d87ad773e3b2d66d9
1 file changed
+20
-9
src/health.c
+20
-9
@@ -2395,23 +2395,34 @@ static inline int rrdcalc_value2status(calculated_number n) {
2395
static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
2396
ae->flags |= HEALTH_ENTRY_FLAG_PROCESSED;
2397
2398
+ if(unlikely(ae->new_status < RRDCALC_STATUS_CLEAR)) {
2399
+ // do not send notifications for internal statuses
2400
+ goto done;
2401
+ }
2402
+
2403
// find the previous notification for the same alarm
2404
+ // which we have run the exec script
2405
ALARM_ENTRY *t;
2406
for(t = ae->next; t ;t = t->next) {
2407
if(t->alarm_id == ae->alarm_id && t->flags & HEALTH_ENTRY_FLAG_EXEC_RUN)
2408
break;
2409
}
2410
2405
- if(t && t->new_status == ae->new_status) {
2406
- // don't send the same notification again
2407
- info("Health not sending again notification for alarm '%s.%s' status %s", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2408
- goto done;
2411
+ if(likely(t)) {
2412
+ // we have executed this alarm notification in the past
2413
+ if (t && t->new_status == ae->new_status) {
2414
+ // don't send the same notification again
2415
+ info("Health not sending again notification for alarm '%s.%s' status %s", ae->chart, ae->name,
2416
+ rrdcalc_status2string(ae->new_status));
2417
+ goto done;
2418
+ }
2419
}
2410
-
2411
- if((ae->old_status == RRDCALC_STATUS_UNDEFINED && ae->new_status == RRDCALC_STATUS_UNINITIALIZED)
2412
- || (ae->old_status == RRDCALC_STATUS_UNINITIALIZED && ae->new_status == RRDCALC_STATUS_CLEAR)) {
2413
- info("Health not sending notification for first initialization of alarm '%s.%s' status %s", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2414
- goto done;
2420
+ else {
2421
+ // we have not executed this alarm notification in the past
2422
+ if(unlikely(ae->old_status == RRDCALC_STATUS_UNINITIALIZED && ae->new_status == RRDCALC_STATUS_CLEAR)) {
2423
+ info("Health not sending notification for first initialization of alarm '%s.%s' status %s", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2424
+ goto done;
2425
+ }
2426
}
2427
2428
char buffer[FILENAME_MAX + 1];