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