Skip to content

Commit

Permalink
Merge pull request #1610 from JamesJJ/ooh-logic-1
Browse files Browse the repository at this point in the history
Fix repeated notifications when delayed/catch-up notifications enabled
  • Loading branch information
jamesoff authored Feb 15, 2025
2 parents 2bd8c4e + 5359968 commit 407b831
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions simplemonitor/Alerters/alerter.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,18 @@ def should_alert(self, monitor: Monitor) -> AlertType:
if virtual_failure_count:
self.alerter_logger.debug("monitor %s has failed", monitor.name)
# Monitor has failed (not just first time)
if self._delay_notification:
# Delayed (catch-up) notifications are enabled
if not out_of_hours:
# Not out of hours
try:
self._ooh_failures.remove(monitor.name)
# if it was in there and we support catchup alerts, do it
if self.support_catchup:
self.alerter_logger.debug(
"alert for monitor %s is CATCHUP", monitor.name
)
return AlertType.CATCHUP
except ValueError:
pass
if self._delay_notification and not out_of_hours:
# Delayed (catch-up) notifications are enabled, and it's time to send the delayed notification
if monitor.name in self._ooh_failures:
# The monitor had failed during ooh
self._ooh_failures.remove(monitor.name)
# if we support catchup alerts, do it
if self.support_catchup:
self.alerter_logger.debug(
"alert for monitor %s is CATCHUP", monitor.name
)
return AlertType.CATCHUP
# send failure if catchup wasn't supported
self.alerter_logger.debug(
"alert for monitor %s is FAILURE", monitor.name
)
Expand Down

0 comments on commit 407b831

Please sign in to comment.