mirror of https://github.com/cppla/ServerStatus
格式化代码,数据包增加丢包率packet
parent
46def9acb2
commit
1ecca6e444
|
@ -2,7 +2,7 @@
|
||||||
# Update by : https://github.com/cppla/ServerStatus
|
# Update by : https://github.com/cppla/ServerStatus
|
||||||
# 支持Python版本:2.7 to 3.5
|
# 支持Python版本:2.7 to 3.5
|
||||||
# 支持操作系统: Linux, OSX, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
|
# 支持操作系统: Linux, OSX, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
|
||||||
# 时间: 20180312
|
# 时间: 20180828
|
||||||
|
|
||||||
|
|
||||||
SERVER = "127.0.0.1"
|
SERVER = "127.0.0.1"
|
||||||
|
@ -156,7 +156,11 @@ def get_network(ip_version):
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
lostRate = {}
|
lostRate = {
|
||||||
|
'10010': 0.0,
|
||||||
|
'189': 0.0,
|
||||||
|
'10086': 0.0
|
||||||
|
}
|
||||||
def _ping_thread(host, mark):
|
def _ping_thread(host, mark):
|
||||||
output = os.popen('ping -O %s &' % host)
|
output = os.popen('ping -O %s &' % host)
|
||||||
lostCount = 0
|
lostCount = 0
|
||||||
|
@ -281,6 +285,9 @@ if __name__ == '__main__':
|
||||||
array['network_in'] = NET_IN
|
array['network_in'] = NET_IN
|
||||||
array['network_out'] = NET_OUT
|
array['network_out'] = NET_OUT
|
||||||
array['ip_status'] = IP_STATUS
|
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")
|
s.send("update " + json.dumps(array) + "\n")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# 依赖于psutil跨平台库:
|
# 依赖于psutil跨平台库:
|
||||||
# 支持Python版本:2.6 to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version)
|
# 支持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
|
# 支持操作系统: Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
|
||||||
# 时间: 20180312
|
# 时间: 20180828
|
||||||
|
|
||||||
SERVER = "127.0.0.1"
|
SERVER = "127.0.0.1"
|
||||||
PORT = 35601
|
PORT = 35601
|
||||||
|
@ -124,7 +124,11 @@ def get_network(ip_version):
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
lostRate = {}
|
lostRate = {
|
||||||
|
'10010': 0.0,
|
||||||
|
'189': 0.0,
|
||||||
|
'10086': 0.0
|
||||||
|
}
|
||||||
def _ping_thread(host, mark):
|
def _ping_thread(host, mark):
|
||||||
output = os.popen('ping -O %s &' % host if 'linux' in sys.platform else '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
|
||||||
|
@ -251,6 +255,9 @@ if __name__ == '__main__':
|
||||||
array['network_in'] = NET_IN
|
array['network_in'] = NET_IN
|
||||||
array['network_out'] = NET_OUT
|
array['network_out'] = NET_OUT
|
||||||
array['ip_status'] = IP_STATUS
|
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")
|
s.send("update " + json.dumps(array) + "\n")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
|
Loading…
Reference in New Issue