2016-03-30 16:15:30 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import time, setuptools, porttools, twitools
|
|
|
|
|
|
|
|
hosts = setuptools.getListSetting("Ports", "hosts")
|
|
|
|
retry = int(setuptools.getSetting("Ports", "retry"))
|
|
|
|
two = twitools.twObject()
|
|
|
|
|
2016-04-28 21:21:38 +00:00
|
|
|
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))
|
|
|
|
|
2016-03-30 16:15:30 +00:00
|
|
|
for h in hosts:
|
2016-04-28 21:21:38 +00:00
|
|
|
try:
|
|
|
|
for p in h[1]:
|
|
|
|
check(h[0], p, h[2])
|
|
|
|
except TypeError:
|
|
|
|
check(*h)
|