From 04b27b1a237995dff459fbc489a9131a417f0325 Mon Sep 17 00:00:00 2001 From: Jonathan Michalon Date: Sat, 23 Aug 2014 16:05:39 +0200 Subject: [PATCH] New feature: different check interval for checks in error --- README.md | 2 ++ lib/__init__.py | 3 +++ lib/checks.py | 6 +++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 308405d..4f34385 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ Each check may be initialised with some options: In addition some checks have specific options, see lib/checks.py for examples. +In case you want to check lesser important services and configure very long check intervals, you may +want to have another interval, global to all checks, for error retries. This can be set with the `error_every` option. Current state output -------------------- diff --git a/lib/__init__.py b/lib/__init__.py index a5d1284..52d271d 100644 --- a/lib/__init__.py +++ b/lib/__init__.py @@ -12,6 +12,9 @@ config.install_attr('checks', Checks()) # Each check may then individually be configured to run every N * tick config.install_attr('base_tick', 60) +# How often we retry checks that are in error (-1 disables feature) +config.install_attr('error_every', -1) + # Email addresses to send to when an alert is triggered config.install_attr('emails.to', []) # The From: address diff --git a/lib/checks.py b/lib/checks.py index 47dabcc..ad07f84 100644 --- a/lib/checks.py +++ b/lib/checks.py @@ -55,7 +55,11 @@ class Check(object): pass def run(self, immediate=False): - self.every_count = (self.every_count + 1) % self.every + from . import config + self.every_count = (self.every_count + 1) % ( + self.every if self.ok or + config.error_every < 0 + else config.error_every) if self.every_count == 0 or immediate: self.setup() if not self.check(): -- GitLab