Dashboard UI overhaul: modern design with system stats, SVG icons, Inter font, theme toggle, loading states, and log modal
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import shutil
|
||||
import psutil
|
||||
import platform
|
||||
import time
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/stats")
|
||||
def system_stats():
|
||||
disk = shutil.disk_usage("/volume1")
|
||||
mem = psutil.virtual_memory()
|
||||
cpu_pct = psutil.cpu_percent(interval=0.5)
|
||||
load_1, load_5, load_15 = psutil.getloadavg()
|
||||
uptime_s = time.time() - psutil.boot_time()
|
||||
|
||||
days = int(uptime_s // 86400)
|
||||
hours = int((uptime_s % 86400) // 3600)
|
||||
|
||||
return {
|
||||
"cpu_percent": cpu_pct,
|
||||
"cpu_count": psutil.cpu_count(),
|
||||
"load_avg": [round(load_1, 2), round(load_5, 2), round(load_15, 2)],
|
||||
"memory": {
|
||||
"total": mem.total,
|
||||
"used": mem.used,
|
||||
"percent": mem.percent,
|
||||
},
|
||||
"disk": {
|
||||
"total": disk.total,
|
||||
"used": disk.used,
|
||||
"free": disk.free,
|
||||
"percent": round(disk.used / disk.total * 100, 1),
|
||||
},
|
||||
"uptime": f"{days}d {hours}h",
|
||||
"platform": platform.platform(),
|
||||
}
|
||||
Reference in New Issue
Block a user