feat: expand livestream management platform

This commit is contained in:
admin committed 2026-08-19 22:24:01 +08:00
1 parent 383c066d86
commit ed62d42a63
12 files changed
+223 -24

No files matched your search

+15
View File
@@ -105,6 +105,17 @@ async def get_system_metrics(_: bool = Depends(require_auth)):
disk_path = metrics_path if metrics_path.exists() else Path.cwd()
disk = shutil.disk_usage(disk_path)
cpu_count = os.cpu_count() or 1
network_in_bytes = 0
network_out_bytes = 0
netdev = Path("/proc/net/dev")
if netdev.exists():
for line in netdev.read_text(encoding="ascii").splitlines()[2:]:
_, _, counters = line.partition(":")
fields = counters.split()
if len(fields) >= 9:
network_in_bytes += int(fields[0])
network_out_bytes += int(fields[8])
return {
"cpu": {
"count": cpu_count,
@@ -123,4 +134,8 @@ async def get_system_metrics(_: bool = Depends(require_auth)):
"free": disk.free,
"used_percent": round(disk.used / disk.total * 100, 1) if disk.total else 0,
},
"network": {
"bytes_recv": network_in_bytes,
"bytes_sent": network_out_bytes,
},
}