mirror of https://github.com/cppla/ServerStatus
跨平台的丢包率检测
parent
35f363edf8
commit
46def9acb2
|
@ -126,14 +126,14 @@ def get_network(ip_version):
|
||||||
|
|
||||||
lostRate = {}
|
lostRate = {}
|
||||||
def _ping_thread(host, mark):
|
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
|
lostCount = 0
|
||||||
allCount = 0
|
allCount = 0
|
||||||
startTime = time.time()
|
startTime = time.time()
|
||||||
output.readline()
|
output.readline()
|
||||||
output.readline()
|
output.readline()
|
||||||
while True:
|
while True:
|
||||||
if 'TTL' not in output.readline():
|
if 'TTL' not in output.readline().upper():
|
||||||
lostCount += 1
|
lostCount += 1
|
||||||
allCount += 1
|
allCount += 1
|
||||||
lostRate[mark] = "%.4f" % (float(lostCount) / allCount)
|
lostRate[mark] = "%.4f" % (float(lostCount) / allCount)
|
||||||
|
|
Loading…
Reference in New Issue