From 41fba68a17b361901d51aab6ea0c9a25bfb03341 Mon Sep 17 00:00:00 2001 From: ubuntu Date: Wed, 29 Aug 2018 13:57:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E5=90=93=E4=BA=BA~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clients/client-linux.py | 6 +++++- clients/client-psutil.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clients/client-linux.py b/clients/client-linux.py index 5eefb95..b4f092e 100755 --- a/clients/client-linux.py +++ b/clients/client-linux.py @@ -171,7 +171,11 @@ def _ping_thread(host, mark): if 'ttl' not in output.readline(): lostCount += 1 allCount += 1 - lostRate[mark] = float(lostCount) / allCount + # 防止吓人 + if allCount < 100: + lostRate[mark] = 0.00 + else: + lostRate[mark] = float(lostCount) / allCount endTime = time.time() if endTime-startTime > 3600: lostCount = 0 diff --git a/clients/client-psutil.py b/clients/client-psutil.py index 5210079..d94944d 100755 --- a/clients/client-psutil.py +++ b/clients/client-psutil.py @@ -140,7 +140,11 @@ def _ping_thread(host, mark): if 'TTL' not in output.readline().upper(): lostCount += 1 allCount += 1 - lostRate[mark] = float(lostCount) / allCount + # 防止吓人 + if allCount < 100: + lostRate[mark] = 0.00 + else: + lostRate[mark] = float(lostCount) / allCount endTime = time.time() if endTime-startTime > 3600: lostCount = 0