Module sysinfo

Module sysinfo 

Source
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::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.