Demystifying VMSTAT

Vmstat, or virtual memory statistics, is one of the useful UNIX command an administrator can (always) use to check the performance of a server. This is specially useful to determine how a particular UNIX box is doing during it’s peak usage time. It shows information about various system resources and their related performance problems.

An example output of this command is shown below:

% vmstat 1 8   	Write a report every second for 5 seconds.  procs  memory           page             faults        cpu   	  

-- --- -------- ---- ----   	  

r  b avm   fre re  pi  po  fr   sr  cy  in  sy  cs us sy id wa   	  

1  0  4680 365  0   0   0   1    3   0 123 102  75  0  2 97  1   	  

1  0  4680 364  0   0   0   0    0   0 121  86  67  0  3 76 21   	  

1  0  4680 364  0   0   0   0    0   0 114  70  28  1  0 99  0   	  

1  0  4680 364  0   0   0   0    0   0 123  70  32  2  0 98  0   	  

1  0  4680 364  0   0   0   0    0   0 114  74  28  1  0 99  0   	  

1  0  4680 364  0   0   0   0    0   0 113  84  67  0 21 69 10   	  

1  0  4680 364  0   0   0   0    0   0 127  78  56  8  9 82  1   	  

1  0  4680 364  0   0   0   0    0   0 119  91  71  0  3 86 11   	  

That is a lot of numbers. What does the out of VMSTAT means anyway?

In a Nutshell

The command produces information (for the least) about virtual memory (swap), CPU usage, and disk usage. In my case, most of the stats that I frequently checked when users complain are CPU and memory usage.

The Details

There are five main column in a vmstat output – proc, memory, paging, faults, CPU.

The first two columns under procs (or kernel thread on some UNIX) show the number of processes on the system.

  • Column r shows “runable” or active processes – the value of this should be less than or equal to the number of processor.
  • Column b shows “blocked” processes awaiting a resource such as input/output.

(more stuff here….)

The Syntax

The command vmstat takes two arguments, one for how long to wait between reports and the second for how many reports to write out before quitting.

Example:

# vmstat 1 8

produces 8 output (lines) in every one second interval. Omitting the second argument, vmstat will not stop displaying output on the screen until a break is sent (usually CNTRL+D or Z or C)

Final Words

Read some more.

You should check out vmstat’s man page (man vmstat command) to get the details for your system. Since usage and output may vary from one operating system to another.

Leave a Reply

Your email address will not be published. Required fields are marked *