格式化代码,数据包增加丢包率packet

This commit is contained in:
ubuntu 2018-08-28 17:59:37 +08:00
parent 46def9acb2
commit 1ecca6e444
2 changed files with 385 additions and 371 deletions

@ -2,7 +2,7 @@
# Update by : https://github.com/cppla/ServerStatus
# 支持Python版本2.7 to 3.5
# 支持操作系统: Linux, OSX, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20180312
# 时间: 20180828
SERVER = "127.0.0.1"
@ -156,7 +156,11 @@ def get_network(ip_version):
pass
return False
lostRate = {}
lostRate = {
'10010': 0.0,
'189': 0.0,
'10086': 0.0
}
def _ping_thread(host, mark):
output = os.popen('ping -O %s &' % host)
lostCount = 0
@ -281,6 +285,9 @@ if __name__ == '__main__':
array['network_in'] = NET_IN
array['network_out'] = NET_OUT
array['ip_status'] = IP_STATUS
array['ping_10010'] = lostRate.get('10010') * 100
array['ping_189'] = lostRate.get('189') * 100
array['ping_10086'] = lostRate.get('10086') * 100
s.send("update " + json.dumps(array) + "\n")
except KeyboardInterrupt:

@ -3,7 +3,7 @@
# 依赖于psutil跨平台库
# 支持Python版本2.6 to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version)
# 支持操作系统: Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20180312
# 时间: 20180828
SERVER = "127.0.0.1"
PORT = 35601
@ -124,7 +124,11 @@ def get_network(ip_version):
pass
return False
lostRate = {}
lostRate = {
'10010': 0.0,
'189': 0.0,
'10086': 0.0
}
def _ping_thread(host, mark):
output = os.popen('ping -O %s &' % host if 'linux' in sys.platform else 'ping %s -t &' % host)
lostCount = 0
@ -251,6 +255,9 @@ if __name__ == '__main__':
array['network_in'] = NET_IN
array['network_out'] = NET_OUT
array['ip_status'] = IP_STATUS
array['ping_10010'] = lostRate.get('10010') * 100
array['ping_189'] = lostRate.get('189') * 100
array['ping_10086'] = lostRate.get('10086') * 100
s.send("update " + json.dumps(array) + "\n")
except KeyboardInterrupt: