From 1b8a64725f8ebb2447d14b231625420519a663a7 Mon Sep 17 00:00:00 2001 From: Iain Learmonth Date: Fri, 17 Jun 2022 12:57:02 +0100 Subject: [PATCH] alarms: reduce state changes that trigger notifications --- app/models/alarms.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/alarms.py b/app/models/alarms.py index 9e9685f..b5657cf 100644 --- a/app/models/alarms.py +++ b/app/models/alarms.py @@ -39,7 +39,11 @@ class Alarm(db.Model): # type: ignore activity = Activity(activity_type="alarm_state", text=f"{self.alarm_state.name}->{state.name}! State changed for " f"{self.aspect} on {self.target}: {text}") - activity.notify() + if (self.alarm_state.name in ["WARNING", "CRITICAL"] + or state.name in ["WARNING", "CRITICAL", "UNKNOWN"]): + # Notifications are only sent on recovery from warning/critical state or on entry + # to warning/critical/unknown states. This should reduce alert fatigue. + activity.notify() db.session.add(activity) self.alarm_state = state self.text = text