A Rolls-Royceโinspired performance reserve meter for Linux and macOS systems. Elegant, minimal, and focused on what really matters: how much performance your machine has left to give.
This library is currently in Beta stage and not yet fully mature.
- Parameter tuning may not be precise enough and might need adjustment for specific systems
- API and behavior may change in future versions
- We welcome your feedback and contributions through Issues and Pull Requests
- Please test thoroughly before using in production environments
Your feedback is crucial for improving this project!
Inspired by the Power Reserve gauge in Rolls-Royce cars โ which shows how much engine power is still available โ pwrzv brings the same philosophy to Unix-like systems. Instead of showing raw usage, it estimates how much headroom remains in your system's core resources.
It provides a simple 0โ5 score, calculated from multiple real-time metrics:
- CPU usage, I/O wait, and load average
- Memory usage and pressure / compression
- Disk I/O utilization (Linux only)
- Network dropped packets ratio
- File descriptor and process count
All inputs are weighted and transformed via sigmoid functions to reflect practical bottlenecks, not just raw numbers.
$ pwrzv --once
โ
Platform check passed for: linux
4.87$ pwrzv --once --detailed
โ
Platform check passed for: linux
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Power Reserve Analysis
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Overall Power Reserve: 4.87 ๐
Status: Abundant - Excellent performance
๐ Component Metrics:
cpu_usage : value=0.050 score=4.987 ๐
cpu_io_wait : value=0.001 score=4.998 ๐
cpu_load : value=0.120 score=4.970 ๐
memory_usage : value=0.450 score=4.523 ๐
memory_pressure : value=0.010 score=4.964 ๐
disk_io_utilization : value=0.050 score=4.987 ๐
network_dropped_packets : value=0.000 score=5.000 ๐
file_descriptors : value=0.030 score=4.993 ๐
process_count : value=0.080 score=4.980 ๐
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก Interpretation:
โข Scores range from 1.0 (Critical) to 5.0 (Abundant)
โข Overall level is determined by the lowest component score
โข Higher precision allows for more accurate assessmentgit clone https://github.com/kookyleo/pwrzv.git
cd pwrzv
cargo install --path .cargo install pwrzvpwrzv supports Linux and macOS systems for now. Other platforms will display an error message.
- Linux: Uses
/procfilesystem for direct system metrics access - macOS: Uses system commands (
sysctl,vm_stat,iostat, etc.) for metrics collection
# Basic usage (simplest numeric output)
pwrzv
# Detailed component analysis (default text format)
pwrzv --detailed
# Detailed analysis with JSON output
pwrzv --detailed json
# Detailed analysis with YAML output
pwrzv --detailed yamluse pwrzv::{get_power_reserve_level_direct, PwrzvError};
#[tokio::main]
async fn main() -> Result<(), PwrzvError> {
let level = get_power_reserve_level_direct().await?;
println!("Power Reserve Level: {}/5", level);
Ok(())
}use pwrzv::{get_power_reserve_level_with_details_direct, PwrzvError};
#[tokio::main]
async fn main() -> Result<(), PwrzvError> {
let (level, details) = get_power_reserve_level_with_details_direct().await?;
println!("Power Reserve: {:.2}/5.0", level);
println!("Detailed metrics:");
for (metric, detail) in details {
println!(" {}: value={:.3} score={:.3}", metric, detail.value, detail.score);
}
Ok(())
}use pwrzv::{check_platform, get_platform_name, PwrzvError};
fn main() -> Result<(), PwrzvError> {
println!("Running on: {}", get_platform_name());
match check_platform() {
Ok(()) => println!("Platform is supported!"),
Err(e) => eprintln!("Platform not supported: {}", e),
}
Ok(())
}The scoring system uses sigmoid functions to map resource utilization to a 0-5 scale:
- 5 (Excellent): Abundant resources, system running smoothly
- 4 (Good): Ample resources available, good performance
- 3 (Moderate): Adequate performance, resources sufficient
- 2 (Low): Resource constrained, consider optimization
- 0-1 (Critical): System under heavy load, immediate attention needed
- Resource Collection: Gathers metrics from
/procfilesystem or system commands - Normalization: Converts raw metrics to 0-1 scale
- Sigmoid Transformation: Applies configurable thresholds and curves
- Bottleneck Detection: Takes the minimum score (worst resource)
- Final Scoring: Maps to 0-5 range with level descriptions
pwrzv employs sophisticated mathematical algorithms to convert raw system metrics into meaningful power reserve scores:
The core calculation uses the sigmoid function to transform linear resource utilization into a smooth 0-1 scale:
f(x) = 1 / (1 + e^(-k * (x - xโ)))
Where:
- x: Raw metric value (0-1 range after normalization)
- xโ (midpoint): The threshold where the metric begins significantly impacting the score
- k (steepness): Controls the curve's steepness; higher values create more dramatic score changes
- Raw Data Collection: Platform-specific metric gathering (Linux:
/procfilesystem, macOS: system commands) - Normalization: Convert raw values to 0-1 scale for consistent processing
- Sigmoid Transformation: Apply individual sigmoid curves to each metric based on its characteristics
- Bottleneck Analysis: Identify the worst-performing resource (minimum score)
- Final Mapping: Transform the 0-1 result to the 0-5 Power Reserve scale
Each metric uses carefully tuned parameters:
- CPU metrics: Balanced sensitivity for both usage spikes and sustained load
- Memory metrics: Higher thresholds to account for normal OS caching behavior
- I/O metrics: Moderate sensitivity to distinguish between light and heavy workloads
- Network metrics: Separate handling for bandwidth utilization vs. packet loss sensitivity
This mathematical approach ensures that pwrzv provides intuitive, actionable scores that reflect real system performance bottlenecks rather than raw utilization percentages.
pwrzv supports customizing sigmoid function parameters for each metric via environment variables to adapt to different system characteristics and use cases.
# CPU usage configuration (default: midpoint=0.60, steepness=8.0)
export PWRZV_MACOS_CPU_USAGE_MIDPOINT=0.60
export PWRZV_MACOS_CPU_USAGE_STEEPNESS=8.0
# CPU load configuration (default: midpoint=1.2, steepness=5.0)
export PWRZV_MACOS_CPU_LOAD_MIDPOINT=1.2
export PWRZV_MACOS_CPU_LOAD_STEEPNESS=5.0
# Memory usage configuration (default: midpoint=0.85, steepness=20.0)
export PWRZV_MACOS_MEMORY_USAGE_MIDPOINT=0.85
export PWRZV_MACOS_MEMORY_USAGE_STEEPNESS=20.0
# Memory compression configuration (default: midpoint=0.60, steepness=15.0)
export PWRZV_MACOS_MEMORY_COMPRESSED_MIDPOINT=0.60
export PWRZV_MACOS_MEMORY_COMPRESSED_STEEPNESS=15.0
# Network dropped packets configuration (default: midpoint=0.01, steepness=50.0)
export PWRZV_MACOS_NETWORK_DROPPED_MIDPOINT=0.01
export PWRZV_MACOS_NETWORK_DROPPED_STEEPNESS=50.0
# File descriptor configuration (default: midpoint=0.90, steepness=30.0)
export PWRZV_MACOS_FD_MIDPOINT=0.90
export PWRZV_MACOS_FD_STEEPNESS=30.0
# Process count configuration (default: midpoint=0.80, steepness=12.0)
export PWRZV_MACOS_PROCESS_MIDPOINT=0.80
export PWRZV_MACOS_PROCESS_STEEPNESS=12.0# CPU usage configuration (default: midpoint=0.65, steepness=8.0)
export PWRZV_LINUX_CPU_USAGE_MIDPOINT=0.65
export PWRZV_LINUX_CPU_USAGE_STEEPNESS=8.0
# CPU I/O wait configuration (default: midpoint=0.20, steepness=20.0)
export PWRZV_LINUX_CPU_IOWAIT_MIDPOINT=0.20
export PWRZV_LINUX_CPU_IOWAIT_STEEPNESS=20.0
# CPU load configuration (default: midpoint=1.2, steepness=5.0)
export PWRZV_LINUX_CPU_LOAD_MIDPOINT=1.2
export PWRZV_LINUX_CPU_LOAD_STEEPNESS=5.0
# Memory usage configuration (default: midpoint=0.85, steepness=18.0)
export PWRZV_LINUX_MEMORY_USAGE_MIDPOINT=0.85
export PWRZV_LINUX_MEMORY_USAGE_STEEPNESS=18.0
# Memory pressure configuration (default: midpoint=0.30, steepness=12.0)
export PWRZV_LINUX_MEMORY_PRESSURE_MIDPOINT=0.30
export PWRZV_LINUX_MEMORY_PRESSURE_STEEPNESS=12.0
# Disk I/O configuration (default: midpoint=0.70, steepness=10.0)
export PWRZV_LINUX_DISK_IO_MIDPOINT=0.70
export PWRZV_LINUX_DISK_IO_STEEPNESS=10.0
# Network dropped packets configuration (default: midpoint=0.01, steepness=50.0)
export PWRZV_LINUX_NETWORK_DROPPED_MIDPOINT=0.01
export PWRZV_LINUX_NETWORK_DROPPED_STEEPNESS=50.0
# File descriptor configuration (default: midpoint=0.90, steepness=25.0)
export PWRZV_LINUX_FD_MIDPOINT=0.90
export PWRZV_LINUX_FD_STEEPNESS=25.0
# Process count configuration (default: midpoint=0.80, steepness=12.0)
export PWRZV_LINUX_PROCESS_MIDPOINT=0.80
export PWRZV_LINUX_PROCESS_STEEPNESS=12.0- midpoint: Sigmoid function midpoint value, representing the threshold where this metric starts significantly affecting the score
- steepness: Sigmoid function steepness, higher values make the curve steeper and score changes more dramatic
# Adjust CPU threshold for high-performance server
export PWRZV_LINUX_CPU_USAGE_MIDPOINT=0.80
export PWRZV_LINUX_CPU_USAGE_STEEPNESS=15.0
# Run pwrzv
pwrzv --detailedWhile most system monitors highlight how much is used, pwrzv tells you how much is left. This makes it a useful tool for:
- Minimal dashboards - Single metric overview
- Autoscaling decisions - When to scale up/down
- Performance monitoring - Proactive resource management
- System health checks - Quick status assessment
Run the included examples:
# Basic usage example
cargo run --example basic_usage
# Detailed metrics analysis example
cargo run --example detailed_metrics# Run all tests
cargo test
# Run only unit tests
cargo test --lib
# Run documentation tests
cargo test --doc
# Run examples
cargo run --example basic_usageGenerate and view the full API documentation:
cargo doc --open- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
cargo test - Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Inspired by the Power Reserve gauge in Rolls-Royce automobiles
- Built with Rust for performance and reliability
- Thanks to the Linux kernel for providing comprehensive
/procmetrics
