Job Statistics: vmstat
Next: I/O Statistics: iostat
Up: Managing the System
Previous: Processes: ps
The command vmstat produces information about virtual memory,
CPU usage, and disk usage. This is useful for determining if your
system is properly configured and if your programs are paging
extensively. 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:
% 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
The actual form of the output may vary somewhat from this, and
again you should issue the man vmstat command to get the
details for your system.
To help understand this output, we examine some of the fields.
- The
first two columns under procs show the number of processes on
the system.
- Column r shows ``runable'' or active processe.,
- Column b shows ``blocked'' processes awaiting a resource
such as input/output.
- Under memory:
- The avm column under memory
denotes active virtual memory,
- that is, memory which resides on
the slow, hard disk and not in the fast electronics. The number in the avm
column is the number of pages, usually of 4 MB size, being used by
that process. This is a good indication of how much memory your
system is using; if this number is significantly larger that the size
of RAM in your computer, then the system may be spending too much time
reading data onto and back from the hard disk (paging). In these
cases performance could be increased by adding more RAM.
-
The fre column under memory in the listing is the number of pages,
again of 4 MB size, of RAM that is unused.
- This is, however,
an unreliable measure of free memory since the table of free pages is
not updated until the system needs more pages.
The page columns in the vmstat listing tracks the
paging activity of the system.
- This is a specific measure of how
virtual memory is being used by your system. The ``page in'' and
``page out'' subcolumns, pi and po, tell how many pages of
virtual memory are being read in from disk or written out to disk.
While some paging activity is normal during program startup, if there
is such extensive enough use of virtual memory as to make pi
and po nonzero for extended periods of time, then the system
has too little RAM to satisfy the needs of all programs during these
periods.
The columns in the vmstat listing under cpu indicate
how the CPU is spending its time. The numbers are the
percentages of CPU time for the past interval spent on:
- us ``user time,''
- that is, doing things like running calculations,
manipulating data, and drawing graphics and the normal activities of
user programs;
- sy ``system time,''
- that is, kernel activities such as input/output;
- id ``idle time,''
- that is, something we all wish we had more of;
- wa ``wait time,''
- that is, the time spent waiting on a device to be ready,
usually for input/output. A system well matched with its CPU should
spend most of its time
in users' work since they are the ones paying the bills. While programs
containing lots of I/O can push the system time up, in normal use it
should be low, say below 33%, even when the system is transferring
large files.
It is illuminating to start vmstat before submitting a
large, numerically intensive program and then redirect vmstat's output into a file you can study later. As you observe the
reports issued by vmstat every few seconds, you should be able
to see how well the system preformed while running your program and
possibly spot problems like excessive paging or input/output.
Next: I/O Statistics: iostat
Up: Managing the System
Previous: Processes: ps