diff options
author | Tom Ritter <tom@ritter.vg> | 2016-01-31 13:22:08 -0600 |
---|---|---|
committer | Tom Ritter <tom@ritter.vg> | 2016-01-31 13:22:08 -0600 |
commit | 3bea3bae59e7404b286b5bf97a6270270bfadd6c (patch) | |
tree | c9d1d7cf76681420587198d09abda761912c47c4 /samplejobs | |
parent | 1a8b46d940d3a4bc06700d15307191bb10008ea6 (diff) |
Refactor lots of things to allow you to be notified every so often, instead of every single time.
Diffstat (limited to 'samplejobs')
-rwxr-xr-x | samplejobs/BWAuthChecker.py | 7 | ||||
-rwxr-xr-x | samplejobs/MetricsChecker.py | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/samplejobs/BWAuthChecker.py b/samplejobs/BWAuthChecker.py index 9116857..2b88e95 100755 --- a/samplejobs/BWAuthChecker.py +++ b/samplejobs/BWAuthChecker.py @@ -13,6 +13,8 @@ import JobBase class BWAuthChecker(JobBase.JobBase): def executeEvery(self): return JobBase.JobFrequency.HOUR + def notifyOnFailureEvery(self): + return JobBase.JobFailureNotificationFrequency.EVERYTIME def execute(self): body = "" url = "https://example.com/bwauth/bwscan.V3BandwidthsFile" @@ -34,6 +36,9 @@ class BWAuthChecker(JobBase.JobBase): if body: logging.warn("tor bwauth is broken?") logging.warn(body) - return self.sendEmail("tor bwauth is broken?", body) + self.logdetails = body + return False else: return True + def onFailure(self): + return self.sendEmail("tor bwauth is broken?", self.logdetails) diff --git a/samplejobs/MetricsChecker.py b/samplejobs/MetricsChecker.py index d46c7d3..1d29a81 100755 --- a/samplejobs/MetricsChecker.py +++ b/samplejobs/MetricsChecker.py @@ -12,6 +12,8 @@ import JobBase class MetricsChecker(JobBase.JobBase): def executeEvery(self): return JobBase.JobFrequency.DAY_NOON + def notifyOnFailureEvery(self): + return JobBase.JobFailureNotificationFrequency.EVERYTIME def execute(self): body = "" ys = datetime.date.today() - datetime.timedelta(hours=24) @@ -27,6 +29,9 @@ class MetricsChecker(JobBase.JobBase): if body: logging.warn("tor metrics is broken?") logging.warn(body) - return self.sendEmail("tor metrics is broken?", body) + self.logdetails = body + return False else: return True + def onFailure(self): + return self.sendEmail("tor metrics is broken?", self.logdetails) |