Allow sslexpiry to be directly executed through an import
This commit is contained in:
parent
ebcb76ab67
commit
44fb3f9f10
1 changed files with 12 additions and 13 deletions
25
sslexpiry.py
25
sslexpiry.py
|
@ -2,17 +2,16 @@
|
|||
|
||||
import datetime, setuptools, ssltools, twitools
|
||||
|
||||
if __name__ == "__main__":
|
||||
hosts = setuptools.getListSetting("SSL", "hosts")
|
||||
pbefore = int(setuptools.getSetting("SSL", "pbefore"))
|
||||
pafter = int(setuptools.getSetting("SSL", "pafter"))
|
||||
two = twitools.twObject()
|
||||
hosts = setuptools.getListSetting("SSL", "hosts")
|
||||
pbefore = int(setuptools.getSetting("SSL", "pbefore"))
|
||||
pafter = int(setuptools.getSetting("SSL", "pafter"))
|
||||
two = twitools.twObject()
|
||||
|
||||
for h in hosts:
|
||||
expiry = ssltools.getRemoteExpiry(h[0], h[1])
|
||||
diff = expiry - datetime.datetime.now()
|
||||
if diff < datetime.timedelta(days=pbefore):
|
||||
if expiry > datetime.datetime.now():
|
||||
two.tweet("@%s %s certificate expiring soon (%s). Please renew." % (h[2], h[0], expiry))
|
||||
elif expiry + datetime.timedelta(days=pafter) < datetime.datetime.now():
|
||||
two.tweet("@%s %s certificate has expired! (%s) Please renew ASAP!" % (h[2], h[0], expiry))
|
||||
for h in hosts:
|
||||
expiry = ssltools.getRemoteExpiry(h[0], h[1])
|
||||
diff = expiry - datetime.datetime.now()
|
||||
if diff < datetime.timedelta(days=pbefore):
|
||||
if expiry > datetime.datetime.now():
|
||||
two.tweet("@%s %s certificate expiring soon (%s). Please renew." % (h[2], h[0], expiry))
|
||||
elif expiry + datetime.timedelta(days=pafter) < datetime.datetime.now():
|
||||
two.tweet("@%s %s certificate has expired! (%s) Please renew ASAP!" % (h[2], h[0], expiry))
|
||||
|
|
Loading…
Reference in a new issue