vmstat – Display virtual memory status

The vmstat command is a Linux utility that provides a report on the system’s virtual memory statistics. It displays information about the system’s memory usage, I/O operations, and CPU activity. The command can be used to monitor system performance and diagnose problems.

Overview

The vmstat command displays a summary of virtual memory statistics. It reports the following information:

  • The number of processes running on the system
  • The number of processes waiting for CPU time
  • The amount of free memory available on the system
  • The amount of memory being used as a disk cache
  • The amount of memory being used as a buffer cache
  • The amount of memory being used by the kernel
  • The amount of memory being used by user processes
  • The number of disk I/O operations per second
  • The number of system calls per second
  • The CPU utilization percentage

To run the vmstat command, open a terminal window and type:

vmstat [options] [delay] [count]
  • options: Optional arguments that modify the output of the command.
  • delay: Optional delay between each report in seconds.
  • count: Optional number of reports to display.

For example, to display a report every two seconds, type:

vmstat 2

To display five reports with a delay of one second between each report, type:

vmstat 1 5

Options

The vmstat command supports several options that modify the output of the command. The available options are:

Option Description
-a Display active and inactive memory information.
-d Display disk statistics.
-f Display the number of forks since boot.
-m Display slab and page cache memory statistics.
-n Display network statistics.
-p Display process-related statistics.
-s Display system statistics.
-t Display timestamp information.
-w Display swap statistics.

Troubleshooting Tips

  • If vmstat shows high CPU utilization, identify the process that is consuming the most CPU time using the top command.
  • If vmstat shows high disk I/O operations, identify the process that is performing the most I/O operations using the iotop command.
  • If vmstat shows high memory usage, identify the process that is consuming the most memory using the top command.

Notes

  • The vmstat command is part of the procps-ng package, which should be installed by default on most Linux distributions.
  • The output of the vmstat command may vary depending on the version of the command and the Linux distribution being used.