From c98dc922562fc8c9c54403d5fffa7ee3932f387f Mon Sep 17 00:00:00 2001 From: windows11 <windows11@pc> Date: Sat, 9 Oct 2021 21:28:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4ip=5Fstatus=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=EF=BC=8C=E5=92=8C=E4=B8=A2=E5=8C=85=E7=8E=87=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E3=80=82=E9=BB=98=E8=AE=A4=E4=B8=BApython3,?= =?UTF-8?q?=20python2=E5=B7=B2=E7=BB=8F=20end=20of=20life?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clients/client-linux.py | 20 +++----------------- clients/client-psutil.py | 20 +++----------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/clients/client-linux.py b/clients/client-linux.py index c946300..a6c4a0c 100755 --- a/clients/client-linux.py +++ b/clients/client-linux.py @@ -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 diff --git a/clients/client-psutil.py b/clients/client-psutil.py index b172dfb..f1a464b 100755 --- a/clients/client-psutil.py +++ b/clients/client-psutil.py @@ -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