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).
Structsยง
- NetState ๐
- Network I/O tracking state for rate calculations.
Constantsยง
- BYTES_
PER_ ๐GB - BYTES_
PER_ ๐MB - DEFAULT_
INTERVAL_ ๐SECS - DISK_
FULL_ ๐REFRESH - How often the disk list and each volumeโs capacity/free space are re-read. Every tick only refreshes I/O counters (the read/write rates need a delta per tick). A full refresh re-lists every mounted volume and, on macOS, asks each for its โavailable for important usageโ capacity, which goes through CacheDelete: with a few DMGs mounted that was thousands of system calls and log lines a minute, for numbers that move slowly.
- HOLDER_
BADGES ๐ - HOLDER_
JANITOR ๐ - HOLDER_
TELEMETRY ๐ - MAX_
INTERVAL_ ๐SECS - MIN_
INTERVAL_ ๐SECS - NEVER_
STRETCHED ๐ - A budget no run exceeds: the source keeps its interval whatever a run costs.
- PANE_
JANITOR_ ๐MS - How often the panesโ processes are scanned with no badge watching: enough to evict a pane whose shell exited without normal cleanup.
- PERSIST_
COUNT ๐ - SCHEDULER_
COALESCE_ ๐MS - Sources due within this much of each other run in one pass.
Staticsยง
- PROCESS_
START_ ๐MS - Baseline reading of
suspend_aware_now_mscaptured at process start bymark_process_start(main.rs).
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. - get_
commit_ ๐data - Read the Windows commit budget via
GlobalMemoryStatusEx. Emitsmem:commit:usedandmem:commit:total(in GB). No-op on non-Windows โ keys are simply absent from the payload. - get_
cpu_ ๐data - Collect CPU usage (total + per-core).
- get_
disk_ ๐data - Collect disk I/O rates (in MB/s). sysinfo Disk::usage() returns deltas (bytes since last refresh) so we divide by elapsed time to get rates.
- get_
interval_ ๐secs - Read the telemetry interval from config, clamped to [MIN, MAX].
- get_
mem_ ๐data - Collect memory metrics (in GB).
- get_
pagefile_ ๐volume_ data - Windows watch volume: the drive backing the page file. Emits the
platform-neutral
disk:watch:free_gb/:total_gb/:free_pct, plusdisk:pagefile_system_managed(1.0/0.0), which stays Windows-named because it is a page-file fact and its ABSENCE is what tells the status bar it is not on Windows (see the colour tri-state in SPEC_STATUSBAR_DISK_PILL_CROSS_PLATFORM_2026_09_18 ยง3.3). - get_
watch_ ๐volume_ data - Unix watch volume: the mount backing AgentMuxโs data dir โ where the store, logs and packaged builds land, so it is the volume whose filling up actually breaks this app.
- 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.
- pick_
watch_ ๐mount - Pick the mount whose path is the longest prefix of
target. - run_
sysinfo_ loop - Run the sysinfo collection loop. Uses
tokio::time::intervalfor steady tick rate regardless of refresh duration. Interval is re-read from config each tick and the timer is reset if it changes. - suspend_
aware_ ๐now_ ms - 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. - write_
watch_ ๐summary - Summarise one already-collected volume as the watch target.