Home·Terminal commands

vmstat

Processes and system

Usage

vmstat <interval> [count]

Prints memory, swap, disk and CPU counters at a fixed interval; throw away the first line, which is an average since boot rather than now, and look at the si/so and wa columns first.

Common flags

FlagMeaning
vmstat 1 5Five samples, one second apart.
-sA one-off table of memory counters since boot.
-wWide columns, so the numbers stop colliding.
-dPer-disk statistics instead of the summary.
si / soSwap in and out. Anything sustained here means real memory pressure.
waPercentage of time the CPU sat waiting for disk.

Examples

vmstat 1 5

Five one-second samples; ignore the first line.

vmstat -w 2

Keep sampling every two seconds with readable columns.

What is running and what is eating the machine. Identifying it comes before killing it.

How to read this

  • Square brackets [ ] mark a part you may leave out.
  • An ellipsis … means you can list more than one.
  • Flags are case-sensitive — in some commands -r and -R do different things.

Questions

Q. What does vmstat do?

Prints memory, swap, disk and CPU counters at a fixed interval; throw away the first line, which is an average since boot rather than now, and look at the si/so and wa columns first.

Q. How do I type it?

vmstat <interval> [count] — square brackets mark the parts you can leave out.

Q. How many flags are worth knowing?

6 are listed here; the full set is in man vmstat. This command sits under Processes and system.

Related commands

man page: man vmstat