From edb3bdb44a35dfbdb0e3c37eb246ebe50e55a4c3 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Mon, 3 Jun 2019 12:15:38 -0700 Subject: [PATCH] Allow disabling repeated alerts --- minitor/main.py | 4 +++- sample-config.yml | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/minitor/main.py b/minitor/main.py index 24a4479..599f6d1 100644 --- a/minitor/main.py +++ b/minitor/main.py @@ -61,7 +61,6 @@ def validate_monitor_settings(settings): non_zero = ( 'check_interval', 'alert_after', - 'alert_every', ) for key in non_zero: @@ -220,6 +219,9 @@ class Monitor(object): if self.alert_every > 0: # Otherwise, we should check against our alert_every should_alert = (failure_count % self.alert_every) == 0 + elif self.alert_every == 0: + # Only alert on the first failure + should_alert = failure_count == 1 else: should_alert = (failure_count >= (2 ** self.alert_count) - 1) diff --git a/sample-config.yml b/sample-config.yml index db21997..2582c2f 100644 --- a/sample-config.yml +++ b/sample-config.yml @@ -5,9 +5,9 @@ monitors: command: [ 'curl', '-s', '-o', '/dev/null', 'https://minitor.mon' ] alert_down: [ log, mailgun_down, sms_down ] alert_up: [ log, email_up ] - check_interval: 30 + check_interval: 30 # Must be at minimum the global `check_interval` alert_after: 3 - alert_every: -1 # Defaults to -1 for exponential backoff + alert_every: -1 # Defaults to -1 for exponential backoff. 0 to disable repeating alerts: email_up: