Report virtual memory, CPU, and I/O statistics.
low risk
vmstat provides a snapshot or continuous stream of system resource statistics: processes, memory, swap, block I/O, and CPU time. Ideal for diagnosing high CPU wait (wa column) indicating I/O bottlenecks, or high swap usage.
| Flag | Meaning |
|---|---|
-a --active | Show active/inactive memory |
-s --stats | Print memory event statistics table |
-d --disk | Show disk statistics |
vmstat 1 5Sample every 1 second, 5 times · explain & risk-check →vmstat -sShow comprehensive memory statistics table · explain & risk-check →vmstat -dShow disk read/write statistics · explain & risk-check →vmstat 2 | awk 'NR>2 {print $15}' | awk '{sum+=$1} END {print sum/NR"%"}'Calculate average CPU idle over time · explain & risk-check →Watch the 'wa' (I/O wait) column in `vmstat 1` — consistently above 10-15% indicates disk is the bottleneck, not CPU. This is often misread as a CPU problem.
Reference text is hand-written and may be incomplete — check man vmstat for your version. Test destructive commands on a non-production system first.