aboutsummaryrefslogtreecommitdiff
path: root/jobs/TCPServerChecker.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/TCPServerChecker.py
parentee3eea047c10d0032efc5a8b98d9bbdb54fe0a3a (diff)
Correct line endings
Diffstat (limited to 'jobs/TCPServerChecker.py')
-rwxr-xr-xjobs/TCPServerChecker.py108
1 files changed, 54 insertions, 54 deletions
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])
+
+