Skip to content

feat: update sysinfo from forked 0.15.x to official 0.37#176

Closed
bvaisvil wants to merge 8 commits into
masterfrom
sysinfo_0.37.x
Closed

feat: update sysinfo from forked 0.15.x to official 0.37#176
bvaisvil wants to merge 8 commits into
masterfrom
sysinfo_0.37.x

Conversation

@bvaisvil
Copy link
Copy Markdown
Owner

@bvaisvil bvaisvil commented Jan 12, 2026

Summary

Migrate zenith from the forked sysinfo crate (zenith_changes_15.1_mem_fix branch) to the official sysinfo 0.37 from crates.io.

  • Remove dependency on forked sysinfo - Use official crate from crates.io instead of git fork
  • Update API calls for sysinfo 0.30+ breaking changes - Trait removal, method renames, type changes
  • Add procfs dependency for Linux - Required for priority, nice, threads_total which were removed from sysinfo
  • Add native macOS support - Use libc::getpriority() and proc_pidinfo() for priority, nice, threads_total
  • Handle new Option return types - temperature() and max() now return Option

Changes

Cargo.toml

  • Changed sysinfo from git fork to sysinfo = "0.37"
  • Added procfs = "0.17" for Linux (to get priority, nice, threads_total)

src/metrics/mod.rs

  • Updated imports: removed *Ext traits, added Components, Disks, Networks
  • Added new struct fields: components, disks_cache, networks
  • Updated all sysinfo method calls (get_* → no prefix)
  • Added procfs calls for Linux priority/nice/threads
  • Added macOS support using get_macos_process_info()

src/metrics/zprocess.rs

  • Updated from_user_and_process() signature to accept uid parameter
  • Added procfs integration for Linux
  • Added macOS implementation using libc::getpriority() and proc_pidinfo()
  • Simplified ProcessStatusExt implementation (single match for all platforms)
  • Added new ProcessStatus variants: UninterruptibleDiskSleep, LockBlocked

src/metrics/disk.rs

  • Removed DiskExt trait import
  • Updated all method calls to new API

Platform Support

Field Linux macOS
priority procfs libc::getpriority() + 20
nice procfs libc::getpriority()
threads_total procfs proc_pidinfo(PROC_PIDTASKINFO)

Test plan

  • cargo build --release succeeds on macOS
  • cargo build --release on Linux (CI)
  • cargo clippy passes
  • cargo fmt passes
  • Verify CPU/memory/disk/network metrics display correctly
  • Verify process list populates with correct data
  • Verify priority/nice/threads columns show values on both platforms

🤖 Generated with Claude Code

Migrate from the forked sysinfo (zenith_changes_15.1_mem_fix branch) to
the official sysinfo 0.37 crate from crates.io.

Key changes:
- Remove *Ext traits (SystemExt, ProcessExt, DiskExt, etc.) - methods
  are now directly on structs
- Rename Processor to Cpu, get_processors() to cpus()
- Add separate Components, Disks, Networks types to CPUTimeApp
- Update all method calls (get_* prefix removed)
- Handle Option<f32> return types for temperature/max
- Convert Pid wrapper type to i32 for internal use
- Use procfs crate on Linux for priority, nice, threads_total
  (these fields were removed from sysinfo)

Note: On macOS, priority/nice/threads_total default to 0/0/1 as these
fields are not available in sysinfo 0.37. A TODO comment marks this
for future platform-specific implementation.
@bvaisvil bvaisvil changed the title feat: update sysinfo from forked 0.15.x to official 0.33 feat: update sysinfo from forked 0.15.x to official 0.37 Jan 12, 2026
- Remove empty lines after doc comments
- Use is_multiple_of() instead of manual modulo check
- Use is_some_and() instead of map_or(false, ...)
- Remove unused lifetime parameter
- Add #[allow] for too_many_arguments on existing functions
The Equal variant from Ordering is used in Linux-specific field
comparators but was accidentally removed. Add #[allow(unused_imports)]
since it's only used on Linux.
Use libc::getpriority() to get the nice value and proc_pidinfo()
with PROC_PIDTASKINFO to get the thread count on macOS.

This removes the TODO comments and provides full functionality
on both Linux and macOS for these process fields.
Instead of calculating priority from nice value, use the actual
pti_priority field from ProcTaskInfo. Also properly handle getpriority
errors by checking errno.
@bvaisvil bvaisvil closed this Feb 16, 2026
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.

1 participant