A high-performance, real-time monitoring tool for ZFS cache layers (ARC, L2ARC, SLOG) written in Rust with visual progress bars and performance indicators.
- Real-time monitoring of all ZFS cache layers with accurate rate calculations
- Visual progress bars with Unicode characters
- Color-coded performance indicators (excellent/good/fair/poor)
- Automatic pool detection or manual selection
- Configurable refresh intervals
- Comprehensive error handling and graceful fallbacks
- Async I/O for high performance and responsiveness
- Demo mode for testing without ZFS installation
- Primary RAM-based cache
- Hit/miss rates and performance rating
- Cache size vs target size with utilization
- Read operations per second (calculated rates)
- Secondary SSD-based read cache
- Hit/miss rates for L2 cache
- Cache size and read throughput
- Operations per second (calculated rates)
- Dedicated write cache device
- Device utilization and write operations
- Write throughput and latency metrics
- Performance assessment based on utilization/latency
- Rust toolchain (1.70+ recommended)
- ZFS utilities:
zpool,arcstat(for live mode) - System access:
/proc/spl/kstat/zfs/arcstats(for live mode)
# Clone the repository
git clone <repository-url>
cd zpool-rw-meter
# Build the project
cargo build --release
# Run in demo mode (no ZFS required)
DEMO_MODE=true cargo run
# Or run live mode on ZFS systems
cargo runsudo apt update
sudo apt install zfsutils-linuxsudo dnf install zfs
# or on older systems:
sudo yum install zfs# Build and run with default settings (demo mode)
DEMO_MODE=true cargo run
# Monitor specific pool with default 2-second refresh
cargo run pool_name
# Custom refresh interval (1 second)
cargo run pool_name 1
# Live mode on ZFS systems (requires ZFS installation)
cargo run
# Show help
cargo run -- --helpDEMO_MODE=true- Run with realistic sample data (useful for testing or demo purposes without ZFS)
======================= π ZFS Cache Performance Monitor ========================
Pool: data | Refresh: 2s | Time: 2025-09-14 17:10:08
π ARC (Primary RAM Cache)
Hit Rate: 100 (Excellent) [####################] 100.0%
Cache Size: 46.3G/46.5G [####################] 99.6%
Read Ops: 0/s
πΎ L2ARC (Secondary SSD Cache)
Hit Rate: 73.4304932735426 (Good) [###############.....] 73.4%
Cache Size: 553.7G
Read Rate: 0 B/s
Operations: 0/s
π‘ SLOG (Synchronous Write Log)
Device: mirror-1
Utilization: 0 (Excellent) [....................] 0.0%
Write Ops: 0/s
Write Rate: 0 B/s
Latency: 0.0ms
================================================================================
Press Ctrl+C to exit | Data refreshes every 2s
- π’ Green: Excellent performance (80%+ hit rate)
- π‘ Yellow: Good performance (60-80% hit rate)
- π΄ Red: Poor performance (<60% hit rate)
- ARC Hit Rate: 85%+ excellent, 70%+ good
- L2ARC Hit Rate: 75%+ excellent, 50%+ good
- SLOG Performance: Based on utilization (<80%) and latency (<5ms)
Error: Failed to collect ARC statistics from all sourcesThis error occurs when running in live mode without ZFS installed. Use demo mode instead:
DEMO_MODE=true cargo runError: No ZFS pools foundEnsure ZFS is loaded and pools are imported:
sudo modprobe zfs
sudo zpool import -aPermission deniedRun with appropriate privileges or add user to disk group:
sudo usermod -a -G disk $USERIf you encounter compilation errors:
# Update Rust toolchain
rustup update
# Clean and rebuild
cargo clean
cargo buildThe application includes comprehensive demo mode for testing:
# Run demo mode
DEMO_MODE=true cargo run
# Test with different pools/intervals
DEMO_MODE=true cargo run testpool 1Demo mode features:
- Realistic ZFS statistics simulation
- All cache layers displayed
- Rate calculations working
- Full UI functionality
- Async runtime: Tokio for high-performance concurrent I/O
- Modular design: Separate modules for display, ZFS parsing, system abstraction
- Trait-based abstractions:
CommandExecutorandFilesystemReaderfor testing - Rate calculation: Custom
RateCalculatorfor accurate ops/second metrics
- ARC stats:
arcstatutility and/proc/spl/kstat/zfs/arcstatsparsing - L2ARC stats: Direct parsing from ZFS kernel statistics
- SLOG stats: Combined
zpool statusandzpool iostatdata - Visual elements: Unicode progress bars with terminal control sequences
- Error handling: Comprehensive fallbacks and graceful degradation
- Real-time rates: Accurate per-second calculations for all metrics
- Flicker-free display: Terminal control for smooth updates
- Signal handling: Graceful Ctrl+C shutdown
- Timeout protection: Prevents hanging on slow commands
This project has been successfully migrated from shell script to Rust:
- β Phase 1: Foundation & Demo Mode - Complete
- β Phase 2: System Abstractions - Complete
- β Phase 3: ZFS Statistics Engine - Complete
- β Phase 4: Caching & Error Handling - Complete
- β Phase 5: Unit Tests & Real System Testing - Complete
- Performance: Async I/O with Tokio runtime
- Reliability: Strong typing and comprehensive error handling
- Maintainability: Modular architecture with clear separation of concerns
- Testing: Trait-based abstractions enable thorough unit testing
- Accuracy: Precise rate calculations for real-time metrics
Feel free to submit issues and enhancement requests! The codebase is written in Rust with a focus on performance and reliability.
This project is open source and available under the MIT License.