From d1ae463a67f1d2dd80171504d532c22d2260f026 Mon Sep 17 00:00:00 2001 From: Fabien BOURGEOIS Date: Sun, 19 Dec 2021 17:30:03 +0100 Subject: [PATCH] [FIX]Uptime error should continue checks --- uptime/check/check.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/uptime/check/check.py b/uptime/check/check.py index 81e2396..97437eb 100644 --- a/uptime/check/check.py +++ b/uptime/check/check.py @@ -13,7 +13,7 @@ def check_domain(domain): try: r = get('https://%s' % domain) except Exception as e: - return e + return (e, 0) return (r.status_code, r.elapsed) def ping_with_info(url, fail=False, data=None): @@ -32,8 +32,11 @@ for check_item in CONFIG: (status, timed) = check_domain(domain) if not fail and status != 200: fail = True - data.append('%s : %s (%sms)' % ( - domain, status, round(timed.total_seconds() * 1000.0) - )) + if isinstance(status, Exception): + data.append('%s : %s' % (domain, status)) + else: + 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))