aboutsummaryrefslogtreecommitdiff
path: root/jobs/PeerChecker.py
diff options
context:
space:
mode:
authorTom Ritter <tom@ritter.vg>2020-09-07 23:52:47 -0400
committerTom Ritter <tom@ritter.vg>2020-09-07 23:52:47 -0400
commit4671e0dec5eab28941e598f109dbf77ed551a707 (patch)
treec1e32edde4d0dceda1df8e79df67ae99f13d2bcb /jobs/PeerChecker.py
parentee3eea047c10d0032efc5a8b98d9bbdb54fe0a3a (diff)
Correct line endings
Diffstat (limited to 'jobs/PeerChecker.py')
-rwxr-xr-xjobs/PeerChecker.py140
1 files changed, 70 insertions, 70 deletions
diff --git a/jobs/PeerChecker.py b/jobs/PeerChecker.py
index 7832b25..77df4ce 100755
--- a/jobs/PeerChecker.py
+++ b/jobs/PeerChecker.py
@@ -1,70 +1,70 @@
-#!/usr/bin/env python
-
-import os
-import base64
-import datetime
-
-import imaplib
-import requests
-
-import JobBase
-import JobSpawner
-
-class PeerChecker(JobSpawner.JobSpawner):
- class IndividualPeerChecker(JobBase.JobBase):
- def __init__(self, config, checkurl, notificationAddress):
- self.checkurl = checkurl
- self.notificationAddress = notificationAddress
- super(PeerChecker.IndividualPeerChecker, self).__init__(config, checkurl, notificationAddress)
-
- def getName(self):
- return str(self.__class__) + " for " + self.checkurl
- def executeEvery(self):
- return JobBase.JobFrequency.HOUR
- def notifyOnFailureEvery(self):
- return JobBase.JobFailureNotificationFrequency.EVERYTIME
- def numberFailuresBeforeNotification(self):
- return JobBase.JobFailureCountMinimumBeforeNotification.ONE
- def execute(self):
- peerOK = False
-
- self.subject = ""
- self.body = ""
-
- try:
- response = requests.get(self.checkurl)
- if response.status_code != 200:
- peerOK = False
- self.subject = self.checkurl + " returned a non-standard status code."
- self.body = str(response.status_code) + "\n" + response.content
- else:
- if "True" in response.content:
- peerOK = True
- elif "MailProblem" in response.content:
- peerOK = False
- self.subject = self.checkurl + " reports it cannot send email."
- self.body = str(response.status_code) + "\n" + response.content
- elif "JobProblem" in response.content:
- peerOK = False
- self.subject = self.checkurl + " reports its jobs are not running."
- self.body = str(response.status_code) + "\n" + response.content
- else:
- peerOK = False
- self.subject = self.checkurl + " had an unexpected response."
- self.body = str(response.status_code) + "\n" + response.content
- except Exception as e:
- peerOK = False
- self.subject = self.checkurl + " is not responding."
- self.body = str(e)
- return peerOK
-
- def onFailure(self):
- return self.sendEmail(self.subject, self.body, self.notificationAddress)
- def onStateChangeSuccess(self):
- return self.sendEmail("Successfully hit " + self.checkurl, "", self.notificationAddress)
-
- def get_sub_jobs(self, config):
- peers = config.items('peers')
- for p in peers:
- (address, email) = p[1].split(',')
- yield self.IndividualPeerChecker(config, address, email)
+#!/usr/bin/env python
+
+import os
+import base64
+import datetime
+
+import imaplib
+import requests
+
+import JobBase
+import JobSpawner
+
+class PeerChecker(JobSpawner.JobSpawner):
+ class IndividualPeerChecker(JobBase.JobBase):
+ def __init__(self, config, checkurl, notificationAddress):
+ self.checkurl = checkurl
+ self.notificationAddress = notificationAddress
+ super(PeerChecker.IndividualPeerChecker, self).__init__(config, checkurl, notificationAddress)
+
+ def getName(self):
+ return str(self.__class__) + " for " + self.checkurl
+ def executeEvery(self):
+ return JobBase.JobFrequency.HOUR
+ def notifyOnFailureEvery(self):
+ return JobBase.JobFailureNotificationFrequency.EVERYTIME
+ def numberFailuresBeforeNotification(self):
+ return JobBase.JobFailureCountMinimumBeforeNotification.ONE
+ def execute(self):
+ peerOK = False
+
+ self.subject = ""
+ self.body = ""
+
+ try:
+ response = requests.get(self.checkurl)
+ if response.status_code != 200:
+ peerOK = False
+ self.subject = self.checkurl + " returned a non-standard status code."
+ self.body = str(response.status_code) + "\n" + response.content
+ else:
+ if "True" in response.content:
+ peerOK = True
+ elif "MailProblem" in response.content:
+ peerOK = False
+ self.subject = self.checkurl + " reports it cannot send email."
+ self.body = str(response.status_code) + "\n" + response.content
+ elif "JobProblem" in response.content:
+ peerOK = False
+ self.subject = self.checkurl + " reports its jobs are not running."
+ self.body = str(response.status_code) + "\n" + response.content
+ else:
+ peerOK = False
+ self.subject = self.checkurl + " had an unexpected response."
+ self.body = str(response.status_code) + "\n" + response.content
+ except Exception as e:
+ peerOK = False
+ self.subject = self.checkurl + " is not responding."
+ self.body = str(e)
+ return peerOK
+
+ def onFailure(self):
+ return self.sendEmail(self.subject, self.body, self.notificationAddress)
+ def onStateChangeSuccess(self):
+ return self.sendEmail("Successfully hit " + self.checkurl, "", self.notificationAddress)
+
+ def get_sub_jobs(self, config):
+ peers = config.items('peers')
+ for p in peers:
+ (address, email) = p[1].split(',')
+ yield self.IndividualPeerChecker(config, address, email)