diff options
author | Tom Ritter <tom@ritter.vg> | 2016-01-26 01:15:03 -0500 |
---|---|---|
committer | Tom Ritter <tom@ritter.vg> | 2016-01-26 01:15:03 -0500 |
commit | 869de79cc6483f5583b2f9bddd08720d103c8bec (patch) | |
tree | 1d548222a4b8d142ff821898df59786c24b176ae | |
parent | 19341244fb0a313a1743cbae9c3dc5cbbcd3ddb0 (diff) |
Differentiating between a mail problem and jobs not being run.
-rwxr-xr-x | jobs/PeerChecker.py | 10 | ||||
-rwxr-xr-x | servers.py | 11 | ||||
-rwxr-xr-x | statustracker.py | 10 |
3 files changed, 22 insertions, 9 deletions
diff --git a/jobs/PeerChecker.py b/jobs/PeerChecker.py index 965f4a4..f17da53 100755 --- a/jobs/PeerChecker.py +++ b/jobs/PeerChecker.py @@ -31,10 +31,18 @@ class PeerChecker(JobBase.JobBase): else:
if "True" in response.content:
peerOK = True
- elif "False" in response.content:
+ elif "MailProblem" in response.content:
peerOK = False
subject = peer[0] + " reports it cannot send email."
body = str(response.status_code) + "\n" + response.content
+ elif "JobProblem" in response.content:
+ peerOK = False
+ subject = peer[0] + " reports its jobs are not running."
+ body = str(response.status_code) + "\n" + response.content
+ else:
+ peerOK = False
+ subject = peer[0] + " had an unexpected response."
+ body = str(response.status_code) + "\n" + response.content
except Exception as e:
peerOK = False
subject = peer[0] + " is not responding."
@@ -11,12 +11,15 @@ class StatusSite(resource.Resource): resource.Resource.__init__(self) self.statusTracker = statusTracker def render_GET(self, request): - if self.statusTracker.isAllGood(): + if self.statusTracker.isMailGood() and self.statusTracker.isJobsGood(): logging.debug("Indicating that everything seems to be okay") s = "True" - else: - logging.warn("Indicating that everything does not seem to be okay") - s = "False" + elif not self.statusTracker.isMailGood(): + logging.warn("Indicating that we have a problem with Mail") + s = "MailProblem" + elif not self.statusTracker.isJobsGood(): + logging.warn("Indicating that we have a problem with Jobs") + s = "JobProblem" request.setResponseCode(200) return s diff --git a/statustracker.py b/statustracker.py index 2c3350c..d092266 100755 --- a/statustracker.py +++ b/statustracker.py @@ -11,12 +11,14 @@ class StatusTracker: self.lastRunJob = 0 self.config = config - def isAllGood(self): - return self.emailNotificationsAreWorking and \ - time.time() - self.lastRunJob < 120 + def isMailGood(self): + return self.emailNotificationsAreWorking + + def isJobsGood(self): + return time.time() - self.lastRunJob < 120 def markJobRan(self): self.lastRunJob = time.time() def markEmailStatus(self, working): - self.emailNotificationsAreWorking = working
\ No newline at end of file + self.emailNotificationsAreWorking = working |