From 0a19bd5eae04fc75eda740e5c2d904ed81176f03 Mon Sep 17 00:00:00 2001 From: Christoph Egger Date: Sat, 7 Nov 2015 19:09:42 +0100 Subject: [PATCH] Nicely format time-until-expire more table-like with fixed width of timedelta --- tls-check | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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(): -- 2.39.5