mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Only collect server stats when clients
This commit is contained in:
parent
a96753d3a7
commit
23b3e642a0
@ -1223,6 +1223,9 @@ class ServerInstance:
|
||||
# **********************************************************************************
|
||||
|
||||
def realtime_stats(self):
|
||||
# only get stats if clients are connected.
|
||||
# no point in burning cpu
|
||||
if len(self.helper.websocket_helper.clients) > 0:
|
||||
total_players = 0
|
||||
max_players = 0
|
||||
servers_ping = []
|
||||
@ -1276,7 +1279,9 @@ class ServerInstance:
|
||||
"version": raw_ping_result.get("version"),
|
||||
"icon": raw_ping_result.get("icon"),
|
||||
"crashed": self.is_crashed,
|
||||
"created": datetime.datetime.now().strftime("%Y/%m/%d, %H:%M:%S"),
|
||||
"created": datetime.datetime.now().strftime(
|
||||
"%Y/%m/%d, %H:%M:%S"
|
||||
),
|
||||
},
|
||||
)
|
||||
total_players += int(raw_ping_result.get("online"))
|
||||
@ -1284,7 +1289,9 @@ class ServerInstance:
|
||||
|
||||
self.record_server_stats()
|
||||
|
||||
if (len(servers_ping) > 0) & (len(self.helper.websocket_helper.clients) > 0):
|
||||
if (len(servers_ping) > 0) & (
|
||||
len(self.helper.websocket_helper.clients) > 0
|
||||
):
|
||||
try:
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard", "update_server_status", servers_ping
|
||||
|
Loading…
Reference in New Issue
Block a user