vmstat Command: Tutorial & Examples

Display performance statistics

vmstat is a command-line utility that displays information about virtual memory statistics in a computer running Unix or Linux. The information provided by vmstat includes details about processes, memory usage, paging, block input/output, and CPU activity.

The basic syntax for using vmstat is:

vmstat [options] [delay [count]]

The options allow you to specify which statistics you want to see, and the delay and count parameters allow you to specify how frequently vmstat should update the display and for how many times.

By default, vmstat displays a summary of virtual memory statistics, including the following information:

  • procs: The number of processes in the system, including both running and blocked processes.
  • r: The number of processes waiting for run time.
  • b: The number of processes in uninterruptible sleep.
  • memory: Information about memory usage, including total available memory, used memory, and free memory.
  • swap: Information about swap space usage, including total swap space, used swap space, and free swap space.
  • io: Information about block input/output, including the number of blocks read from and written to disk.
  • system: Information about CPU activity, including the number of interrupts per second and the number of context switches per second.
  • cpu: Information about CPU utilization, including the percentage of time spent in user mode, system mode, and idle.

Typical output may look like this:

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
13  0 1686016 263224 500408 7675080    0    0    18   128    0    0 54  2 44  1  0

You can use vmstat to monitor the performance of your system and identify potential bottlenecks or issues with resources such as memory, CPU, or disk I/O. By running vmstat over time and observing changes in the statistics, you can get a better understanding of how your system is being used and identify areas where you might need to make adjustments or optimizations.

CleverUptime uses the raw data from /proc/vmstat to detect performance problems on your server or VM.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA