Skip to content

feat: Add native Linux hardware sensor polling via sysfs hwmon - #23

Merged
manupawickramasinghe merged 1 commit into
masterfrom
feature/native-linux-sensors
Jul 29, 2026
Merged

feat: Add native Linux hardware sensor polling via sysfs hwmon#23
manupawickramasinghe merged 1 commit into
masterfrom
feature/native-linux-sensors

Conversation

@manupawickramasinghe

Copy link
Copy Markdown
Member

Description

This PR implements native Linux hardware sensor polling using the Linux kernel /sys/class/hwmon sysfs interface, /proc/stat, /proc/meminfo, and CPU frequency scaling interfaces.

Features Added

  1. LinuxSysfsSource: Reads live hardware temperatures (°C), fan speeds (RPM), voltages (V), power consumption (W), and clock frequencies (MHz).
  2. Automatic Chip Categorization: Maps hwmon drivers (k10temp, coretemp, amdgpu, nouveau, nvme, spd5118, nct6775, etc.) to HardwareType.
  3. CPU & Memory Metrics: Computes true active CPU Load % and system Memory Used/Total GB.
  4. Enhanced System Info: Reads motherboard DMI product/vendor info, CPU model string, and OS release.
  5. Headless Execution: Added SENSORVIEW_HEADLESS environment variable for server monitoring.
  6. Tests: Added unit test coverage for hwmon file scanning and chip classification (74 total tests passing).

Copilot AI review requested due to automatic review settings July 29, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@manupawickramasinghe
manupawickramasinghe merged commit 3e052ee into master Jul 29, 2026
3 checks passed
@manupawickramasinghe
manupawickramasinghe deleted the feature/native-linux-sensors branch July 29, 2026 20:40
manupawickramasinghe pushed a commit that referenced this pull request Jul 30, 2026
Resolves the conflict with PR #23, which added a Linux sysfs/hwmon backend
in the same two places this branch touched. Both changes had the identical
shape — add a platform arm, narrow the fallback — so the resolution keeps
both arms and widens each fallback to exclude all three platforms:

    source/mod.rs  default_source()
    sysinfo.rs     query()
      -> #[cfg(not(any(windows, target_os = "macos", target_os = "linux")))]

Getting this wrong is silent: these are sequential exclusive cfg blocks, not
else-if, so a platform named in an arm *and* left in the fallback compiles
both and the last one wins.

CI was failing on all three legs:

- Windows and Linux failed at Clippy. sysinfo::query_for_test is a #[cfg(test)]
  helper consumed only by the macOS system-profile test, so on other platforms
  it tripped dead_code under -D warnings. Marked allow(dead_code) with the
  reason.
- macOS failed at Run tests (exit 101). CI runs macOS virtualized, where the
  IOHID sensor plane, IOReport, an integrated GPU, an NVMe controller and the
  system fonts may all be absent. Several new tests still asserted that
  hardware into existence, including two that indexed services[0] and would
  panic on an empty list. Every environment-dependent assertion now reports
  "SKIP: ... not available" instead. Only *presence* is ever skipped — the
  range, uniqueness, stability and unit assertions still run wherever the
  hardware is real, which is where the coverage actually comes from.

Verified by cross-checking the other two targets locally rather than guessing:
cargo clippy --all-targets -D warnings is clean for
x86_64-unknown-linux-gnu, x86_64-pc-windows-msvc and the macOS host, and
cargo check --no-default-features passes for Linux too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants