do not allow reasing and falling notification delays to interact; do not send notifications for cancelled events due to notification delays
Costa Tsaousis committed
Sep 14, 2016 at 19:15 UTC
dd0773e2d7e2b4db1c3d44ceb3ede12171c3e62b
1 file changed
+20
-5
src/health.c
+20
-5
@@ -1836,7 +1836,7 @@ static inline void health_rrdcalc2json_nolock(BUFFER *wb, RRDCALC *rc) {
1836
, rc->delay_max_duration
1837
, rc->delay_multiplier
1838
, rc->delay_last
1839
- , rc->delay_up_to_timestamp
1839
+ , (unsigned long)rc->delay_up_to_timestamp
1840
);
1841
1842
if(RRDCALC_HAS_DB_LOOKUP(rc)) {
@@ -1998,8 +1998,23 @@ static inline int rrdcalc_value2status(calculated_number n) {
1998
static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
1999
ae->notifications |= HEALTH_ENTRY_NOTIFICATIONS_PROCESSED;
2000
2001
- if(ae->old_status == RRDCALC_STATUS_UNINITIALIZED && ae->new_status == RRDCALC_STATUS_CLEAR)
2001
+ // find the previous notification for the same alarm
2002
+ ALARM_ENTRY *t;
2003
+ for(t = ae->next; t ;t = t->next) {
2004
+ if(t->alarm_id == ae->alarm_id && t->notifications & HEALTH_ENTRY_NOTIFICATIONS_PROCESSED)
2005
+ break;
2006
+ }
2007
+
2008
+ if(t && t->new_status == ae->new_status) {
2009
+ // don't send the same notification again
2010
+ info("Health not sending again notification for alarm '%s.%s' status %s", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2011
return;
2012
+ }
2013
+
2014
+ if(ae->old_status == RRDCALC_STATUS_UNINITIALIZED && ae->new_status == RRDCALC_STATUS_CLEAR) {
2015
+ info("Health not sending notification for first initialization of alarm '%s.%s' status %s", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2016
+ return;
2017
+ }
2018
2019
char buffer[FILENAME_MAX + 1];
2020
pid_t command_pid;
@@ -2044,7 +2059,6 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
2059
debug(D_HEALTH, "HEALTH reading from command");
2060
char *s = fgets(buffer, FILENAME_MAX, fp);
2061
(void)s;
2047
- debug(D_HEALTH, "HEALTH closing command");
2062
ae->exec_code = mypclose(fp, command_pid);
2063
debug(D_HEALTH, "done executing command - returned with code %d", ae->exec_code);
2064
@@ -2413,8 +2427,9 @@ void *health_main(void *ptr) {
2427
else
2428
delay = rc->delay_down_current;
2429
2416
- if(now + delay < rc->delay_up_to_timestamp)
2417
- delay = rc->delay_up_to_timestamp - now;
2430
+ // COMMENTED: because we do need to send raising alarms
2431
+ // if(now + delay < rc->delay_up_to_timestamp)
2432
+ // delay = (int)(rc->delay_up_to_timestamp - now);
2433
2434
rc->delay_last = delay;
2435
rc->delay_up_to_timestamp = now + delay;