Hardware Query
A cross-platform Rust library for querying detailed system hardware information with advanced monitoring and power management capabilities.
🚀 Features
Core Hardware Detection
- ✅ Cross-platform hardware detection (Windows, Linux, macOS)
- ✅ Detailed CPU information (cores, threads, cache, features)
- ✅ GPU detection and capabilities (CUDA, ROCm, DirectML support)
- ✅ Memory configuration and status
- ✅ Storage device enumeration and properties
- ✅ Network interface detection and capabilities
- ✅ Hardware acceleration support detection (NPU, TPU, FPGA)
- ✅ PCI/USB device enumeration
- ✅ ARM-specific hardware detection (Raspberry Pi, Jetson, etc.)
🔄 Real-time Monitoring (NEW!)
- ✅ Continuous hardware metrics monitoring
- ✅ Configurable update intervals and thresholds
- ✅ Event-driven notifications for thermal/power alerts
- ✅ Background monitoring with async support
- ✅ Comprehensive monitoring statistics
⚡ Power Management & Efficiency
- ✅ Real-time power consumption tracking
- ✅ Battery life estimation and health monitoring
- ✅ Power efficiency scoring and optimization
- ✅ Thermal throttling risk assessment
- ✅ Power optimization recommendations
🌡️ Enhanced Thermal Management
- ✅ Advanced temperature monitoring with history
- ✅ Thermal throttling prediction algorithms
- ✅ Cooling optimization recommendations
- ✅ Sustained performance capability analysis
- ✅ Fan curve analysis and optimization
🐳 Virtualization & Container Detection
- ✅ Comprehensive virtualization environment detection
- ✅ Container runtime identification (Docker, Kubernetes, etc.)
- ✅ Resource limits and restrictions analysis
- ✅ GPU passthrough capability detection
- ✅ Performance impact assessment
- ✅ Security feature analysis
🎯 AI/ML Optimization
- ✅ Hardware suitability assessment for AI workloads
- ✅ Performance scoring for different AI tasks
- ✅ Memory and compute requirement analysis
- ✅ Acceleration framework compatibility
- ✅ Optimization recommendations
Quick Start
Add this to your Cargo.toml
:
[]
= "0.2.0"
# For real-time monitoring features
= { = "0.2.0", = ["monitoring"] }
🔧 Feature Flags
When to Use the monitoring
Feature
Enable monitoring
if you need:
- ✅ Continuous hardware monitoring - Track temperatures, power, and performance over time
- ✅ Real-time alerts - Get notified when hardware exceeds thresholds
- ✅ Background monitoring - Async monitoring that doesn't block your application
- ✅ Event-driven architecture - React to hardware changes as they happen
- ✅ Server/system monitoring - Long-running applications that need to track hardware health
Skip monitoring
if you only need:
- ❌ One-time hardware queries (use
SystemOverview::quick()
) - ❌ Static hardware information for configuration
- ❌ Simple compatibility checks
- ❌ Lightweight applications where async dependencies are unwanted
# Lightweight - no async dependencies
= "0.2.0"
# Full featured - includes real-time monitoring
= { = "0.2.0", = ["monitoring"] }
🚀 Simplified API (Recommended for New Users)
For most use cases, start with the simplified API:
use SystemOverview;
// Get essential system info in one line - no hardware expertise needed!
let overview = quick?;
println!;
println!;
println!;
println!;
For domain-specific needs:
use HardwarePresets;
// AI/ML assessment with built-in expertise
let ai_assessment = ai_assessment?;
println!;
// Gaming performance recommendations
let gaming = gaming_assessment?;
println!;
Advanced Usage
use HardwareInfo;
Advanced Real-time Monitoring
use ;
use Duration;
async
// Get GPU information
for (i, gpu) in hw_info.gpus().iter().enumerate() {
println!("GPU {}: {} {} with {} GB VRAM",
i + 1,
gpu.vendor(),
gpu.model_name(),
gpu.memory_gb()
);
// Check GPU capabilities
println!(" CUDA support: {}", gpu.supports_cuda());
println!(" ROCm support: {}", gpu.supports_rocm());
println!(" DirectML support: {}", gpu.supports_directml());
}
// Memory information
let mem = hw_info.memory();
println!("System memory: {:.1} GB total, {:.1} GB available",
mem.total_gb(),
mem.available_gb()
);
// Storage information
for (i, disk) in hw_info.storage_devices().iter().enumerate() {
println!("Disk {}: {} {:.1} GB ({:?} type)",
i + 1,
disk.model,
disk.capacity_gb,
disk.storage_type
);
}
// Network interfaces
for interface in hw_info.network_interfaces() {
println!("Network: {} - {}",
interface.name,
interface.mac_address
);
}
// Check specialized hardware
for npu in hw_info.npus() {
println!("NPU detected: {} {}", npu.vendor(), npu.model_name());
}
for tpu in hw_info.tpus() {
println!("TPU detected: {} {}", tpu.vendor(), tpu.model_name());
}
// Check ARM-specific hardware (Raspberry Pi, Jetson, etc.)
if let Some(arm) = hw_info.arm_hardware() {
println!("ARM System: {}", arm.system_type);
}
// Check FPGA hardware
for fpga in hw_info.fpgas() {
println!("FPGA: {} {} with {} logic elements",
fpga.vendor,
fpga.family,
fpga.logic_elements.unwrap_or(0)
);
}
// Serialize hardware information to JSON
let hw_json = hw_info.to_json()?;
println!("Hardware JSON: {}", hw_json);
Ok(())
}
## Specialized Hardware Support
The library provides comprehensive detection for AI/ML-oriented hardware:
- **NPUs**: Intel Movidius, GNA, XDNA; Apple Neural Engine; Qualcomm Hexagon
- **TPUs**: Google Cloud TPU and Edge TPU; Intel Habana
- **ARM Systems**: Raspberry Pi, NVIDIA Jetson, Apple Silicon with power management
- **FPGAs**: Intel/Altera and Xilinx families with AI optimization scoring
```rust
use hardware_query::HardwareInfo;
let hw_info = HardwareInfo::query()?;
// Check for specialized AI hardware
for npu in hw_info.npus() {
println!("NPU: {} {}",
npu.vendor(),
npu.model_name()
);
}
for tpu in hw_info.tpus() {
println!("TPU: {} {}",
tpu.vendor(),
tpu.model_name()
);
}
Platform Support
Platform | CPU | GPU | Memory | Storage | Network | Battery | Thermal | PCI | USB |
---|---|---|---|---|---|---|---|---|---|
Windows | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Linux | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
macOS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Optional Features
Enable additional GPU support with feature flags:
[]
= { = "0.2.0", = ["nvidia", "amd", "intel"] }
nvidia
: NVIDIA GPU support via NVMLamd
: AMD GPU support via ROCmintel
: Intel GPU support
Examples
See the examples directory for complete usage examples:
- 🚀 Simplified API (Start Here!) - Easy-to-use API for common scenarios
- Basic Hardware Detection - Fundamental hardware querying
- Enhanced Hardware - Advanced hardware analysis
- Comprehensive Hardware - Complete system analysis
- Advanced Usage - Expert-level features
- Comprehensive AI Hardware - AI/ML-specific analysis
- Enhanced Monitoring Demo - Real-time monitoring (requires
monitoring
feature)
Building
# Build with default features
# Build with GPU support
# Run tests
# Try the simplified API first (recommended for new users!)
# Or run the basic hardware example
Dependencies
sysinfo
- Cross-platform system informationserde
- Serialization frameworkthiserror
- Error handlingnum_cpus
- CPU core detection
Optional Dependencies
nvml-wrapper
- NVIDIA GPU support (feature: nvidia)wmi
- Windows Management Instrumentation (Windows only)libc
- Linux system calls (Linux only)core-foundation
- macOS system APIs (macOS only)
Performance
The library is designed for performance with:
- Lazy evaluation of hardware information
- Minimal system calls
- Efficient data structures
- Optional caching for repeated queries
Typical query times:
- Complete hardware scan: 10-50ms
- CPU information: 1-5ms
- GPU information: 5-20ms
- Memory information: 1-3ms
Error Handling
The library uses comprehensive error handling:
use ;
match query
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT OR Apache-2.0 License - see the LICENSE-MIT and LICENSE-APACHE files for details.
Acknowledgments
- Built on top of the excellent
sysinfo
crate - Inspired by the need for better hardware detection in AI workload placement
- Thanks to all contributors who helped improve cross-platform compatibility