aboutsummaryrefslogtreecommitdiff
path: root/jobs/TCPServerChecker.py
diff options
context:
space:
mode:
authorTom <tom@ritter.vg>2016-12-28 13:59:43 -0600
committerTom Ritter <tom@ritter.vg>2016-12-28 14:37:55 -0600
commit3e85f1d0d48f0fb65a83af6ce3fb4b6a08f0bb1a (patch)
tree43367c6c5c98bf31759e576bcf43efabd4772e57 /jobs/TCPServerChecker.py
parent50111ca74eaa5b14253814a9aa39e35b40480935 (diff)
Create an option that lets you require two failures before alerting.
Diffstat (limited to 'jobs/TCPServerChecker.py')
-rwxr-xr-xjobs/TCPServerChecker.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/jobs/TCPServerChecker.py b/jobs/TCPServerChecker.py
index 4b5460c..d02cb58 100755
--- a/jobs/TCPServerChecker.py
+++ b/jobs/TCPServerChecker.py
@@ -9,18 +9,19 @@ import JobSpawner
class TCPServerChecker(JobSpawner.JobSpawner):
servers = [
- #("example.com", 53, "example.com:tcpdns", JobBase.JobFrequency.MINUTE, JobBase.JobFailureNotificationFrequency.EVERYTIME)
+ #("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):
+ 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
- super(TCPServerChecker.ServerChecker, self).__init__(config, ip, port, friendlyName, frequency, failureNotificationFrequency)
+ self.failuresBeforeNotification = failuresBeforeNotification
+ super(TCPServerChecker.ServerChecker, self).__init__(config, ip, port, friendlyName, frequency, failureNotificationFrequency, failuresBeforeNotification)
def getName(self):
return str(self.__class__) + " for " + self.friendlyName
@@ -28,6 +29,8 @@ class TCPServerChecker(JobSpawner.JobSpawner):
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)
@@ -46,6 +49,6 @@ class TCPServerChecker(JobSpawner.JobSpawner):
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])
+ yield self.ServerChecker(config, s[0], s[1], s[2], s[3], s[4], s[5])