vmstat
Overview
vmstat reports virtual memory, processes, CPU, and I/O counters. Ideal for a quick “is it CPU, RAM, or disk?” loop in a terminal.
Syntax
vmstat [options] [delay [count]]Common Options
| Option | Description |
|---|---|
delay count |
Sample every delay seconds, count times |
-w |
Wide columns |
-S M |
Units (k/K/m/M) |
-a |
Active/inactive memory |
-s |
Event counters summary |
-d |
Disk stats |
-t |
Timestamp each line |
Reading the columns (classic)
| Area | Fields | Hints |
|---|---|---|
| Procs | r, b |
r > CPU count → runnable contention; b blocked on I/O |
| Memory | swpd, free, buff, cache |
Rising swpd + low free → pressure |
| Swap | si, so |
Continuous swap in/out → RAM shortage |
| IO | bi, bo |
Blocks in/out |
| System | in, cs |
Interrupts, context switches |
| CPU | us, sy, id, wa, st |
wa I/O wait; st steal (VM) |
First line is often averages since boot — prefer the subsequent sample lines when using a delay.
Examples with Explanations
Live sample
vmstat 1 10
vmstat -w 1 5Summary counters
vmstat -sDisk
vmstat -d 1 5Timestamped
vmstat -t 2 5Patterns
- High
r, highus/sy→ CPU bound
- High
borwa→ I/O bound (pair withiostat -xz)
so/sinon-zero sustained → add RAM or reduce cache pressure
- High
st→ noisy neighbor / undersized VM