mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add realtime storage updates
This commit is contained in:
parent
f824ca2959
commit
a6d1f7b62c
@ -4,6 +4,7 @@ import logging
|
||||
import threading
|
||||
import asyncio
|
||||
import datetime
|
||||
import json
|
||||
|
||||
from tzlocal import get_localzone
|
||||
from tzlocal.utils import ZoneInfoNotFoundError
|
||||
@ -687,18 +688,36 @@ class TasksManager:
|
||||
host_stats = HelpersManagement.get_latest_hosts_stats()
|
||||
if len(self.helper.websocket_helper.clients) > 0:
|
||||
# There are clients
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard",
|
||||
"update_host_stats",
|
||||
{
|
||||
"cpu_usage": host_stats.get("cpu_usage"),
|
||||
"cpu_cores": host_stats.get("cpu_cores"),
|
||||
"cpu_cur_freq": host_stats.get("cpu_cur_freq"),
|
||||
"cpu_max_freq": host_stats.get("cpu_max_freq"),
|
||||
"mem_percent": host_stats.get("mem_percent"),
|
||||
"mem_usage": host_stats.get("mem_usage"),
|
||||
},
|
||||
)
|
||||
try:
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard",
|
||||
"update_host_stats",
|
||||
{
|
||||
"cpu_usage": host_stats.get("cpu_usage"),
|
||||
"cpu_cores": host_stats.get("cpu_cores"),
|
||||
"cpu_cur_freq": host_stats.get("cpu_cur_freq"),
|
||||
"cpu_max_freq": host_stats.get("cpu_max_freq"),
|
||||
"mem_percent": host_stats.get("mem_percent"),
|
||||
"mem_usage": host_stats.get("mem_usage"),
|
||||
"disk_usage": json.loads(
|
||||
host_stats.get("disk_json").replace("'", '"')
|
||||
),
|
||||
},
|
||||
)
|
||||
except:
|
||||
self.helper.websocket_helper.broadcast_page(
|
||||
"/panel/dashboard",
|
||||
"update_host_stats",
|
||||
{
|
||||
"cpu_usage": host_stats.get("cpu_usage"),
|
||||
"cpu_cores": host_stats.get("cpu_cores"),
|
||||
"cpu_cur_freq": host_stats.get("cpu_cur_freq"),
|
||||
"cpu_max_freq": host_stats.get("cpu_max_freq"),
|
||||
"mem_percent": host_stats.get("mem_percent"),
|
||||
"mem_usage": host_stats.get("mem_usage"),
|
||||
"disk_usage": {},
|
||||
},
|
||||
)
|
||||
time.sleep(1)
|
||||
|
||||
def check_for_updates(self):
|
||||
|
Loading…
Reference in New Issue
Block a user