From 584def7070dafbf9a03d1909ca5d9a81de00600a Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Tue, 2 Nov 2021 19:11:22 +0100 Subject: [PATCH] [IMP]Uptime : add millisecs on uptime info --- uptime/check/check.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/uptime/check/check.py b/uptime/check/check.py index f778a4b..81e2396 100644 --- a/uptime/check/check.py +++ b/uptime/check/check.py @@ -14,7 +14,7 @@ def check_domain(domain): r = get('https://%s' % domain) except Exception as e: return e - return r.status_code + return (r.status_code, r.elapsed) def ping_with_info(url, fail=False, data=None): try: @@ -29,9 +29,11 @@ for check_item in CONFIG: fail = False data = [] for domain in check_item['domains']: - status = check_domain(domain) + (status, timed) = check_domain(domain) if not fail and status != 200: fail = True - data.append('%s : %s' % (domain, status)) + data.append('%s : %s (%sms)' % ( + domain, status, round(timed.total_seconds() * 1000.0) + )) url = '%s/ping/%s' % (HC_ROOT, check_item['uuid']) ping_with_info(url, fail=fail, data='\n'.join(data))