mirror of https://github.com/cppla/ServerStatus
custom probe check by yourself
parent
fa84260a61
commit
5576acc29d
|
@ -4,13 +4,19 @@
|
||||||
# 支持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
|
||||||
# 时间: 20190128
|
# 时间: 20190128
|
||||||
|
# 说明: 默认情况下修改server和user就可以了。
|
||||||
|
|
||||||
SERVER = "127.0.0.1"
|
SERVER = "127.0.0.1"
|
||||||
PORT = 35601
|
|
||||||
USER = "s01"
|
USER = "s01"
|
||||||
|
|
||||||
|
|
||||||
|
PORT = 35601
|
||||||
PASSWORD = "USER_DEFAULT_PASSWORD"
|
PASSWORD = "USER_DEFAULT_PASSWORD"
|
||||||
INTERVAL = 1 #更新间隔
|
INTERVAL = 1
|
||||||
|
PORBEPORT = 80
|
||||||
|
CU = "cu.tz.cloudcpp.com"
|
||||||
|
CT = "ct.tz.cloudcpp.com"
|
||||||
|
CM = "cm.tz.cloudcpp.com"
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
|
@ -54,7 +60,7 @@ def get_hdd():
|
||||||
return int(size), int(used)
|
return int(size), int(used)
|
||||||
|
|
||||||
def get_time():
|
def get_time():
|
||||||
stat_file = file("/proc/stat", "r")
|
stat_file = open("/proc/stat", "r")
|
||||||
time_list = stat_file.readline().split(' ')[2:6]
|
time_list = stat_file.readline().split(' ')[2:6]
|
||||||
stat_file.close()
|
stat_file.close()
|
||||||
for i in range(len(time_list)) :
|
for i in range(len(time_list)) :
|
||||||
|
@ -144,13 +150,12 @@ def tupd():
|
||||||
return t,u,p,d
|
return t,u,p,d
|
||||||
|
|
||||||
def ip_status():
|
def ip_status():
|
||||||
object_check = ['www.10010.com', 'www.189.cn', 'www.10086.cn']
|
|
||||||
ip_check = 0
|
ip_check = 0
|
||||||
for i in object_check:
|
for i in [CU, CT, CM]:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.settimeout(1)
|
s.settimeout(1)
|
||||||
try:
|
try:
|
||||||
s.connect((i, 80))
|
s.connect((i, PORBEPORT))
|
||||||
except:
|
except:
|
||||||
ip_check += 1
|
ip_check += 1
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -215,25 +220,25 @@ def get_packetLostRate():
|
||||||
t1 = threading.Thread(
|
t1 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'cu.tz.cloudcpp.com',
|
'host': CU,
|
||||||
'mark': '10010',
|
'mark': '10010',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t2 = threading.Thread(
|
t2 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'ct.tz.cloudcpp.com',
|
'host': CT,
|
||||||
'mark': '189',
|
'mark': '189',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t3 = threading.Thread(
|
t3 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'cm.tz.cloudcpp.com',
|
'host': CM,
|
||||||
'mark': '10086',
|
'mark': '10086',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t1.setDaemon(True)
|
t1.setDaemon(True)
|
||||||
|
|
|
@ -1,18 +1,25 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
# Update by : https://github.com/cppla/ServerStatus
|
# Update by : https://github.com/cppla/ServerStatus
|
||||||
# 依赖于psutil跨平台库:
|
# 依赖于psutil跨平台库
|
||||||
# 支持Python版本:2.7 to 3.5
|
# 支持Python版本:2.7 to 3.5
|
||||||
# 支持操作系统: 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
|
||||||
# 时间: 20190128
|
# 时间: 20190128
|
||||||
|
# 说明: 默认情况下修改server和user就可以了。
|
||||||
|
|
||||||
|
|
||||||
SERVER = "127.0.0.1"
|
SERVER = "127.0.0.1"
|
||||||
PORT = 35601
|
|
||||||
USER = "s01"
|
USER = "s01"
|
||||||
PASSWORD = "USER_DEFAULT_PASSWORD"
|
|
||||||
INTERVAL = 1 # 更新间隔
|
|
||||||
|
|
||||||
|
|
||||||
|
PORT = 35601
|
||||||
|
PASSWORD = "USER_DEFAULT_PASSWORD"
|
||||||
|
INTERVAL = 1
|
||||||
|
PORBEPORT = 80
|
||||||
|
CU = "cu.tz.cloudcpp.com"
|
||||||
|
CT = "ct.tz.cloudcpp.com"
|
||||||
|
CM = "cm.tz.cloudcpp.com"
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
import time
|
import time
|
||||||
import timeit
|
import timeit
|
||||||
|
@ -115,13 +122,12 @@ def tupd():
|
||||||
return t,u,p,d
|
return t,u,p,d
|
||||||
|
|
||||||
def ip_status():
|
def ip_status():
|
||||||
object_check = ['www.10010.com', 'www.189.cn', 'www.10086.cn']
|
|
||||||
ip_check = 0
|
ip_check = 0
|
||||||
for i in object_check:
|
for i in [CU, CT, CM]:
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.settimeout(1)
|
s.settimeout(1)
|
||||||
try:
|
try:
|
||||||
s.connect((i, 80))
|
s.connect((i, PORBEPORT))
|
||||||
except:
|
except:
|
||||||
ip_check += 1
|
ip_check += 1
|
||||||
s.close()
|
s.close()
|
||||||
|
@ -186,25 +192,25 @@ def get_packetLostRate():
|
||||||
t1 = threading.Thread(
|
t1 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'cu.tz.cloudcpp.com',
|
'host': CU,
|
||||||
'mark': '10010',
|
'mark': '10010',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t2 = threading.Thread(
|
t2 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'ct.tz.cloudcpp.com',
|
'host': CT,
|
||||||
'mark': '189',
|
'mark': '189',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t3 = threading.Thread(
|
t3 = threading.Thread(
|
||||||
target=_ping_thread,
|
target=_ping_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
'host': 'cm.tz.cloudcpp.com',
|
'host': CM,
|
||||||
'mark': '10086',
|
'mark': '10086',
|
||||||
'port': 443
|
'port': PORBEPORT
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
t1.setDaemon(True)
|
t1.setDaemon(True)
|
||||||
|
|
Loading…
Reference in New Issue