mirror of
https://github.com//cppla/ServerStatus
synced 2025-07-05 00:45:59 +08:00
fix bug
This commit is contained in:
parent
8dfc6d4718
commit
eddf37c413
@ -324,13 +324,7 @@ def _monitor_thread(name, host, interval, type):
|
|||||||
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
|
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
|
||||||
while True:
|
while True:
|
||||||
if name not in monitorServer.keys():
|
if name not in monitorServer.keys():
|
||||||
monitorServer[name] = {
|
break
|
||||||
"type": type,
|
|
||||||
"dns_time": 0,
|
|
||||||
"connect_time": 0,
|
|
||||||
"download_time": 0,
|
|
||||||
"online_rate": 1
|
|
||||||
}
|
|
||||||
if packet_queue.full():
|
if packet_queue.full():
|
||||||
if packet_queue.get() == 0:
|
if packet_queue.get() == 0:
|
||||||
lostPacket -= 1
|
lostPacket -= 1
|
||||||
@ -459,6 +453,13 @@ if __name__ == '__main__':
|
|||||||
for i in data.split('\n'):
|
for i in data.split('\n'):
|
||||||
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
||||||
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
||||||
|
monitorServer[jdata.get("name")] = {
|
||||||
|
"type": jdata.get("type"),
|
||||||
|
"dns_time": 0,
|
||||||
|
"connect_time": 0,
|
||||||
|
"download_time": 0,
|
||||||
|
"online_rate": 1
|
||||||
|
}
|
||||||
t = threading.Thread(
|
t = threading.Thread(
|
||||||
target=_monitor_thread,
|
target=_monitor_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
@ -524,11 +525,13 @@ if __name__ == '__main__':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
monitorServer.clear()
|
||||||
print("Disconnected...")
|
print("Disconnected...")
|
||||||
if 's' in locals().keys():
|
if 's' in locals().keys():
|
||||||
del s
|
del s
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
monitorServer.clear()
|
||||||
print("Caught Exception:", e)
|
print("Caught Exception:", e)
|
||||||
if 's' in locals().keys():
|
if 's' in locals().keys():
|
||||||
del s
|
del s
|
||||||
|
@ -312,13 +312,7 @@ def _monitor_thread(name, host, interval, type):
|
|||||||
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
|
packet_queue = Queue(maxsize=ONLINE_PACKET_HISTORY_LEN)
|
||||||
while True:
|
while True:
|
||||||
if name not in monitorServer.keys():
|
if name not in monitorServer.keys():
|
||||||
monitorServer[name] = {
|
break
|
||||||
"type": type,
|
|
||||||
"dns_time": 0,
|
|
||||||
"connect_time": 0,
|
|
||||||
"download_time": 0,
|
|
||||||
"online_rate": 1
|
|
||||||
}
|
|
||||||
if packet_queue.full():
|
if packet_queue.full():
|
||||||
if packet_queue.get() == 0:
|
if packet_queue.get() == 0:
|
||||||
lostPacket -= 1
|
lostPacket -= 1
|
||||||
@ -444,10 +438,16 @@ 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)
|
||||||
monitorServer.clear()
|
|
||||||
for i in data.split('\n'):
|
for i in data.split('\n'):
|
||||||
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
if "monitor" in i and "type" in i and "{" in i and "}" in i:
|
||||||
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
jdata = json.loads(i[i.find("{"):i.find("}")+1])
|
||||||
|
monitorServer[jdata.get("name")] = {
|
||||||
|
"type": jdata.get("type"),
|
||||||
|
"dns_time": 0,
|
||||||
|
"connect_time": 0,
|
||||||
|
"download_time": 0,
|
||||||
|
"online_rate": 1
|
||||||
|
}
|
||||||
t = threading.Thread(
|
t = threading.Thread(
|
||||||
target=_monitor_thread,
|
target=_monitor_thread,
|
||||||
kwargs={
|
kwargs={
|
||||||
@ -514,11 +514,13 @@ if __name__ == '__main__':
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except socket.error:
|
except socket.error:
|
||||||
|
monitorServer.clear()
|
||||||
print("Disconnected...")
|
print("Disconnected...")
|
||||||
if 's' in locals().keys():
|
if 's' in locals().keys():
|
||||||
del s
|
del s
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
monitorServer.clear()
|
||||||
print("Caught Exception:", e)
|
print("Caught Exception:", e)
|
||||||
if 's' in locals().keys():
|
if 's' in locals().keys():
|
||||||
del s
|
del s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user