Expand description
Sysinfo data collection loop: collects CPU, memory, and network metrics
and publishes them via the WPS 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 - MAX_
INTERVAL_ ๐SECS - MIN_
INTERVAL_ ๐SECS - PERSIST_
COUNT ๐
Functionsยง
- 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).
- 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.