Skip to main content

Module metrics

Module metrics 

Source
Expand description

Metric collection and parsing for remote servers.

Metrics are gathered via SSH commands and parsed into typed values. All parsers return Option<f32> — they never panic. Unknown or truncated output results in None, which the UI renders as “N/A”.

Commands used per OS family:

  • CPU: top -bn1 (Linux) / top -l 1 -n 0 (macOS)
  • RAM: free -b (Linux) / vm_stat + sysctl hw.memsize (macOS)
  • Disk: df -k /
  • Uptime: uptime
  • Load: cat /proc/loadavg (Linux only)

Severity thresholds: Ok < 60 % Warn 60–85 % Crit > 85 %

Enums§

ThresholdLevel
Severity of a metric percentage. The UI maps each level to a colour.

Functions§

parse_cpu_proc_stat
Parse CPU usage from Linux /proc/stat.
parse_cpu_top
Parse CPU idle percentage from Linux top -bn1 output.
parse_cpu_top_macos
Parse CPU usage from macOS top -l 1 -n 0 output.
parse_disk_df
Parse disk usage of / from df -k / output.
parse_loadavg
Extract load averages from cat /proc/loadavg output.
parse_ram_free
Parse RAM usage from Linux free -b output.
parse_ram_vmstat
Parse RAM usage from macOS vm_stat + sysctl hw.memsize output.
parse_top_processes
Parse the top processes by CPU usage from ps output.
parse_uptime
Extract the human-readable uptime string from uptime output.
threshold_level
Returns the severity level for a metric percentage.