From: Christoph Egger Date: Sat, 7 Nov 2015 18:09:42 +0000 (+0100) Subject: Nicely format time-until-expire X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=0a19bd5eae04fc75eda740e5c2d904ed81176f03;p=tools.git Nicely format time-until-expire more table-like with fixed width of timedelta --- diff --git a/tls-check b/tls-check index d8bdc9b..3919e2e 100644 --- a/tls-check +++ b/tls-check @@ -71,12 +71,13 @@ class Verifier: def check_cert(self, data, host, port, name): expiretimestamp = cert_time_to_seconds(data['notAfter']) delta = datetime.utcfromtimestamp(expiretimestamp) - datetime.utcnow() + deltastr = str(delta).split(",") if delta < self.crit: - print("CRIT (expires in %s) %s:%d" % (delta, name, port)) + print("CRIT (expires in %8s,%16s) %s:%d" % (deltastr[0], deltastr[1], name, port)) return 2 elif delta < self.warn: - print("WARN (expires in %s) %s:%d" % (delta, name, port)) + print("WARN (expires in %8s,%16s) %s:%d" % (deltastr[0], deltastr[1], name, port)) return 1 def main():