dstat
Versatile resource statistics tool.
Official WebsiteFeatures
Installation
apt install dstatpacman -S dstatdnf install dstatWhy Use dstat?
Real-Time Versatility
Monitor CPU, memory, disk I/O, network, and more in real-time with a single command and customizable output.
Flexible Plugin System
Extend functionality with plugins for system-specific metrics, temperature monitoring, SMART data, and more.
CSV Export & Integration
Export data in CSV format for integration with other tools, spreadsheets, and custom analysis scripts.
Customizable Output
Choose which metrics to display, adjust update intervals, and format output for specific needs.
Basic Usage
# Default monitoring (CPU, disk, net, page, load)
dstat
# Monitor with 2-second intervals
dstat -t -v
# Show specific metrics
dstat --cpu --mem --disk --net
# Monitor for a specific duration (10 iterations)
dstat 1 10
# Specify update interval (in seconds)
dstat -T -s 2 5
# Show all available metrics
dstat --list
# Get help
dstat -hCommon Options
| Option | Description |
|---|---|
-c, --cpu | Show CPU stats (user, system, idle, wait) |
-m, --mem | Show memory stats (used, free, buffer, cache) |
-d, --disk | Show disk I/O stats (read, write) |
-n, --net | Show network stats (send, receive) |
-p, --proc | Show process stats (runnable, uninterruptible) |
-l, --load | Show load average |
-t, --time | Include timestamp in output |
-T, --epoch | Show epoch timestamp |
--output FILE | Write output to CSV file |
Practical Examples
1. Monitor Everything with Timestamps
# Full system monitoring with timestamps
dstat -tcmlpnd
# Output includes:
# Time, CPU, Memory, Load, Process, Network, Disk2. Focus on Disk I/O
# Monitor disk I/O performance
dstat -d --disk-util --disk-tps
# Output shows:
# Disk read/write, utilization, and transactions per second3. Focus on Network Traffic
# Monitor network performance
dstat -n --net
# Or monitor per-interface
dstat --net -i eth0
# Check all interfaces
dstat --net --net-packets4. Memory and Swap Monitoring
# Focus on memory usage
dstat -m --mem-adv
# Include swap statistics
dstat -m -s --swap5. Export to CSV for Analysis
# Collect data to CSV file (10 samples, 2-second intervals)
dstat -tcmlpnd --output monitoring.csv 2 10
# Run in background and collect for extended period
nohup dstat -tcmlpnd --output monitoring.csv 1 > /dev/null 2>&1 &
# Convert to CSV for Excel or analysis tools
dstat -t --csv --output data.csv 1 100Plugins & Extended Metrics
Discovering Available Plugins
# List all available plugins
dstat --list
# List only available modules
dstat --list | grep -E "^(internal|external)"
# Typical built-in modules:
# --cpu, --mem, --disk, --net, --proc, --load, --page
# --ipc, --lock, --raw, --socket, --tcp, --udp, --unix, --filesystemUsing Advanced Plugins
# Monitor filesystem usage
dstat --filesystem
# Monitor TCP connections
dstat --tcp
# Monitor temperature (if available)
dstat --temp
# Monitor battery status
dstat --battery
# Combine multiple plugins
dstat -t --cpu --mem --disk --net --tcp --udpComparison with Similar Tools
vs. top/htop
dstat shows system-wide metrics (CPU, disk, network) while top/htop focus on processes. dstat is better for infrastructure monitoring.
vs. iostat
dstat provides more comprehensive metrics including network and memory, while iostat specializes in disk I/O only.
vs. vmstat
dstat is more user-friendly with better formatting. vmstat is lighter on resources and available on more systems by default.
vs. glances
glances provides a more comprehensive all-in-one dashboard with a web interface, while dstat excels at streaming metrics to CSV for scripted analysis.
Tips
1. Create Monitoring Scripts
Wrap dstat in shell scripts to automate data collection with consistent parameters and store results for trend analysis.
2. Use Aliases for Common Monitoring Profiles
Create bash aliases for your most common dstat commands to save typing and ensure consistency.
3. Combine with Log Rotation
When using CSV output, configure logrotate to manage large CSV files and prevent disk space issues.
4. Monitor Specific Devices
Use -D option to focus on specific devices: dstat -D sda,sdb for selective disk monitoring.
5. Integrate with Monitoring Systems
Use dstat's CSV output with tools like Prometheus, InfluxDB, or custom monitoring dashboards for historical analysis.