Skip to main content

Module sysinfo

Module sysinfo 

Source
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). Returns None where there’s no cheap commit figure (non-Windows) or the read fails — callers treat None as “no limit / admit”. This is the admission-control signal for Pillar 3 (commit-aware agent spawn): see agents::runner::admit_spawn and SPEC_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 stop is 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_sub makes a decrease structurally impossible even if a platform counter ever misbehaved.