Expand description
Sysinfo data collection loop: collects CPU, memory, and network metrics
and publishes them via the MPS broker. Sampling interval is configurable
via the telemetry:interval setting (0.1s–2.0s, default 1.0s).
Constants§
- SAMPLE_
WINDOW_ KEY - The sample’s key for the milliseconds its rates average over (the chart reads it).
Functions§
- available_
commit_ gb - Available system commit headroom in GB (Windows:
GlobalMemoryStatusEx→ullAvailPageFile). ReturnsNonewhere there’s no cheap commit figure (non-Windows) or the read fails — callers treatNoneas “no limit / admit”. This is the admission-control signal for Pillar 3 (commit-aware agent spawn): seeagents::runner::admit_spawnandSPEC_WIN10_PAGEFILE_OOM_CRASH. - mark_
process_ start - Record this process’s start for uptime reporting. Idempotent; the first call wins, so a stray second call can’t restart the clock.
- run_
sysinfo_ loop - Run the sysinfo collection loop until
stopis set. It must run on a runtime of its own (sampler::thread), not srv’s: every read below blocks its thread, and a sampler that waits for a free worker in the runtime it measures is late exactly when the machine is busiest. The interval is re-read from config each tick. - uptime_
secs - Seconds since
mark_process_start. Falls back to initializing on first read, so a caller that never marked startup reports a truthful (if late-based) 0 rather than a wrong number or a panic.saturating_submakes a decrease structurally impossible even if a platform counter ever misbehaved.