aboutsummaryrefslogtreecommitdiff
path: root/jobs/PeerChecker.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/PeerChecker.py
Initial commit of checker
Diffstat (limited to 'jobs/PeerChecker.py')
-rwxr-xr-xjobs/PeerChecker.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/jobs/PeerChecker.py b/jobs/PeerChecker.py
new file mode 100755
index 0000000..c8cca38
--- /dev/null
+++ b/jobs/PeerChecker.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+import os
+import base64
+import datetime
+
+import imaplib
+
+import JobBase
+
+class PeerChecker(JobBase.JobBase):
+ def executeEvery(self):
+ return JobBase.JobFrequency.HOUR
+ def execute(self):
+ testSuccess = True
+ peers = self.config.items('peers')
+ for p in peers:
+ peer = p[1].split(',')
+ peerOK = False
+
+ try:
+ response = requests.get(peer[0])
+ if response.status_code != 200:
+ peerOK = False
+ subject = peer[0] + " returned a non-standard status code."
+ else:
+ if "True" in response.content:
+ peerOK = True
+ elif "False" in response.content:
+ peerOK = False
+ subject = peer[0] + " reports it cannot send email."
+ except:
+ peerOK = False
+ subject = peer[0] + " is not responding."
+
+ if not peerOK:
+ if not self.sendEmail(subject, "", peer[1]):
+ testSuccess = False
+ return testSuccess \ No newline at end of file