vmstat
Report virtual memory statistics.
Description
Reports information about processes, memory, paging, block I/O, traps, disks, and CPU activity. The first report gives averages since the last reboot. Subsequent reports cover the sampling interval.
Inputs
/proc/stat– CPU times (user, nice, system, idle, iowait, irq, softirq, steal, guest), context switches, boot time, process forks, procs running, procs blocked, and total interrupt count from the “intr” line/proc/meminfo– memory statistics (MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree, Active, Inactive, SReclaimable)/proc/vmstat– virtual memory counters (pswpin, pswpout, pgpgin, pgpgout)/proc/uptime– system uptime in seconds (for per-second rate calculations on the first report)/proc/diskstats– per-disk I/O statistics (for-dand-Dmodes)/proc/slabinfo– slab allocator information (for-mmode)
Note: the total interrupt count is read directly from the “intr” line in
/proc/stat because the procfs crate does not expose this field.
Arguments
Positional
| Argument | Description |
|---|---|
delay | Seconds between updates (enables repeating mode) |
count | Number of updates to print (default: infinite when delay is set) |
Mode selection
These flags are mutually exclusive. If none is specified, the default VM statistics mode is used.
| Flag | Description |
|---|---|
-f, --forks | Display the total number of forks since boot and exit |
-m, --slabs | Display slabinfo |
-s, --stats | Display a table of event counters and memory statistics |
-d, --disk | Display per-disk I/O statistics |
-D, --disk-sum | Display summary of disk I/O statistics across all disks |
Display options
| Flag | Description |
|---|---|
-a, --active | Show active/inactive memory columns instead of buff/cache |
-n, --one-header | Print the column header only once, not periodically |
-S, --unit CHAR | Display unit: k (1000), K (1024, default), m (1000000), M (1048576) |
-t, --timestamp | Append a timestamp column to each output line |
-w, --wide | Wide output mode (wider columns to avoid truncation) |
-y, --no-first | Omit the first report (which shows averages since boot) |
Behavior
Default VM mode
Produces a table with the following column groups:
procs -----------memory---------- ---swap-- -----io---- -system-- --------cpu--------
r b swpd free buff cache si so bi bo in cs us sy id wa st gu
Columns:
- procs: r (runnable processes), b (blocked processes)
- memory: swpd (used swap), free (free memory), buff (buffer memory),
cache (cache memory). With
-a, buff and cache are replaced by inact (inactive memory) and active (active memory). - swap: si (swap in from disk per second), so (swap out to disk per second)
- io: bi (blocks received from block devices per second), bo (blocks sent to block devices per second)
- system: in (interrupts per second), cs (context switches per second)
- cpu: us (user), sy (system), id (idle), wa (iowait), st (steal), gu (guest) – all as percentages of total CPU time
The first report shows averages since boot, calculated using system uptime as
the elapsed interval. Subsequent reports show deltas over the sampling
interval. With -y, the first report is omitted.
Stats mode (-s)
Displays a vertical list of memory statistics (in the selected unit), followed by CPU tick counts, paging and swap counts, interrupt and context switch totals, boot time, and fork count.
Disk mode (-d)
Displays a per-disk table:
DISK TOTAL MERGED SECTORS MS TOTAL MERGED SECTORS MS CUR SEC
vda 310603 34230 25314959 94573 392788 161615 28903938 850299 0 50
The first four data columns are reads (total, merged, sectors, ms); the next four are writes; the final two are current in-flight I/O and seconds spent on I/O.
Disk summary mode (-D)
Displays aggregate totals across all disks: total disks, partitions, total reads/writes, merged reads/writes, read/written sectors, and milliseconds spent reading/writing.
Forks mode (-f)
Prints a single line with the total number of forks (from the “processes”
field in /proc/stat) since boot:
12345678 forks
Slabs mode (-m)
Displays the raw contents of /proc/slabinfo.
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Failure (cannot read proc files or invalid arguments) |
Divergences from procps-ng
- Column headers are UPPERCASE (
R,B,SWPD,FREE,SI,IN, …) rather than lowercase, matching the convention used bylsblk,lscpu, and other modern util-linux tools. - The section-grouping header line above the column names
(
procs / memory / swap / io / system / cpufor the default layout,disk / reads / writes / IOfor-d) is not emitted. Column widths are sized to fit each report’s data, which would visually misalign with a fixed-width label row.