allow notifications with option no-clear-notification to re-send the same notification
Costa Tsaousis (ktsaou) committed
Jan 27, 2017 at 02:59 UTC
7a9f30fb109a3d86bf0fccb8f7cf9a14dd3728f9
1 file changed
+8
-2
src/health.c
+8
-2
@@ -1786,6 +1786,8 @@ static inline uint32_t health_parse_options(const char *s) {
1786
1787
if(!strcasecmp(buf, "no-clear-notification") || !strcasecmp(buf, "no-clear"))
1788
options |= RRDCALC_FLAG_NO_CLEAR_NOTIFICATION;
1789
+ else
1790
+ error("Ignoring unknown alarm option '%s'", buf);
1791
}
1792
}
1793
@@ -2729,17 +2731,21 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
2731
2732
if(unlikely(ae->new_status < RRDCALC_STATUS_CLEAR)) {
2733
// do not send notifications for internal statuses
2734
+ debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (internal statuses)", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2735
goto done;
2736
}
2737
2735
- if(unlikely(ae->new_status <= RRDCALC_STATUS_CLEAR && ae->flags & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION)) {
2738
+ if(unlikely(ae->new_status <= RRDCALC_STATUS_CLEAR && (ae->flags & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION))) {
2739
// do not send notifications for disabled statuses
2740
+ debug(D_HEALTH, "Health not sending notification for alarm '%s.%s' status %s (it has no-clear-notification enabled)", ae->chart, ae->name, rrdcalc_status2string(ae->new_status));
2741
+ // mark it as run, so that we will send the same alarm if it happens again
2742
goto done;
2743
}
2744
2745
// find the previous notification for the same alarm
2746
// which we have run the exec script
2742
- {
2747
+ // exception: alarms with HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION set
2748
+ if(likely(!(ae->flags & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION))) {
2749
uint32_t id = ae->alarm_id;
2750
ALARM_ENTRY *t;
2751
for(t = ae->next; t ; t = t->next) {