aboutsummaryrefslogtreecommitdiff
path: root/jobs/HTTPServerChecker.py
diff options
context:
space:
mode:
authorTom <tom@ritter.vg>2016-12-28 13:59:43 -0600
committerTom Ritter <tom@ritter.vg>2016-12-28 14:37:55 -0600
commit3e85f1d0d48f0fb65a83af6ce3fb4b6a08f0bb1a (patch)
tree43367c6c5c98bf31759e576bcf43efabd4772e57 /jobs/HTTPServerChecker.py
parent50111ca74eaa5b14253814a9aa39e35b40480935 (diff)
Create an option that lets you require two failures before alerting.
Diffstat (limited to 'jobs/HTTPServerChecker.py')
-rwxr-xr-xjobs/HTTPServerChecker.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/jobs/HTTPServerChecker.py b/jobs/HTTPServerChecker.py
index 9336588..8f0e88f 100755
--- a/jobs/HTTPServerChecker.py
+++ b/jobs/HTTPServerChecker.py
@@ -8,17 +8,18 @@ import JobSpawner
class HTTPServerChecker(JobSpawner.JobSpawner):
servers = [
- #("http://example.com", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME),
- #("https://exampletwo.com", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME)
+ #("http://example.com", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME, JobBase.JobFailureCountMinimumBeforeNotification.ONE),
+ #("https://exampletwo.com", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME, JobBase.JobFailureCountMinimumBeforeNotification.ONE)
]
class ServerChecker(JobBase.JobBase):
- def __init__(self, config, url, frequency, failureNotificationFrequency):
+ def __init__(self, config, url, frequency, failureNotificationFrequency, failuresBeforeNotification):
self.config = config
self.url = url
self.frequency = frequency
self.failureNotificationFrequency = failureNotificationFrequency
- super(HTTPServerChecker.ServerChecker, self).__init__(config, url, frequency, failureNotificationFrequency)
+ self.failuresBeforeNotification = failuresBeforeNotification
+ super(HTTPServerChecker.ServerChecker, self).__init__(config, url, frequency, failureNotificationFrequency, failuresBeforeNotification)
def getName(self):
return str(self.__class__) + " for " + self.url
@@ -26,6 +27,8 @@ class HTTPServerChecker(JobSpawner.JobSpawner):
return self.frequency
def notifyOnFailureEvery(self):
return self.failureNotificationFrequency
+ def numberFailuresBeforeNotification(self):
+ return self.failuresBeforeNotification
def execute(self):
try:
i = requests.get(self.url)
@@ -44,5 +47,5 @@ class HTTPServerChecker(JobSpawner.JobSpawner):
def get_sub_jobs(self, config):
for s in self.servers:
- yield self.ServerChecker(config, s[0], s[1], s[2])
+ yield self.ServerChecker(config, s[0], s[1], s[2], s[3])