mirror of
https://github.com//cppla/ServerStatus
synced 2025-07-04 16:35:58 +08:00
测试监控重要服务
This commit is contained in:
parent
d96e711a34
commit
71cadcfebe
@ -20,6 +20,7 @@ PING_PACKET_HISTORY_LEN = 100
|
|||||||
INTERVAL = 1
|
INTERVAL = 1
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
import ssl
|
||||||
import time
|
import time
|
||||||
import timeit
|
import timeit
|
||||||
import re
|
import re
|
||||||
@ -29,10 +30,10 @@ import json
|
|||||||
import errno
|
import errno
|
||||||
import subprocess
|
import subprocess
|
||||||
import threading
|
import threading
|
||||||
try:
|
if sys.version_info.major == 3:
|
||||||
from queue import Queue # python3
|
from queue import Queue
|
||||||
except ImportError:
|
elif sys.version_info.major == 2:
|
||||||
from Queue import Queue # python2
|
from Queue import Queue
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
with open('/proc/uptime', 'r') as f:
|
with open('/proc/uptime', 'r') as f:
|
||||||
@ -150,6 +151,7 @@ diskIO = {
|
|||||||
'read': 0,
|
'read': 0,
|
||||||
'write': 0
|
'write': 0
|
||||||
}
|
}
|
||||||
|
monitorServer = {}
|
||||||
|
|
||||||
def _ping_thread(host, mark, port):
|
def _ping_thread(host, mark, port):
|
||||||
lostPacket = 0
|
lostPacket = 0
|
||||||
@ -314,6 +316,97 @@ def get_realtime_data():
|
|||||||
ti.daemon = True
|
ti.daemon = True
|
||||||
ti.start()
|
ti.start()
|
||||||
|
|
||||||
|
|
||||||
|
def _monitor_thread(name, host, interval, type):
|
||||||
|
lostPacket = 0
|
||||||
|
packet_queue = Queue(maxsize=PING_PACKET_HISTORY_LEN)
|
||||||
|
while True:
|
||||||
|
if name not in monitorServer.keys():
|
||||||
|
monitorServer[name] = {
|
||||||
|
"type": type,
|
||||||
|
"dns_time": 0,
|
||||||
|
"connect_time": 0,
|
||||||
|
"download_time": 0,
|
||||||
|
"online_rate": 1
|
||||||
|
}
|
||||||
|
if packet_queue.full():
|
||||||
|
if packet_queue.get() == 0:
|
||||||
|
lostPacket -= 1
|
||||||
|
try:
|
||||||
|
if type == "http":
|
||||||
|
address = host.replace("http://", "")
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, 80), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k.sendall("GET / HTTP/1.2\r\nHost:{}\r\nConnection:close\r\n\r\n".format(address).encode('utf-8'))
|
||||||
|
response = b""
|
||||||
|
while True:
|
||||||
|
data = k.recv(4096)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
response += data
|
||||||
|
http_code = response.decode('utf-8').split('\r\n')[0].split()[1]
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
k.close()
|
||||||
|
if http_code not in ['200', '204', '301', '302', '401']:
|
||||||
|
raise Exception("http code not in 200, 204, 301, 302, 401")
|
||||||
|
elif type == "https":
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
address = host.replace("https://", "")
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, 443), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
kk = context.wrap_socket(k, server_hostname=address)
|
||||||
|
kk.sendall("GET / HTTP/1.2\r\nHost:{}\r\nConnection:close\r\n\r\n".format(address).encode('utf-8'))
|
||||||
|
response = b""
|
||||||
|
while True:
|
||||||
|
data = kk.recv(4096)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
response += data
|
||||||
|
http_code = response.decode('utf-8').split('\r\n')[0].split()[1]
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
kk.close()
|
||||||
|
k.close()
|
||||||
|
if http_code not in ['200', '204', '301', '302', '401']:
|
||||||
|
raise Exception("http code not in 200, 204, 301, 302, 401")
|
||||||
|
elif type == "tcp":
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(host.split(":")[0], None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(host.split(":")[0], None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, int(host.split(":")[1])), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k.send(b"GET / HTTP/1.2\r\n\r\n")
|
||||||
|
k.recv(1024)
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
k.close()
|
||||||
|
packet_queue.put(1)
|
||||||
|
except Exception as e:
|
||||||
|
lostPacket += 1
|
||||||
|
packet_queue.put(0)
|
||||||
|
if packet_queue.qsize() > 5:
|
||||||
|
monitorServer[name]["online_rate"] = 1 - float(lostPacket) / packet_queue.qsize()
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
def byte_str(object):
|
def byte_str(object):
|
||||||
'''
|
'''
|
||||||
bytes to str, str to bytes
|
bytes to str, str to bytes
|
||||||
@ -360,6 +453,20 @@ if __name__ == '__main__':
|
|||||||
if data.find("You are connecting via") < 0:
|
if data.find("You are connecting via") < 0:
|
||||||
data = byte_str(s.recv(1024))
|
data = byte_str(s.recv(1024))
|
||||||
print(data)
|
print(data)
|
||||||
|
for i in data.split('\n'):
|
||||||
|
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
||||||
|
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
||||||
|
t = threading.Thread(
|
||||||
|
target=_monitor_thread,
|
||||||
|
kwargs={
|
||||||
|
'name': jdata.get("name"),
|
||||||
|
'host': jdata.get("host"),
|
||||||
|
'interval': jdata.get("interval"),
|
||||||
|
'type': jdata.get("type")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
timer = 0
|
timer = 0
|
||||||
check_ip = 0
|
check_ip = 0
|
||||||
@ -378,7 +485,6 @@ if __name__ == '__main__':
|
|||||||
Load_1, Load_5, Load_15 = os.getloadavg()
|
Load_1, Load_5, Load_15 = os.getloadavg()
|
||||||
MemoryTotal, MemoryUsed, SwapTotal, SwapFree = get_memory()
|
MemoryTotal, MemoryUsed, SwapTotal, SwapFree = get_memory()
|
||||||
HDDTotal, HDDUsed = get_hdd()
|
HDDTotal, HDDUsed = get_hdd()
|
||||||
|
|
||||||
array = {}
|
array = {}
|
||||||
if not timer:
|
if not timer:
|
||||||
array['online' + str(check_ip)] = get_network(check_ip)
|
array['online' + str(check_ip)] = get_network(check_ip)
|
||||||
@ -412,7 +518,7 @@ if __name__ == '__main__':
|
|||||||
array['tcp'], array['udp'], array['process'], array['thread'] = tupd()
|
array['tcp'], array['udp'], array['process'], array['thread'] = tupd()
|
||||||
array['io_read'] = diskIO.get("read")
|
array['io_read'] = diskIO.get("read")
|
||||||
array['io_write'] = diskIO.get("write")
|
array['io_write'] = diskIO.get("write")
|
||||||
|
array['custom'] = "<br>".join(f"<code>{k}</code>\\t解析: {v['dns_time']}\\t连接: {v['connect_time']}\\t下载: {v['download_time']}\\t在线率: <code>{v['online_rate']*100}%</code>" for k, v in monitorServer.items())
|
||||||
s.send(byte_str("update " + json.dumps(array) + "\n"))
|
s.send(byte_str("update " + json.dumps(array) + "\n"))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
|
@ -21,6 +21,7 @@ PING_PACKET_HISTORY_LEN = 100
|
|||||||
INTERVAL = 1
|
INTERVAL = 1
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
import ssl
|
||||||
import time
|
import time
|
||||||
import timeit
|
import timeit
|
||||||
import os
|
import os
|
||||||
@ -29,10 +30,10 @@ import json
|
|||||||
import errno
|
import errno
|
||||||
import psutil
|
import psutil
|
||||||
import threading
|
import threading
|
||||||
try:
|
if sys.version_info.major == 3:
|
||||||
from queue import Queue # python3
|
from queue import Queue
|
||||||
except ImportError:
|
elif sys.version_info.major == 2:
|
||||||
from Queue import Queue # python2
|
from Queue import Queue
|
||||||
|
|
||||||
def get_uptime():
|
def get_uptime():
|
||||||
return int(time.time() - psutil.boot_time())
|
return int(time.time() - psutil.boot_time())
|
||||||
@ -148,6 +149,7 @@ diskIO = {
|
|||||||
'read': 0,
|
'read': 0,
|
||||||
'write': 0
|
'write': 0
|
||||||
}
|
}
|
||||||
|
monitorServer = {}
|
||||||
|
|
||||||
def _ping_thread(host, mark, port):
|
def _ping_thread(host, mark, port):
|
||||||
lostPacket = 0
|
lostPacket = 0
|
||||||
@ -303,6 +305,97 @@ def get_realtime_data():
|
|||||||
ti.daemon = True
|
ti.daemon = True
|
||||||
ti.start()
|
ti.start()
|
||||||
|
|
||||||
|
def _monitor_thread(name, host, interval, type):
|
||||||
|
lostPacket = 0
|
||||||
|
packet_queue = Queue(maxsize=PING_PACKET_HISTORY_LEN)
|
||||||
|
while True:
|
||||||
|
if name not in monitorServer.keys():
|
||||||
|
monitorServer[name] = {
|
||||||
|
"type": type,
|
||||||
|
"dns_time": 0,
|
||||||
|
"connect_time": 0,
|
||||||
|
"download_time": 0,
|
||||||
|
"online_rate": 1
|
||||||
|
}
|
||||||
|
if packet_queue.full():
|
||||||
|
if packet_queue.get() == 0:
|
||||||
|
lostPacket -= 1
|
||||||
|
try:
|
||||||
|
if type == "http":
|
||||||
|
address = host.replace("http://", "")
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, 80), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k.sendall("GET / HTTP/1.2\r\nHost:{}\r\nConnection:close\r\n\r\n".format(address).encode('utf-8'))
|
||||||
|
response = b""
|
||||||
|
while True:
|
||||||
|
data = k.recv(4096)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
response += data
|
||||||
|
http_code = response.decode('utf-8').split('\r\n')[0].split()[1]
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
k.close()
|
||||||
|
if http_code not in ['200', '204', '301', '302', '401']:
|
||||||
|
raise Exception("http code not in 200, 204, 301, 302, 401")
|
||||||
|
elif type == "https":
|
||||||
|
context = ssl._create_unverified_context()
|
||||||
|
address = host.replace("https://", "")
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(address, None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, 443), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
kk = context.wrap_socket(k, server_hostname=address)
|
||||||
|
kk.sendall("GET / HTTP/1.2\r\nHost:{}\r\nConnection:close\r\n\r\n".format(address).encode('utf-8'))
|
||||||
|
response = b""
|
||||||
|
while True:
|
||||||
|
data = kk.recv(4096)
|
||||||
|
if not data:
|
||||||
|
break
|
||||||
|
response += data
|
||||||
|
http_code = response.decode('utf-8').split('\r\n')[0].split()[1]
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
kk.close()
|
||||||
|
k.close()
|
||||||
|
if http_code not in ['200', '204', '301', '302', '401']:
|
||||||
|
raise Exception("http code not in 200, 204, 301, 302, 401")
|
||||||
|
elif type == "tcp":
|
||||||
|
m = timeit.default_timer()
|
||||||
|
if PROBE_PROTOCOL_PREFER == 'ipv4':
|
||||||
|
IP = socket.getaddrinfo(host.split(":")[0], None, socket.AF_INET)[0][4][0]
|
||||||
|
else:
|
||||||
|
IP = socket.getaddrinfo(host.split(":")[0], None, socket.AF_INET6)[0][4][0]
|
||||||
|
monitorServer[name]["dns_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k = socket.create_connection((IP, int(host.split(":")[1])), timeout=6)
|
||||||
|
monitorServer[name]["connect_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
m = timeit.default_timer()
|
||||||
|
k.send(b"GET / HTTP/1.2\r\n\r\n")
|
||||||
|
k.recv(1024)
|
||||||
|
monitorServer[name]["download_time"] = int((timeit.default_timer() - m) * 1000)
|
||||||
|
k.close()
|
||||||
|
packet_queue.put(1)
|
||||||
|
except Exception as e:
|
||||||
|
lostPacket += 1
|
||||||
|
packet_queue.put(0)
|
||||||
|
if packet_queue.qsize() > 5:
|
||||||
|
monitorServer[name]["online_rate"] = 1 - float(lostPacket) / packet_queue.qsize()
|
||||||
|
time.sleep(interval)
|
||||||
|
|
||||||
|
|
||||||
def byte_str(object):
|
def byte_str(object):
|
||||||
'''
|
'''
|
||||||
bytes to str, str to bytes
|
bytes to str, str to bytes
|
||||||
@ -349,6 +442,20 @@ if __name__ == '__main__':
|
|||||||
if data.find("You are connecting via") < 0:
|
if data.find("You are connecting via") < 0:
|
||||||
data = byte_str(s.recv(1024))
|
data = byte_str(s.recv(1024))
|
||||||
print(data)
|
print(data)
|
||||||
|
for i in data.split('\n'):
|
||||||
|
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
||||||
|
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
||||||
|
t = threading.Thread(
|
||||||
|
target=_monitor_thread,
|
||||||
|
kwargs={
|
||||||
|
'name': jdata.get("name"),
|
||||||
|
'host': jdata.get("host"),
|
||||||
|
'interval': jdata.get("interval"),
|
||||||
|
'type': jdata.get("type")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
t.daemon = True
|
||||||
|
t.start()
|
||||||
|
|
||||||
timer = 0
|
timer = 0
|
||||||
check_ip = 0
|
check_ip = 0
|
||||||
@ -368,7 +475,6 @@ if __name__ == '__main__':
|
|||||||
MemoryTotal, MemoryUsed = get_memory()
|
MemoryTotal, MemoryUsed = get_memory()
|
||||||
SwapTotal, SwapUsed = get_swap()
|
SwapTotal, SwapUsed = get_swap()
|
||||||
HDDTotal, HDDUsed = get_hdd()
|
HDDTotal, HDDUsed = get_hdd()
|
||||||
|
|
||||||
array = {}
|
array = {}
|
||||||
if not timer:
|
if not timer:
|
||||||
array['online' + str(check_ip)] = get_network(check_ip)
|
array['online' + str(check_ip)] = get_network(check_ip)
|
||||||
@ -402,7 +508,7 @@ if __name__ == '__main__':
|
|||||||
array['tcp'], array['udp'], array['process'], array['thread'] = tupd()
|
array['tcp'], array['udp'], array['process'], array['thread'] = tupd()
|
||||||
array['io_read'] = diskIO.get("read")
|
array['io_read'] = diskIO.get("read")
|
||||||
array['io_write'] = diskIO.get("write")
|
array['io_write'] = diskIO.get("write")
|
||||||
|
array['custom'] = "<br>".join(f"<code>{k}</code>\\t解析: {v['dns_time']}\\t连接: {v['connect_time']}\\t下载: {v['download_time']}\\t在线率: <code>{v['online_rate']*100}%</code>" for k, v in monitorServer.items())
|
||||||
s.send(byte_str("update " + json.dumps(array) + "\n"))
|
s.send(byte_str("update " + json.dumps(array) + "\n"))
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
|
@ -38,6 +38,26 @@
|
|||||||
"monthstart": 1
|
"monthstart": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"monitors": [
|
||||||
|
{
|
||||||
|
"name": "百度一下",
|
||||||
|
"host": "https://www.baidu.com",
|
||||||
|
"interval": 60,
|
||||||
|
"type": "https"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "主机交流",
|
||||||
|
"host": "https://www.hostloc.com",
|
||||||
|
"interval": 60,
|
||||||
|
"type": "https"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "DNS服务",
|
||||||
|
"host": "114.114.114.114:53",
|
||||||
|
"interval": 60,
|
||||||
|
"type": "tcp"
|
||||||
|
}
|
||||||
|
],
|
||||||
"watchdog": [
|
"watchdog": [
|
||||||
{
|
{
|
||||||
"name": "cpu high warning,exclude username s01",
|
"name": "cpu high warning,exclude username s01",
|
||||||
@ -58,17 +78,17 @@
|
|||||||
"callback": "https://yourSMSurl"
|
"callback": "https://yourSMSurl"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ddcc attack,limit type Oracle",
|
"name": "ddcc attack,limit type Oracle",
|
||||||
"rule": "tcp_count>600&type='Oracle'",
|
"rule": "tcp_count>600&type='Oracle'",
|
||||||
"interval": 300,
|
"interval": 300,
|
||||||
"callback": "https://yourSMSurl"
|
"callback": "https://yourSMSurl"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "month traffic warning",
|
"name": "month traffic warning",
|
||||||
"rule": "(network_out-last_network_out)/1024/1024/1024>999",
|
"rule": "(network_out-last_network_out)/1024/1024/1024>999",
|
||||||
"interval": 3600,
|
"interval": 3600,
|
||||||
"callback": "https://yourSMSurl"
|
"callback": "https://yourSMSurl"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "you can parse an expression combining any known field",
|
"name": "you can parse an expression combining any known field",
|
||||||
"rule": "load_5>3",
|
"rule": "load_5>3",
|
||||||
|
@ -92,6 +92,18 @@ void CMain::OnNewClient(int ClientNetID, int ClientID)
|
|||||||
Client(ClientID)->m_Stats.m_Online4 = true;
|
Client(ClientID)->m_Stats.m_Online4 = true;
|
||||||
else if(Client(ClientID)->m_ClientNetType == NETTYPE_IPV6)
|
else if(Client(ClientID)->m_ClientNetType == NETTYPE_IPV6)
|
||||||
Client(ClientID)->m_Stats.m_Online6 = true;
|
Client(ClientID)->m_Stats.m_Online6 = true;
|
||||||
|
|
||||||
|
// Send monitor to client
|
||||||
|
// support by cpp.la
|
||||||
|
int ID = 0;
|
||||||
|
char monitorBuffer[2048];
|
||||||
|
while (strcmp(Monitors(ID)->m_aName, "NULL"))
|
||||||
|
{
|
||||||
|
memset(monitorBuffer, 0, sizeof(monitorBuffer));
|
||||||
|
sprintf(monitorBuffer, "{\"name\":\"%s\",\"host\":\"%s\",\"interval\":%d,\"type\":\"%s\",\"monitor\":%d}", Monitors(ID)->m_aName, Monitors(ID)->m_aHost, Monitors(ID)->m_aInterval, Monitors(ID)->m_aType, ID);
|
||||||
|
m_Server.Network()->Send(ClientNetID, monitorBuffer);
|
||||||
|
ID++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMain::OnDelClient(int ClientNetID)
|
void CMain::OnDelClient(int ClientNetID)
|
||||||
@ -572,6 +584,28 @@ int CMain::ReadConfig()
|
|||||||
} else
|
} else
|
||||||
str_copy(Watchdog(ID)->m_aName, "NULL", sizeof(Watchdog(ID)->m_aName));
|
str_copy(Watchdog(ID)->m_aName, "NULL", sizeof(Watchdog(ID)->m_aName));
|
||||||
|
|
||||||
|
// monitor
|
||||||
|
// support by: https://cpp.la
|
||||||
|
ID = 0;
|
||||||
|
const json_value &mStart = (*pJsonData)["monitors"];
|
||||||
|
if(mStart.type == json_array)
|
||||||
|
{
|
||||||
|
for(unsigned i = 0; i < mStart.u.array.length; i++)
|
||||||
|
{
|
||||||
|
if(ID < 0 || ID >= NET_MAX_CLIENTS)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
str_copy(Monitors(ID)->m_aName, mStart[i]["name"].u.string.ptr, sizeof(Monitors(ID)->m_aName));
|
||||||
|
str_copy(Monitors(ID)->m_aHost, mStart[i]["host"].u.string.ptr, sizeof(Monitors(ID)->m_aHost));
|
||||||
|
Monitors(ID)->m_aInterval = mStart[i]["interval"].u.integer;
|
||||||
|
str_copy(Monitors(ID)->m_aType, mStart[i]["type"].u.string.ptr, sizeof(Monitors(ID)->m_aType));
|
||||||
|
|
||||||
|
ID++;
|
||||||
|
}
|
||||||
|
str_copy(Monitors(ID)->m_aName, "NULL", sizeof(Monitors(ID)->m_aName));
|
||||||
|
} else
|
||||||
|
str_copy(Monitors(ID)->m_aName, "NULL", sizeof(Monitors(ID)->m_aName));
|
||||||
|
|
||||||
// if file exists, read last network traffic record,reset m_LastNetworkIN and m_LastNetworkOUT
|
// if file exists, read last network traffic record,reset m_LastNetworkIN and m_LastNetworkOUT
|
||||||
// support by: https://cpp.la
|
// support by: https://cpp.la
|
||||||
IOHANDLE nFile = io_open(m_Config.m_aJSONFile, IOFLAG_READ);
|
IOHANDLE nFile = io_open(m_Config.m_aJSONFile, IOFLAG_READ);
|
||||||
|
@ -77,7 +77,7 @@ class CMain
|
|||||||
int64_t m_IORead;
|
int64_t m_IORead;
|
||||||
int64_t m_IOWrite;
|
int64_t m_IOWrite;
|
||||||
double m_CPU;
|
double m_CPU;
|
||||||
char m_aCustom[512];
|
char m_aCustom[1024];
|
||||||
// Options
|
// Options
|
||||||
bool m_Pong;
|
bool m_Pong;
|
||||||
} m_Stats;
|
} m_Stats;
|
||||||
@ -90,6 +90,13 @@ class CMain
|
|||||||
char m_aCallback[1024];
|
char m_aCallback[1024];
|
||||||
} m_aCWatchDogs[NET_MAX_CLIENTS];
|
} m_aCWatchDogs[NET_MAX_CLIENTS];
|
||||||
|
|
||||||
|
struct CMonitors{
|
||||||
|
char m_aName[128];
|
||||||
|
char m_aHost[128];
|
||||||
|
int m_aInterval;
|
||||||
|
char m_aType[128];
|
||||||
|
} m_aCMonitors[NET_MAX_CLIENTS];
|
||||||
|
|
||||||
struct CJSONUpdateThreadData
|
struct CJSONUpdateThreadData
|
||||||
{
|
{
|
||||||
CClient *pClients;
|
CClient *pClients;
|
||||||
@ -108,6 +115,8 @@ public:
|
|||||||
int Run();
|
int Run();
|
||||||
|
|
||||||
CWatchDog *Watchdog(int ruleID) { return &m_aCWatchDogs[ruleID]; }
|
CWatchDog *Watchdog(int ruleID) { return &m_aCWatchDogs[ruleID]; }
|
||||||
|
CMonitors *Monitors(int ruleID) { return &m_aCMonitors[ruleID]; }
|
||||||
|
|
||||||
void WatchdogMessage(int ClientNetID,
|
void WatchdogMessage(int ClientNetID,
|
||||||
double load_1, double load_5, double load_15, double ping_10010, double ping_189, double ping_10086,
|
double load_1, double load_5, double load_15, double ping_10010, double ping_189, double ping_10086,
|
||||||
double time_10010, double time_189, double time_10086, double tcp_count, double udp_count, double process_count, double thread_count,
|
double time_10010, double time_189, double time_10086, double tcp_count, double udp_count, double process_count, double thread_count,
|
||||||
|
@ -23,48 +23,32 @@ tr.odd.expandRow > :hover { background: #212e36 !important; }
|
|||||||
#ping { max-width: 110px; }
|
#ping { max-width: 110px; }
|
||||||
|
|
||||||
@media only screen and (max-width: 1200px) {
|
@media only screen and (max-width: 1200px) {
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
#server {
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@media only screen and (max-width: 720px) {
|
@media only screen and (max-width: 720px) {
|
||||||
body { font-size: 10px; }
|
#server {
|
||||||
.content { padding: 0; }
|
body { font-size: 10px; }
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
.content { padding: 0; }
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@media only screen and (max-width: 620px) {
|
@media only screen and (max-width: 620px) {
|
||||||
body { font-size: 10px; }
|
#server {
|
||||||
.content { padding: 0; }
|
body { font-size: 10px; }
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
.content { padding: 0; }
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
||||||
}
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
@media only screen and (max-width: 533px) {
|
}
|
||||||
body { font-size: 10px; }
|
}
|
||||||
.content { padding: 0; }
|
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
|
||||||
}
|
|
||||||
@media only screen and (max-width: 450px) {
|
|
||||||
body { font-size: 10px; }
|
|
||||||
.content { padding: 0; }
|
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
|
||||||
#name, tr td:nth-child(3) { min-width: 55px; max-width: 85px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
|
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
|
||||||
#cpu, #ram, #hdd { min-width: 25px; max-width: 50px; }
|
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
|
||||||
}
|
|
@ -20,48 +20,32 @@ tr.odd.expandRow > :hover { background: #FFF !important; }
|
|||||||
#ping { max-width: 110px; }
|
#ping { max-width: 110px; }
|
||||||
|
|
||||||
@media only screen and (max-width: 1200px) {
|
@media only screen and (max-width: 1200px) {
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
#server {
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@media only screen and (max-width: 720px) {
|
@media only screen and (max-width: 720px) {
|
||||||
body { font-size: 10px; }
|
#server {
|
||||||
.content { padding: 0; }
|
body { font-size: 10px; }
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
.content { padding: 0; }
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@media only screen and (max-width: 620px) {
|
@media only screen and (max-width: 620px) {
|
||||||
body { font-size: 10px; }
|
#server {
|
||||||
.content { padding: 0; }
|
body { font-size: 10px; }
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
.content { padding: 0; }
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
||||||
}
|
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
||||||
@media only screen and (max-width: 533px) {
|
}
|
||||||
body { font-size: 10px; }
|
}
|
||||||
.content { padding: 0; }
|
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
|
||||||
}
|
|
||||||
@media only screen and (max-width: 450px) {
|
|
||||||
body { font-size: 10px; }
|
|
||||||
.content { padding: 0; }
|
|
||||||
#month_traffic, tr td:nth-child(2) { display:none; visibility:hidden; }
|
|
||||||
#name, tr td:nth-child(3) { min-width: 55px; max-width: 85px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
|
|
||||||
#type, tr td:nth-child(4) { display:none; visibility:hidden; }
|
|
||||||
#location, tr td:nth-child(5) { display:none; visibility:hidden; }
|
|
||||||
#uptime, tr td:nth-child(6) { display:none; visibility:hidden; }
|
|
||||||
#traffic, tr td:nth-child(9) { display:none; visibility:hidden; }
|
|
||||||
#cpu, #ram, #hdd { min-width: 25px; max-width: 50px; }
|
|
||||||
#ping, tr td:nth-child(13) { display:none; visibility:hidden; }
|
|
||||||
}
|
|
@ -47,6 +47,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="navbar-collapse collapse">
|
<div class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="dropdown">
|
||||||
|
<a data-toggle="tab" class="dropdown-toggle" href="#server">首页</a>
|
||||||
|
</li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a data-toggle="tab" class="dropdown-toggle" href="#monitor">服务</a>
|
||||||
|
</li>
|
||||||
<li class="dropdown">
|
<li class="dropdown">
|
||||||
<a data-toggle="dropdown" class="dropdown-toggle" href="#">风格<b class="caret"></b></a>
|
<a data-toggle="dropdown" class="dropdown-toggle" href="#">风格<b class="caret"></b></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
@ -73,28 +79,51 @@
|
|||||||
</div>
|
</div>
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-striped table-condensed table-hover">
|
|
||||||
<thead>
|
<div class="tab-content">
|
||||||
<tr>
|
<div class="tab-pane fade in active" id="server">
|
||||||
<th id="online_status" style="text-align: center;">🔗协议</th>
|
<!--主机-->
|
||||||
<th id="month_traffic" style="text-align: center;">📊月流量↓|↑</th>
|
<table class="table table-striped table-condensed table-hover">
|
||||||
<th id="name">📌节点</th>
|
<thead>
|
||||||
<th id="type">🗂️虚拟化</th>
|
<tr>
|
||||||
<th id="location">🌍位置</th>
|
<th id="online_status" style="text-align: center;">🔗协议</th>
|
||||||
<th id="uptime">⏱️在线</th>
|
<th id="month_traffic" style="text-align: center;">📊月流量↓|↑</th>
|
||||||
<th id="load">负载</th>
|
<th id="name">📌节点</th>
|
||||||
<th id="network">🚦网络↓|↑</th>
|
<th id="type">🗂️虚拟化</th>
|
||||||
<th id="traffic">📋总流量↓|↑</th>
|
<th id="location">🌍位置</th>
|
||||||
<th id="cpu">🎯核芯</th>
|
<th id="uptime">⏱️在线</th>
|
||||||
<th id="ram">⚡️内存</th>
|
<th id="load">负载</th>
|
||||||
<th id="hdd">💾硬盘</th>
|
<th id="network">🚦网络↓|↑</th>
|
||||||
<th id="ping">🌐CU|CT|CM</th>
|
<th id="traffic">📋总流量↓|↑</th>
|
||||||
</tr>
|
<th id="cpu">🎯核芯</th>
|
||||||
</thead>
|
<th id="ram">⚡️内存</th>
|
||||||
<tbody id="servers">
|
<th id="hdd">💾硬盘</th>
|
||||||
<!-- Servers here \o/ -->
|
<th id="ping">🌐CU|CT|CM</th>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
</thead>
|
||||||
|
<tbody id="servers">
|
||||||
|
<!-- Servers here \o/ -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane fade" id="monitor">
|
||||||
|
<!--服务-->
|
||||||
|
<table class="table table-striped table-condensed table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th id="monitor_status" style="text-align: center;">🔗协议</th>
|
||||||
|
<th id="monitor_node">📌监测节点</th>
|
||||||
|
<th id="monitor_location">🌍监测位置</th>
|
||||||
|
<th id="monitor_text" style="text-align: center;">📋监测内容</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="monitors">
|
||||||
|
<!-- Monitors here \o/ -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<div id="updated">Updating...</div>
|
<div id="updated">Updating...</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,6 +57,7 @@ function uptime() {
|
|||||||
|
|
||||||
for (var i = 0, rlen=result.servers.length; i < rlen; i++) {
|
for (var i = 0, rlen=result.servers.length; i < rlen; i++) {
|
||||||
var TableRow = $("#servers tr#r" + i);
|
var TableRow = $("#servers tr#r" + i);
|
||||||
|
var MableRow = $("#monitors tr#r" + i);
|
||||||
var ExpandRow = $("#servers #rt" + i);
|
var ExpandRow = $("#servers #rt" + i);
|
||||||
var hack; // fuck CSS for making me do this
|
var hack; // fuck CSS for making me do this
|
||||||
if(i%2) hack="odd"; else hack="even";
|
if(i%2) hack="odd"; else hack="even";
|
||||||
@ -82,16 +83,28 @@ function uptime() {
|
|||||||
"<div id=\"expand_hdd\">加载中</div>" +
|
"<div id=\"expand_hdd\">加载中</div>" +
|
||||||
"<div id=\"expand_tupd\">加载中</div>" +
|
"<div id=\"expand_tupd\">加载中</div>" +
|
||||||
"<div id=\"expand_ping\">加载中</div>" +
|
"<div id=\"expand_ping\">加载中</div>" +
|
||||||
"<div id=\"expand_custom\">加载中</div>" +
|
|
||||||
"</div></td></tr>"
|
"</div></td></tr>"
|
||||||
);
|
);
|
||||||
TableRow = $("#servers tr#r" + i);
|
TableRow = $("#servers tr#r" + i);
|
||||||
ExpandRow = $("#servers #rt" + i);
|
ExpandRow = $("#servers #rt" + i);
|
||||||
server_status[i] = true;
|
server_status[i] = true;
|
||||||
}
|
}
|
||||||
|
if (!MableRow.length) {
|
||||||
|
$("#monitors").append(
|
||||||
|
"<tr id=\"r" + i + "\" data-toggle=\"collapse\" data-target=\"#rt" + i + "\" class=\"accordion-toggle " + hack + "\">" +
|
||||||
|
"<td id=\"monitor_status\"><div class=\"progress\"><div style=\"width: 100%;\" class=\"progress-bar progress-bar-warning\"><small>加载中</small></div></div></td>" +
|
||||||
|
"<td id=\"monitor_node\">加载中</td>" +
|
||||||
|
"<td id=\"monitor_location\">加载中</td>" +
|
||||||
|
"<td id=\"monitor_text\">加载中</td>" +
|
||||||
|
"</tr>"
|
||||||
|
);
|
||||||
|
MableRow = $("#monitors tr#r" + i);
|
||||||
|
}
|
||||||
TableRow = TableRow[0];
|
TableRow = TableRow[0];
|
||||||
|
MableRow = MableRow[0];
|
||||||
if(error) {
|
if(error) {
|
||||||
TableRow.setAttribute("data-target", "#rt" + i);
|
TableRow.setAttribute("data-target", "#rt" + i);
|
||||||
|
MableRow.setAttribute("data-target", "#rt" + i);
|
||||||
server_status[i] = true;
|
server_status[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,25 +112,35 @@ function uptime() {
|
|||||||
if (result.servers[i].online4 && !result.servers[i].online6) {
|
if (result.servers[i].online4 && !result.servers[i].online6) {
|
||||||
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>IPv4</small>";
|
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>IPv4</small>";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].innerHTML = "<small>IPv4</small>";
|
||||||
} else if (result.servers[i].online4 && result.servers[i].online6) {
|
} else if (result.servers[i].online4 && result.servers[i].online6) {
|
||||||
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>双栈</small>";
|
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>双栈</small>";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].innerHTML = "<small>双栈</small>";
|
||||||
} else if (!result.servers[i].online4 && result.servers[i].online6) {
|
} else if (!result.servers[i].online4 && result.servers[i].online6) {
|
||||||
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>IPv6</small>";
|
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>IPv6</small>";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].innerHTML = "<small>IPv6</small>";
|
||||||
} else {
|
} else {
|
||||||
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
||||||
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>关闭</small>";
|
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>关闭</small>";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].innerHTML = "<small>关闭</small>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
TableRow.children["name"].innerHTML = result.servers[i].name;
|
TableRow.children["name"].innerHTML = result.servers[i].name;
|
||||||
|
MableRow.children["monitor_node"].innerHTML = result.servers[i].name;
|
||||||
|
|
||||||
// Type
|
// Type
|
||||||
TableRow.children["type"].innerHTML = result.servers[i].type;
|
TableRow.children["type"].innerHTML = result.servers[i].type;
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
TableRow.children["location"].innerHTML = result.servers[i].location;
|
TableRow.children["location"].innerHTML = result.servers[i].location;
|
||||||
|
MableRow.children["monitor_location"].innerHTML = result.servers[i].location;
|
||||||
if (!result.servers[i].online4 && !result.servers[i].online6) {
|
if (!result.servers[i].online4 && !result.servers[i].online6) {
|
||||||
if (server_status[i]) {
|
if (server_status[i]) {
|
||||||
TableRow.children["uptime"].innerHTML = "–";
|
TableRow.children["uptime"].innerHTML = "–";
|
||||||
@ -138,15 +161,18 @@ function uptime() {
|
|||||||
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-danger";
|
||||||
TableRow.children["ping"].children[0].children[0].style.width = "100%";
|
TableRow.children["ping"].children[0].children[0].style.width = "100%";
|
||||||
TableRow.children["ping"].children[0].children[0].innerHTML = "<small>关闭</small>";
|
TableRow.children["ping"].children[0].children[0].innerHTML = "<small>关闭</small>";
|
||||||
|
MableRow.children["monitor_text"].innerHTML = "-";
|
||||||
if(ExpandRow.hasClass("in")) {
|
if(ExpandRow.hasClass("in")) {
|
||||||
ExpandRow.collapse("hide");
|
ExpandRow.collapse("hide");
|
||||||
}
|
}
|
||||||
TableRow.setAttribute("data-target", "");
|
TableRow.setAttribute("data-target", "");
|
||||||
|
MableRow.setAttribute("data-target", "");
|
||||||
server_status[i] = false;
|
server_status[i] = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!server_status[i]) {
|
if (!server_status[i]) {
|
||||||
TableRow.setAttribute("data-target", "#rt" + i);
|
TableRow.setAttribute("data-target", "#rt" + i);
|
||||||
|
MableRow.setAttribute("data-target", "#rt" + i);
|
||||||
server_status[i] = true;
|
server_status[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,12 +297,8 @@ function uptime() {
|
|||||||
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-success";
|
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-success";
|
||||||
TableRow.children["ping"].children[0].children[0].innerHTML = PING_10010 + "%💻" + PING_189 + "%💻" + PING_10086 + "%";
|
TableRow.children["ping"].children[0].children[0].innerHTML = PING_10010 + "%💻" + PING_189 + "%💻" + PING_10086 + "%";
|
||||||
|
|
||||||
// Custom
|
// monitor
|
||||||
if (result.servers[i].custom) {
|
MableRow.children["monitor_text"].innerHTML = result.servers[i].custom;
|
||||||
ExpandRow[0].children["expand_custom"].innerHTML = result.servers[i].custom
|
|
||||||
} else {
|
|
||||||
ExpandRow[0].children["expand_custom"].innerHTML = ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -286,9 +308,12 @@ function uptime() {
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
$("#servers > tr.accordion-toggle").each(function(i) {
|
$("#servers > tr.accordion-toggle").each(function(i) {
|
||||||
var TableRow = $("#servers tr#r" + i)[0];
|
var TableRow = $("#servers tr#r" + i)[0];
|
||||||
|
var MableRow = $("#monitors tr#r" + i)[0];
|
||||||
var ExpandRow = $("#servers #rt" + i);
|
var ExpandRow = $("#servers #rt" + i);
|
||||||
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-error";
|
TableRow.children["online_status"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>错误</small>";
|
TableRow.children["online_status"].children[0].children[0].innerHTML = "<small>错误</small>";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
|
MableRow.children["monitor_status"].children[0].children[0].innerHTML = "<small>错误</small>";
|
||||||
TableRow.children["month_traffic"].children[0].children[0].className = "progress-bar progress-bar-error";
|
TableRow.children["month_traffic"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
TableRow.children["month_traffic"].children[0].children[0].innerHTML = "<small>错误</small>";
|
TableRow.children["month_traffic"].children[0].children[0].innerHTML = "<small>错误</small>";
|
||||||
TableRow.children["uptime"].children[0].children[0].className = "progress-bar progress-bar-error";
|
TableRow.children["uptime"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
@ -311,10 +336,13 @@ function uptime() {
|
|||||||
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-error";
|
TableRow.children["ping"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
TableRow.children["ping"].children[0].children[0].style.width = "100%";
|
TableRow.children["ping"].children[0].children[0].style.width = "100%";
|
||||||
TableRow.children["ping"].children[0].children[0].innerHTML = "<small>错误</small>";
|
TableRow.children["ping"].children[0].children[0].innerHTML = "<small>错误</small>";
|
||||||
|
MableRow.children["monitor_text"].children[0].children[0].className = "progress-bar progress-bar-error";
|
||||||
|
MableRow.children["monitor_text"].children[0].children[0].innerHTML = "<small>错误</small>";
|
||||||
if(ExpandRow.hasClass("in")) {
|
if(ExpandRow.hasClass("in")) {
|
||||||
ExpandRow.collapse("hide");
|
ExpandRow.collapse("hide");
|
||||||
}
|
}
|
||||||
TableRow.setAttribute("data-target", "");
|
TableRow.setAttribute("data-target", "");
|
||||||
|
MableRow.setAttribute("data-target", "");
|
||||||
server_status[i] = false;
|
server_status[i] = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user