Commit 4e504387 authored by Klaus-Uwe Mitterer's avatar Klaus-Uwe Mitterer

portsopen.py: Allow config to include ports as either integers or lists for backwards compatibility

parent dd9e60fb
Pipeline #3 skipped
......@@ -6,9 +6,15 @@ hosts = setuptools.getListSetting("Ports", "hosts")
retry = int(setuptools.getSetting("Ports", "retry"))
two = twitools.twObject()
def check(host, port, recipient):
if not porttools.isPortOpen(host, port):
time.sleep(retry)
if not porttools.isPortOpen(host, port):
two.tweet("@%s Port %s is not open on host %s!" % (recipient, port, host))
for h in hosts:
for p in h[1]:
if not porttools.isPortOpen(h[0], p):
time.sleep(retry)
if not porttools.isPortOpen(h[0], p):
two.tweet("@%s Port %s is not open on host %s!" % (h[2], p, h[0]))
try:
for p in h[1]:
check(h[0], p, h[2])
except TypeError:
check(*h)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment