去除ip_status检测,和丢包率检测重复。默认为python3, python2已经 end of life

This commit is contained in:
windows11 2021-10-09 21:28:05 +08:00
parent 60264204cb
commit c98dc92256
2 changed files with 6 additions and 34 deletions

@ -1,9 +1,9 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# coding: utf-8
# Update by : https://github.com/cppla/ServerStatus
# 支持Python版本2.7 to 3.7
# 支持Python版本2.7 to 3.9
# 支持操作系统: Linux, OSX, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20200407
# 时间: 20211009
# 说明: 默认情况下修改server和user就可以了。丢包率监测方向可以自定义例如CU = "www.facebook.com"。
SERVER = "127.0.0.1"
@ -119,18 +119,6 @@ def tupd():
d = int(s[:-1])-2
return t,u,p,d
def ip_status():
ip_check = 0
for i in [CU, CT, CM]:
try:
socket.create_connection((i, PROBEPORT), timeout=1).close()
except:
ip_check += 1
if ip_check >= 2:
return False
else:
return True
def get_network(ip_version):
if(ip_version == 4):
HOST = "ipv4.google.com"
@ -324,7 +312,6 @@ if __name__ == '__main__':
Load_1, Load_5, Load_15 = os.getloadavg()
MemoryTotal, MemoryUsed, SwapTotal, SwapFree = get_memory()
HDDTotal, HDDUsed = get_hdd()
IP_STATUS = ip_status()
array = {}
if not timer:
@ -348,7 +335,6 @@ if __name__ == '__main__':
array['network_tx'] = netSpeed.get("nettx")
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

@ -1,10 +1,10 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# coding: utf-8
# Update by : https://github.com/cppla/ServerStatus
# 依赖于psutil跨平台库
# 支持Python版本2.7 to 3.7
# 支持Python版本2.7 to 3.9
# 支持操作系统: Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD and NetBSD, both 32-bit and 64-bit architectures
# 时间: 20200407
# 时间: 20211009
# 说明: 默认情况下修改server和user就可以了。丢包率监测方向可以自定义例如CU = "www.facebook.com"。
SERVER = "127.0.0.1"
@ -103,18 +103,6 @@ def tupd():
except:
return 0,0,0,0
def ip_status():
ip_check = 0
for i in [CU, CT, CM]:
try:
socket.create_connection((i, PROBEPORT), timeout=1).close()
except:
ip_check += 1
if ip_check >= 2:
return False
else:
return True
def get_network(ip_version):
if(ip_version == 4):
HOST = "ipv4.google.com"
@ -305,7 +293,6 @@ if __name__ == '__main__':
MemoryTotal, MemoryUsed = get_memory()
SwapTotal, SwapUsed = get_swap()
HDDTotal, HDDUsed = get_hdd()
IP_STATUS = ip_status()
array = {}
if not timer:
@ -329,7 +316,6 @@ if __name__ == '__main__':
array['network_tx'] = netSpeed.get("nettx")
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