aboutsummaryrefslogtreecommitdiff
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
parentee3eea047c10d0032efc5a8b98d9bbdb54fe0a3a (diff)
Correct line endings
-rwxr-xr-xjobs/HTTPServerChecker.py102
-rwxr-xr-xjobs/PeerChecker.py140
-rwxr-xr-xjobs/TCPServerChecker.py108
3 files changed, 175 insertions, 175 deletions
diff --git a/jobs/HTTPServerChecker.py b/jobs/HTTPServerChecker.py
index 621e7b8..df96c1e 100755
--- a/jobs/HTTPServerChecker.py
+++ b/jobs/HTTPServerChecker.py
@@ -1,51 +1,51 @@
-#!/usr/bin/env python
-
-import logging
-import requests
-
-import JobBase
-import JobSpawner
-
-class HTTPServerChecker(JobSpawner.JobSpawner):
- servers = [
- #("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, failuresBeforeNotification):
- self.config = config
- self.url = url
- self.frequency = frequency
- self.failureNotificationFrequency = failureNotificationFrequency
- self.failuresBeforeNotification = failuresBeforeNotification
- super(HTTPServerChecker.ServerChecker, self).__init__(config, url)
-
- def getName(self):
- return str(self.__class__) + " for " + self.url
- def executeEvery(self):
- return self.frequency
- def notifyOnFailureEvery(self):
- return self.failureNotificationFrequency
- def numberFailuresBeforeNotification(self):
- return self.failuresBeforeNotification
- def execute(self):
- try:
- i = requests.get(self.url)
- if i.status_code != 200:
- self.failuremsg = "Error hitting server " + self.url + " (Code: " + str(i.status_code) + ")"
- else:
- return True
- except:
- self.failuremsg = "Could not hit server " + self.url
- logging.warn(self.failuremsg)
- return False
- def onFailure(self):
- return self.sendEmail(self.failuremsg, "")
- def onStateChangeSuccess(self):
- return self.sendEmail("Successfully hit " + self.url, "")
-
- def get_sub_jobs(self, config):
- for s in self.servers:
- yield self.ServerChecker(config, s[0], s[1], s[2], s[3])
-
+#!/usr/bin/env python
+
+import logging
+import requests
+
+import JobBase
+import JobSpawner
+
+class HTTPServerChecker(JobSpawner.JobSpawner):
+ servers = [
+ #("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, failuresBeforeNotification):
+ self.config = config
+ self.url = url
+ self.frequency = frequency
+ self.failureNotificationFrequency = failureNotificationFrequency
+ self.failuresBeforeNotification = failuresBeforeNotification
+ super(HTTPServerChecker.ServerChecker, self).__init__(config, url)
+
+ def getName(self):
+ return str(self.__class__) + " for " + self.url
+ def executeEvery(self):
+ return self.frequency
+ def notifyOnFailureEvery(self):
+ return self.failureNotificationFrequency
+ def numberFailuresBeforeNotification(self):
+ return self.failuresBeforeNotification
+ def execute(self):
+ try:
+ i = requests.get(self.url)
+ if i.status_code != 200:
+ self.failuremsg = "Error hitting server " + self.url + " (Code: " + str(i.status_code) + ")"
+ else:
+ return True
+ except:
+ self.failuremsg = "Could not hit server " + self.url
+ logging.warn(self.failuremsg)
+ return False
+ def onFailure(self):
+ return self.sendEmail(self.failuremsg, "")
+ def onStateChangeSuccess(self):
+ return self.sendEmail("Successfully hit " + self.url, "")
+
+ def get_sub_jobs(self, config):
+ for s in self.servers:
+ yield self.ServerChecker(config, s[0], s[1], s[2], s[3])
+
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)
diff --git a/jobs/TCPServerChecker.py b/jobs/TCPServerChecker.py
index 7daf7f5..6098977 100755
--- a/jobs/TCPServerChecker.py
+++ b/jobs/TCPServerChecker.py
@@ -1,54 +1,54 @@
-#!/usr/bin/env python
-
-import os
-import socket
-import logging
-
-import JobBase
-import JobSpawner
-
-class TCPServerChecker(JobSpawner.JobSpawner):
- servers = [
- #("example.com", 53, "example.com:tcpdns", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME, JobBase.JobFailureCountMinimumBeforeNotification.ONE)
- ]
-
- class ServerChecker(JobBase.JobBase):
- def __init__(self, config, ip, port, friendlyName, frequency, failureNotificationFrequency, failuresBeforeNotification):
- self.config = config
- self.ip = ip
- self.port = port
- self.friendlyName = friendlyName + "(" + self.ip + ":" + str(self.port) + ")"
- self.frequency = frequency
- self.failureNotificationFrequency = failureNotificationFrequency
- self.failuresBeforeNotification = failuresBeforeNotification
- super(TCPServerChecker.ServerChecker, self).__init__(config, ip, port)
-
- def getName(self):
- return str(self.__class__) + " for " + self.friendlyName
- def executeEvery(self):
- return self.frequency
- def notifyOnFailureEvery(self):
- return self.failureNotificationFrequency
- def numberFailuresBeforeNotification(self):
- return self.failuresBeforeNotification
- def execute(self):
- try:
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.settimeout(10)
- s.connect((self.ip, self.port))
- s.close()
- return True
- except:
- self.failuremsg = "Could not hit server " + self.friendlyName
- logging.warn(self.failuremsg)
- return False
- def onFailure(self):
- return self.sendEmail(self.failuremsg, "")
- def onStateChangeSuccess(self):
- return self.sendEmail("Successfully hit " + self.friendlyName, "")
-
- def get_sub_jobs(self, config):
- for s in self.servers:
- yield self.ServerChecker(config, s[0], s[1], s[2], s[3], s[4], s[5])
-
-
+#!/usr/bin/env python
+
+import os
+import socket
+import logging
+
+import JobBase
+import JobSpawner
+
+class TCPServerChecker(JobSpawner.JobSpawner):
+ servers = [
+ #("example.com", 53, "example.com:tcpdns", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME, JobBase.JobFailureCountMinimumBeforeNotification.ONE)
+ ]
+
+ class ServerChecker(JobBase.JobBase):
+ def __init__(self, config, ip, port, friendlyName, frequency, failureNotificationFrequency, failuresBeforeNotification):
+ self.config = config
+ self.ip = ip
+ self.port = port
+ self.friendlyName = friendlyName + "(" + self.ip + ":" + str(self.port) + ")"
+ self.frequency = frequency
+ self.failureNotificationFrequency = failureNotificationFrequency
+ self.failuresBeforeNotification = failuresBeforeNotification
+ super(TCPServerChecker.ServerChecker, self).__init__(config, ip, port)
+
+ def getName(self):
+ return str(self.__class__) + " for " + self.friendlyName
+ def executeEvery(self):
+ return self.frequency
+ def notifyOnFailureEvery(self):
+ return self.failureNotificationFrequency
+ def numberFailuresBeforeNotification(self):
+ return self.failuresBeforeNotification
+ def execute(self):
+ try:
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.settimeout(10)
+ s.connect((self.ip, self.port))
+ s.close()
+ return True
+ except:
+ self.failuremsg = "Could not hit server " + self.friendlyName
+ logging.warn(self.failuremsg)
+ return False
+ def onFailure(self):
+ return self.sendEmail(self.failuremsg, "")
+ def onStateChangeSuccess(self):
+ return self.sendEmail("Successfully hit " + self.friendlyName, "")
+
+ def get_sub_jobs(self, config):
+ for s in self.servers:
+ yield self.ServerChecker(config, s[0], s[1], s[2], s[3], s[4], s[5])
+
+