portsopen.py: Allow config to include ports as either integers or lists for backwards compatibility
This commit is contained in:
parent
dd9e60fb9a
commit
4e50438717
1 changed files with 11 additions and 5 deletions
16
portsopen.py
16
portsopen.py
|
@ -6,9 +6,15 @@ hosts = setuptools.getListSetting("Ports", "hosts")
|
||||||
retry = int(setuptools.getSetting("Ports", "retry"))
|
retry = int(setuptools.getSetting("Ports", "retry"))
|
||||||
two = twitools.twObject()
|
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 h in hosts:
|
||||||
for p in h[1]:
|
try:
|
||||||
if not porttools.isPortOpen(h[0], p):
|
for p in h[1]:
|
||||||
time.sleep(retry)
|
check(h[0], p, h[2])
|
||||||
if not porttools.isPortOpen(h[0], p):
|
except TypeError:
|
||||||
two.tweet("@%s Port %s is not open on host %s!" % (h[2], p, h[0]))
|
check(*h)
|
||||||
|
|
Loading…
Reference in a new issue