From 25bdf4b7645dc3acc82a6f7f7fdd8af04bf7d66a Mon Sep 17 00:00:00 2001 From: yshtcn Date: Fri, 4 Aug 2023 16:06:00 +0800 Subject: [PATCH] Update heartbeat.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当ping为0时,将其设为1 --- heartbeat.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/heartbeat.py b/heartbeat.py index 5450cb7..2fc27e5 100644 --- a/heartbeat.py +++ b/heartbeat.py @@ -76,12 +76,16 @@ def ping(host): ping_result = ''.join(filter(str.isdigit, time_str)) if ping_result.isdigit() and int(ping_result) < 10000: + # If ping result is 0, change it to 1 + if int(ping_result) == 0: + ping_result = '1' return ping_result logger.info(f"{datetime.now()} Ping command output: {repr(stdout)}") return "ping failed" + def heartbeat(interval, heartbeat_url, session, ping_host): while not stop_heartbeat.is_set(): try: