From 5fbc5cc335a985dd6eb47d72e54907f7e53d43c4 Mon Sep 17 00:00:00 2001
From: starlight-apk
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
psutil not available
" + + cpu = stats.get("cpu", {}) + mem = stats.get("memory", {}) + disk = stats.get("disk", {}) + net = stats.get("network", {}) + procs = stats.get("processes", {}) + uptime = stats.get("uptime", 0) + + # 格式化时间 + days, rem = divmod(uptime, 86400) + hours, rem = divmod(rem, 3600) + mins = rem // 60 + uptime_str = f"{int(days)}天 {int(hours)}时 {int(mins)}分" + + def bar(pct, color="primary"): + color_map = { + "primary": "#0d6efd", "success": "#198754", + "warning": "#ffc107", "danger": "#dc3545", + } + c = color_map.get(color, color_map["primary"]) + return f'' + + def mem_fmt(b): + for unit in ["B", "KB", "MB", "GB", "TB"]: + if b < 1024: + return f"{b:.1f} {unit}" + b /= 1024 + return f"{b:.1f} PB" + + # 进程TOP表格行 + proc_rows = "" + for p in procs.get("top", []): + proc_rows += f"v{VERSION} · 运行时间 {uptime_str} · 进程 {procs.get('total', '?')} 个
+ + + +| PID | 名称 | CPU | 内存 | 状态 |
|---|
+ 数据采集间隔 5秒 · 保留最近 {MAX_HISTORY} 条 +
+