vmstat
system monitoringLinux/Unix
The vmstat command is one of the most frequently used commands in Linux/Unix-like operating systems. vmstat Report virtual memory statistics
Quick Reference
Command Name:
vmstat
Category:
system monitoring
Platform:
Linux/Unix
Basic Usage:
vmstat [options] [arguments]
Common Use Cases
Syntax
vmstat [options] [delay [count]]
Options
| Option | Description |
|---|---|
-a, --active |
Display active and inactive memory |
-f, --forks |
Display number of forks since boot |
-m, --slabs |
Display slabinfo |
-n, --one-header |
Display header only once |
-s, --stats |
Display event counters and memory statistics |
-d, --disk |
Display disk statistics |
-D, --disk-sum |
Display disk summary |
-p, --partition device |
Display partition specific statistics |
-S, --unit character |
Define display unit (k, K, m, M) for size output |
-t, --timestamp |
Display timestamp with each update |
-w, --wide |
Use wide output format |
-V, --version |
Display version information |
-h, --help |
Display help information |
delay |
Delay between updates in seconds |
count |
Number of updates to display |
vmstat Output Fields
Procs
| Field | Description |
|---|---|
r | Number of processes waiting for run time |
b | Number of processes in uninterruptible sleep |
Memory
| Field | Description |
|---|---|
swpd | Virtual memory used (swap) |
free | Idle memory |
buff | Memory used as buffers |
cache | Memory used as cache |
inact | Inactive memory (with -a option) |
active | Active memory (with -a option) |
Swap
| Field | Description |
|---|---|
si | Memory swapped in from disk (KB/s) |
so | Memory swapped out to disk (KB/s) |
I/O
| Field | Description |
|---|---|
bi | Blocks received from a block device (blocks/s) |
bo | Blocks sent to a block device (blocks/s) |
System
| Field | Description |
|---|---|
in | Interrupts per second, including the clock |
cs | Context switches per second |
CPU
| Field | Description |
|---|---|
us | Time spent running non-kernel code (user time, including nice time) |
sy | Time spent running kernel code (system time) |
id | Time spent idle |
wa | Time spent waiting for IO |
st | Time stolen from a virtual machine |
Examples
How to Use These Examples
The examples below show common ways to use the vmstat command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Examples:
Display a snapshot of virtual memory statistics
vmstat
Display statistics every 2 seconds for 5 times
vmstat 2 5
Display statistics with unit suffixes (K, M, etc.)
vmstat -S M
Show active and inactive memory
vmstat -a
Display timestamp with each update
vmstat -t 1 3
Display disk statistics
vmstat -d