proc_stats: report websocket connection count

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2021-09-21 14:19:01 -04:00
parent 46a8723566
commit d6fafef902
1 changed files with 6 additions and 2 deletions

View File

@ -94,11 +94,13 @@ class ProcStats:
ts = await self._check_throttled_state() ts = await self._check_throttled_state()
cpu_temp = await self.event_loop.run_in_thread( cpu_temp = await self.event_loop.run_in_thread(
self._get_cpu_temperature) self._get_cpu_temperature)
websocket_count = self.server.get_websocket_manager().get_count()
return { return {
'moonraker_stats': list(self.proc_stat_queue), 'moonraker_stats': list(self.proc_stat_queue),
'throttled_state': ts, 'throttled_state': ts,
'cpu_temp': cpu_temp, 'cpu_temp': cpu_temp,
'network': self.last_net_stats 'network': self.last_net_stats,
'websocket_connections': websocket_count
} }
async def _handle_shutdown(self) -> None: async def _handle_shutdown(self) -> None:
@ -137,10 +139,12 @@ class ProcStats:
'mem_units': mem_units 'mem_units': mem_units
} }
self.proc_stat_queue.append(result) self.proc_stat_queue.append(result)
websocket_count = self.server.get_websocket_manager().get_count()
self.server.send_event("proc_stats:proc_stat_update", { self.server.send_event("proc_stats:proc_stat_update", {
'moonraker_stats': result, 'moonraker_stats': result,
'cpu_temp': cpu_temp, 'cpu_temp': cpu_temp,
'network': net 'network': net,
'websocket_connections': websocket_count
}) })
self.last_update_time = update_time self.last_update_time = update_time
self.last_proc_time = proc_time self.last_proc_time = proc_time