How to monitor the Virtual Memory by using the ‘vmstat’ command

This article provides information on how to monitory the Virtual Memory by using the vmsat command.

Usage of vmstat for troubleshooting:

  • Identifying high CPU usage.
  • Monitoring the Virtual Memory in real-time.
  • Monitoring the system performance.

The vmstat command, as its name suggests, reports the virtual memory statistics. It shows how much virtual memory is present, how much is free, and paging activity. Most importantly, it prints page-ins and page-outs, as they occur.

To monitor the virtual memory activity on your system, it is best to use vmstat with a delay. A delay is the number of seconds between updates. Five seconds is the recommended delay interval. By default, vmstat displays the following information just once:
procs Information about the numbers of processes in various states.

To monitor the virtual memory activity on your system, it is best to use vmstat with a delay. A delay is the number of seconds between updates. If you do not provide a delay, vmstat will report the averages from the last boot and quit. Five seconds is the recommended delay interval.

The command has to be issued from the shell, as shown below:

To run vmstat with a five second delay, type:

To stop the vmstat process, use the break character (^C or Control+C), as shown above.

You can specify a count, which indicates how many updates should be printed; before vmstat quits. If the count is not explicitly mentioned, the count defaults to infinity; but the same can be terminated with Ctrl-C.

To run vmstat with ten updates, five seconds apart, type:

The summary option (-s) sends a summary report in the standard output, starting from system initialization expressed in absolute counts; rather than on an interval basis.

The recommended way to use these statistics is to run this command before a workload, save the output, run it again after the workload, and save the output. The next step is to determine the difference between the two sets of output.

About the author

Prasanna

Leave a Comment