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).

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_ms captured at process start by mark_process_start (main.rs).

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.
get_commit_data ๐Ÿ”’
Read the Windows commit budget via GlobalMemoryStatusEx. Emits mem:commit:used and mem: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, plus disk: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::interval for 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_sub makes a decrease structurally impossible even if a platform counter ever misbehaved.
write_watch_summary ๐Ÿ”’
Summarise one already-collected volume as the watch target.