Skip to content
>_devvkit
$devvkit learn --librarie iostat-&-dstat-guide

iostat & dstat Guide

[disk][io][cpu][performance]
System Monitoring
Install
# iostat: part of sysstat
sudo apt install sysstat
# dstat:
sudo apt install dstat
brew install dstat

iostat reports CPU and I/O statistics for devices and partitions. Key columns: `%iowait` (time CPU waits for I/O — high = storage bottleneck), `r/s` + `w/s` (read/write requests per second), `rkB/s` + `wkB/s` (throughput), and `await` (average I/O response time in ms).

dstat combines iostat, vmstat, netstat, and ifstat into one view. Run `dstat -c --top-cpu -d --top-bio --net` to see CPU hogs, disk hogs, and network in a single terminal. It's the best "I don't know what's wrong yet" tool.

iostat -x 10 shows extended stats every 10 seconds. Watch `avgqu-sz` (queue size >1 = congestion) and `svctm` (service time). For GUI monitoring, use Grafana with Prometheus + node_exporter for historical I/O trends.

iostat CPU

CPU reportCPU utilization breakdown.
iostat -c                  # CPU stats only
iostat -c 5                # Every 5 seconds
iostat -c -z 5             # Skip zeros
iostat -c -p ALL           # Per-processor stats
# Columns: %user, %nice, %system, %iowait, %steal, %idle

iostat Disk

Device reportPer-disk I/O stats.
iostat -d                 # Device stats
iostat -x                  # Extended stats (better!)
iostat -x 5 10             # Every 5s, 10 reports
iostat -x -p sda, sdb      # Specific devices
iostat -m                  # In MB/s instead of blocks/s

# -x columns:
# r/s, w/s, rkB/s, wkB/s, avgqu-sz, await, svctm, %util
Find slow diskHigh await = slow.
iostat -x 2
# watch: await > 20ms = slow for SSD, > 100ms for HDD
# watch: %util near 100% = saturated device
# watch: avgqu-sz > 1 = requests queued

dstat

dstat — all-in-oneEverything at once.
dstat                       # CPU, disk, net, paging, system
dstat -c -d -n -m           # CPU + disk + net + memory
dstat --top-cpu --top-io --top-bio --top-mem
# See top processes by CPU, disk I/O, block I/O, memory
dstat — networkNetwork throughput.
dstat -n --net-packets     # Network bandwidth + packets
dstat -n --tcp              # TCP connections and segments
dstat --top-latency         # Process with highest latency
dstat --top-bio-adv         # Detailed block I/O per process
dstat — colored outputVisual gauges.
dstat --output report.csv  # Export to CSV for later
dstat --float               # Float numbers instead of integers
# Install dstat-colorized for colored output:
# pip install dstat-colorized

Analysis

Continuous monitoringLog for later analysis.
# Log iostat to file:
iostat -x 30 > iostat.log &
# Run for a while, then analyze
awk '/^Device/ {header=$0; next} NF {print $1, $14, $15, $16}' iostat.log | head

# dstat to CSV:
dstat --output /tmp/dstat.csv -c -d -n 10 60
Trick: detect disk saturationQuick health check.
iostat -x -z 1 3 | tail -20
# Healthy SSD: await < 5ms, %util < 50%
# Healthy HDD: await < 20ms, %util < 80%
# Saturation: await spikes, %util > 90%, svctm increases

# Check if I/O is the bottleneck:
iostat -c 1 3 | grep iowait
# %iowait > 10% → storage is suspect #1