mirror of
https://github.com//cppla/ServerStatus
synced 2025-07-16 06:52:21 +08:00
跨平台的丢包率检测
This commit is contained in:
parent
35f363edf8
commit
46def9acb2
@ -126,14 +126,14 @@ def get_network(ip_version):
|
||||
|
||||
lostRate = {}
|
||||
def _ping_thread(host, mark):
|
||||
output = os.popen('ping %s -t &' % host)
|
||||
output = os.popen('ping -O %s &' % host if 'linux' in sys.platform else 'ping %s -t &' % host)
|
||||
lostCount = 0
|
||||
allCount = 0
|
||||
startTime = time.time()
|
||||
output.readline()
|
||||
output.readline()
|
||||
while True:
|
||||
if 'TTL' not in output.readline():
|
||||
if 'TTL' not in output.readline().upper():
|
||||
lostCount += 1
|
||||
allCount += 1
|
||||
lostRate[mark] = "%.4f" % (float(lostCount) / allCount)
|
||||
|
Loading…
x
Reference in New Issue
Block a user