feat(daemon): sample host cpu, memory and disk for /info and /resources
The status page had no host figures: `/api/v1/info` only carried identity and `/api/v1/resources` only carried instance RSS, so the CPU/mem/disk tiles fell back to "—" and the memory tile faked its percentage from RSS over physical memory. src/core/sysinfo.ts is a zero-dependency sampler: CPU from the /proc/stat delta (null on the first read, since it needs two samples), load average from os.loadavg(), memory from os.freemem/os.totalmem, and disk via statfs on the daemon's state dir. One sample is cached for ~1 s and shared between /info and /resources, so polling both does not double the syscalls. /info gains additive `cpu`, `mem`, `disk` percentages plus `cpuCores` and `loadAvg`; /resources gains a `system` object with the byte counts, the disk path and `sampledAt`. Every field is optional on the client side: an older daemon simply omits them.
This commit is contained in:
1 parent
1664227c3b
commit
88354ec078
7 files changed
+492
-5
No files matched your search
@@ -102,6 +102,7 @@ export async function startServer(config: Config, deps: ServerDeps): Promise<Sta
|
||||
startedAt: deps.startedAt,
|
||||
now: deps.now,
|
||||
metrics: () => ({ connections: ws.connections(), eventsSent: ws.eventsSent() }),
|
||||
sysinfo: deps.sysinfo,
|
||||
});
|
||||
|
||||
let closing: Promise<void> | undefined;
|
||||
|
||||
Reference in new issue
Block a user