feat: add system load average, uptime, and process count to dashboard with responsive detail cards and iconify indicators

Add os.getloadavg() to system_metrics() with (0,0,0) fallback for AttributeError/OSError. Add /proc/uptime parsing for uptime_seconds with float conversion and 0 fallback. Add /proc process counting by iterating numeric entries with OSError exception handling. Add load/uptime_seconds/processes fields to /api/system response with rounded values.

Add DOMContentLoaded script to inject #
This commit is contained in:
2026-08-16 12:32:08 +02:00
parent c15cc17142
commit cc7d719465
2 changed files with 15 additions and 1 deletions
+13 -1
View File
@@ -491,7 +491,19 @@ def system_metrics():
disks.append({"label": label, "path": path, "total": format_bytes(usage.total), "used": format_bytes(usage.used), "free": format_bytes(usage.free), "used_bytes": usage.used, "total_bytes": usage.total, "percent": round(usage.used / usage.total * 100, 1) if usage.total else 0})
except OSError:
continue
return {"cpu_percent": cpu_usage_percent(), "memory": {"used": format_bytes(used_memory), "total": format_bytes(total_memory), "percent": round(used_memory / total_memory * 100, 1) if total_memory else 0}, "disks": disks, "timestamp": time.time()}
try:
load = os.getloadavg()
except (AttributeError, OSError):
load = (0, 0, 0)
try:
uptime_seconds = float(Path("/proc/uptime").read_text().split()[0])
except (OSError, ValueError, IndexError):
uptime_seconds = 0
try:
process_count = sum(1 for entry in Path("/proc").iterdir() if entry.name.isdigit())
except OSError:
process_count = 0
return {"cpu_percent": cpu_usage_percent(), "memory": {"used": format_bytes(used_memory), "total": format_bytes(total_memory), "percent": round(used_memory / total_memory * 100, 1) if total_memory else 0}, "disks": disks, "load": [round(value, 2) for value in load], "uptime_seconds": round(uptime_seconds), "processes": process_count, "timestamp": time.time()}
def release_languages(name):
value = f" {name.lower().replace('.', ' ').replace('-', ' ')} "