feat(host): populate sysinfo and cpuinfo on macOS (VA-133) #133

Merged
longjacksonle merged 1 commit from feat/VA-133-macos-sysinfo-cpuinfo into main 2026-07-14 14:31:05 +02:00

What

Populates the agent Overview on macOS nodes. host::sysinfo and host::cpuinfo both had a cfg(not(target_os = "linux")) stub returning a default snapshot, so on a Mac the console showed OS -, Kernel -, CPU 0 threads, Memory -, Uptime -, and Load -. This adds macOS backends that read the same facts via sysctl and vm_stat.

cpuinfo

snapshot() gains a macOS arm reading hw.logicalcpu, machdep.cpu.brand_string, machdep.cpu.vendor, and hw.cpufrequency. The raw-to-CpuInfo mapping is a pure cpuinfo_from_sysctl() so it is unit-tested off-macOS. hw.cpufrequency is absent on Apple Silicon; a missing or zero value is reported as unknown rather than 0 MHz. cache_size has no clean single-key sysctl equivalent and is left None.

sysinfo

snapshot() gains a macOS arm reading kern.osrelease (kernel), kern.boottime (uptime = now - boottime), vm.loadavg (load averages), hw.memsize (total memory), and vm_stat (available memory, estimated as free + inactive + speculative + purgeable pages times page size, matching what Activity Monitor treats as reclaimable). Each BSD-format source is parsed by a pure helper (parse_boottime_secs, parse_loadavg_bsd, parse_vm_stat_available) with Linux-runnable unit tests; the thin sysctl/vm_stat shells are macOS-gated.

Testing

The pure parsers are gated cfg(any(target_os = "macos", test)) so they compile and run under test on Linux. 21 lib tests for host::cpuinfo + host::sysinfo pass; clippy --deny warnings and fmt are clean on Linux.

The macOS-only process shells (sysctl_str, vm_stat_output, snapshot_macos) cannot be compiled on the Linux dev box (no Apple SDK for the C deps), so a native cargo build --release --target x86_64-apple-darwin plus an Overview check on a Mac node is still needed to confirm the live values render. Linux and other-platform paths are unchanged.

Closes VA-133.

## What Populates the agent Overview on macOS nodes. `host::sysinfo` and `host::cpuinfo` both had a `cfg(not(target_os = "linux"))` stub returning a default snapshot, so on a Mac the console showed OS `-`, Kernel `-`, CPU `0 threads`, Memory `-`, Uptime `-`, and Load `-`. This adds macOS backends that read the same facts via `sysctl` and `vm_stat`. ## cpuinfo `snapshot()` gains a macOS arm reading `hw.logicalcpu`, `machdep.cpu.brand_string`, `machdep.cpu.vendor`, and `hw.cpufrequency`. The raw-to-`CpuInfo` mapping is a pure `cpuinfo_from_sysctl()` so it is unit-tested off-macOS. `hw.cpufrequency` is absent on Apple Silicon; a missing or zero value is reported as unknown rather than 0 MHz. `cache_size` has no clean single-key sysctl equivalent and is left `None`. ## sysinfo `snapshot()` gains a macOS arm reading `kern.osrelease` (kernel), `kern.boottime` (uptime = now - boottime), `vm.loadavg` (load averages), `hw.memsize` (total memory), and `vm_stat` (available memory, estimated as free + inactive + speculative + purgeable pages times page size, matching what Activity Monitor treats as reclaimable). Each BSD-format source is parsed by a pure helper (`parse_boottime_secs`, `parse_loadavg_bsd`, `parse_vm_stat_available`) with Linux-runnable unit tests; the thin `sysctl`/`vm_stat` shells are macOS-gated. ## Testing The pure parsers are gated `cfg(any(target_os = "macos", test))` so they compile and run under `test` on Linux. 21 lib tests for `host::cpuinfo` + `host::sysinfo` pass; clippy `--deny warnings` and fmt are clean on Linux. The macOS-only process shells (`sysctl_str`, `vm_stat_output`, `snapshot_macos`) cannot be compiled on the Linux dev box (no Apple SDK for the C deps), so a native `cargo build --release --target x86_64-apple-darwin` plus an Overview check on a Mac node is still needed to confirm the live values render. Linux and other-platform paths are unchanged. Closes VA-133.
feat(host): populate sysinfo and cpuinfo on macOS (VA-133)
All checks were successful
Check / fmt + clippy + tests (pull_request) Successful in 4m34s
Create release / Create release from merged PR (pull_request) Has been skipped
715f8dbcf4
macOS has no /proc, so both host::sysinfo and host::cpuinfo returned a default snapshot, leaving the agent Overview blank on Mac nodes (OS, kernel, CPU thread count, memory, uptime, load all empty). Add macOS backends that read the same facts via sysctl and vm_stat.

cpuinfo: snapshot() gains a macOS arm reading hw.logicalcpu, machdep.cpu.brand_string, machdep.cpu.vendor, and hw.cpufrequency. The raw-value-to-CpuInfo mapping lives in a pure cpuinfo_from_sysctl() so it is unit-tested off-macOS; hw.cpufrequency is absent on Apple Silicon and a zero/missing value is reported as unknown rather than 0 MHz.

sysinfo: snapshot() gains a macOS arm reading kern.osrelease (kernel), kern.boottime (uptime = now - boottime), vm.loadavg (load averages), hw.memsize (total memory), and vm_stat (available memory estimated as free + inactive + speculative + purgeable pages times page size). Each BSD-format source is parsed by a pure helper (parse_boottime_secs, parse_loadavg_bsd, parse_vm_stat_available) with Linux-runnable unit tests; the thin sysctl/vm_stat shells are macOS-gated.

The pure parsers are gated cfg(any(target_os = "macos", test)) so they compile and run under test on Linux; only the process-spawning shells are macOS-only. Linux and other-platform paths are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BFsMi3Vmf3pCc7mBdhZqoV
longjacksonle deleted branch feat/VA-133-macos-sysinfo-cpuinfo 2026-07-14 14:31:05 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/vervain-agent!133
No description provided.