Add container health status, multi-volume storage, auto-refresh Overview

This commit is contained in:
Gan, Jimmy
2026-02-22 17:11:17 +08:00
parent ae98811c23
commit 8797231f53
3 changed files with 38 additions and 16 deletions
@@ -13,6 +13,7 @@ def list_containers():
"id": c.short_id,
"name": c.name,
"status": c.status,
"health": (c.attrs.get("State", {}).get("Health", {}) or {}).get("Status", ""),
"image": c.image.tags[0] if c.image.tags else str(c.image.id)[:20],
"ports": c.ports,
}
+9
View File
@@ -28,6 +28,14 @@ async def send_notification(body: dict):
@router.get("/stats")
def system_stats():
disk = shutil.disk_usage("/volume1")
volumes = []
for mount in psutil.disk_partitions():
if mount.mountpoint.startswith(("/volume",)):
try:
u = shutil.disk_usage(mount.mountpoint)
volumes.append({"mount": mount.mountpoint, "total": u.total, "used": u.used, "free": u.free, "percent": round(u.used / u.total * 100, 1)})
except Exception:
pass
mem = psutil.virtual_memory()
cpu_pct = psutil.cpu_percent(interval=0.5)
load_1, load_5, load_15 = psutil.getloadavg()
@@ -53,6 +61,7 @@ def system_stats():
},
"uptime": f"{days}d {hours}h",
"platform": platform.platform(),
"volumes": volumes,
}