A Python script to collect and log ZFS Adaptive Replacement Cache (ARC) and L2ARC statistics using the arcstat utility.
- Collects ARC/L2ARC performance metrics at configurable intervals
- Logs data to CSV for long-term monitoring and analysis
- Tracks extended statistics including:
- L2ARC MRU/MFU percentages
- MRU/MFU size metrics
- Ghost cache statistics
- Hit ratios and cache sizes
- Automatic unit conversion (bytes to GB)
- Configurable sampling parameters
- I have a seperate dataset in my pool
/mnt/tank/tn_scriptsthat I use for this purpose, and I highly recommend you should as well. git clone https://github.com/nickf1227/arcstat_collector.git /mnt/tank/tn_scriptsReplace the path with where you want to store it on your system, and then run it.- You can call the script by running
python3 /mnt/tank/tn_scripts/arcstat_collector/arcstat_collector.py
Edit these variables in the script:
SAMPLING_INTERVAL = 10 # arcstat sampling interval in seconds SAMPLING_FREQUENCY = 60 # How often to collect samples in seconds CSV_OUTPUT_PATH = "." # Output directory for CSV file
For now, columns include the below. I plan to expose more later. Please see https://openzfs.github.io/openzfs-docs/man/master/1/arcstat.1.html:
timestamp: Measurement time (YYYY-MM-DD HH:MM:SS )
size (GB): Total ARC size
hit%: ARC hit percentage
l2size (GB): L2ARC device size
l2hit%: L2ARC hit percentage
l2mru%: L2ARC MRU (Most Recently Used) percentage
mrusz%: MRU size percentage
mrugsz (GB): MRU ghost size
l2mfu%: L2ARC MFU (Most Frequently Used) percentage
mfusz%: MFU size percentage
mfugsz (GB): MFU ghost size
Common Issues:
Permission Denied for arcstat
Run with sudo: sudo python3 arcstat_monitor.py