vmstat(8)
vmstat reports virtual memory statistics and system activity including processes, memory, paging, block I/O, interrupts, and CPU usage.
Synopsis
vmstat [options] [delay [count]]Description
vmstat displays one-line summaries of key system statistics including processes, memory usage (real and virtual), page swaps, block I/O operations, interrupts, and CPU time allocation. It's useful for identifying performance bottlenecks related to memory, I/O, and CPU contention.
When invoked with a delay parameter, vmstat reports statistics continuously at the specified interval in seconds. The optional count parameter limits the number of reports; without it, vmstat runs indefinitely. The first report shows averages since system boot; subsequent reports show activity during the interval.
Common options
| Flag | What it does |
|---|---|
-a | display active and inactive memory instead of buffer and cache |
-f | display the number of forks since boot |
-m | display memory statistics in megabytes |
-n | display only one header line (useful with repeated sampling) |
-p partition | display partition statistics (disk I/O for specific partition) |
-s | display a summary of memory and fork statistics since boot |
-d | display disk statistics instead of default output |
-w | widen output (wider column format for better readability) |
-t | add timestamp to each report |
--help | display help message and exit |
Examples
show system statistics every 1 second for 5 iterations (good for quick snapshots)
vmstat 1 5continuously report statistics every 2 seconds until interrupted
vmstat 2show 10 reports at 1-second intervals with a single header line for cleaner output
vmstat -n 1 10 | head -20display summary statistics since last boot including total memory, forks, and disk I/O
vmstat -sreport memory statistics in megabytes at 3-second intervals, 5 times
vmstat -m 3 5show disk I/O statistics every 1 second for 3 iterations
vmstat -d 1 3monitor active/inactive memory and process queue lengths every second
vmstat -a 1 | grep -E 'procs|r b'log system statistics every 5 seconds for 500 seconds to a file in the background
vmstat 5 100 > /tmp/vmstat.log &