diff --git a/README.md b/README.md index 308405df9aa804a889a33b568c84fbbdb78f089c..4f34385fcbbe66303d9f8d719e30fdcc668ec5c0 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 a5d12847744b48bdf8bc3b62099a4b5b268139d3..52d271d52599bcb63e6c55ccd9528c2fbb9da9ef 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 47dabccd757feec525b2fd0c7856df9c333fac15..ad07f84bd48f5c32b2b4a92b0fe14ddf9f4edee7 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():