aboutsummaryrefslogtreecommitdiff
path: root/jobs/HTTPServerChecker.py
diff options
context:
space:
mode:
authorTom Ritter <tom@ritter.vg>2016-01-25 21:24:41 -0500
committerTom Ritter <tom@ritter.vg>2016-01-25 21:24:41 -0500
commit9b25f65ca655a567873c66c2b015884a3e013276 (patch)
tree242b994394ebbbcfdcc72eba6241f4ea03cf921c /jobs/HTTPServerChecker.py
Initial commit of checker
Diffstat (limited to 'jobs/HTTPServerChecker.py')
-rwxr-xr-xjobs/HTTPServerChecker.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/jobs/HTTPServerChecker.py b/jobs/HTTPServerChecker.py
new file mode 100755
index 0000000..ec8eda1
--- /dev/null
+++ b/jobs/HTTPServerChecker.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python
+
+import logging
+import requests
+
+import JobBase
+import JobSpawner
+
+class HTTPServerChecker(JobSpawner.JobSpawner):
+ servers = [
+ #("http://example.com", JobBase.JobFrequency.MINUTE),
+ #("https://exampletwo.com", JobBase.JobFrequency.MINUTE)
+ ]
+
+ class ServerChecker(JobBase.JobBase):
+ def __init__(self, url, frequency):
+ self.url = url
+ self.frequency = frequency
+
+ def getName(self):
+ return str(self.__class__) + " for " + self.url
+ def executeEvery(self):
+ return self.frequency
+ def execute(self):
+ try:
+ requests.get(self.url)
+ return True
+ except:
+ msg = "Could not hit server " + self.url
+ logging.warn(msg)
+ return self.sendEmail(msg, "")
+
+ def get_sub_jobs(self):
+ for s in self.servers:
+ yield self.ServerChecker(s[0], s[1])
+