|
The vmstat command provides information about
the status of processes, memory usage, paging statistics, system activity
and CPU usage. For tuning purposes, the process, paging and CPU are most
interesting. The first report from the command is an attempt to show
averages since the system was booted. These may or may be not meaningful,
depending on a number of factors, the most siginificant being how long
as the machine been running. In most cases this line can be discarded,
which means vmstat 2 1 is probably is the
quickest meaningful report.
vmstat 5 5
procs memory page disk faults cpu
r b w swap free re mf pi po fr de sr f0 s3 s6 -- in sy cs us sy id
0 0 0 9472 9100 0 0 1 0 1 0 0 0 0 0 0 18 861 74 8 30 62
0 0 0 182952 1980 0 1 1 0 3 0 1 0 2 0 0 39 369 75 22 78 0
0 0 0 182952 1980 0 0 0 0 0 0 0 0 0 0 0 32 284 73 21 79 0
0 0 0 182952 1980 0 0 0 0 0 0 0 0 0 0 0 33 367 76 20 80 0
0 0 0 182952 1980 0 0 0 1 1 0 0 0 0 0 0 33 425 73 21 79 0
The output fields vary from Unix to Unix but should include the following
Processes
| r |
The number of runnable processes during the interval. It
does not include processes either waiting for I/O or sleeping, ie the
number of processes that want to run but can't get a processor. |
| b |
The number of processes which are blocked. These are
processes waiting for disk I/O or other external events. High numbers of
blocked processes can indicate a problem with the disk subsystem. |
| w |
Runnable but swapped out, not shown on AIX. Thisu should always be zero.
On Solaris 2.4 and later this column is meaningless - nothing should be
inferred from any value in this column. |
Memory
| avm |
The amount of active memory. Some versions of UNIX do not compute and
display this field. This can be reported in Kbyte or pages. |
| swap |
swap amount of swap space currently available (normally Kbytes) |
| fr |
The number of pages on the free list. The amount of physical memory
that is not currently allocated to a process or I/O buffer cache. Due to
memory usage techniques, some systems consistently report a very low
value for free memory. |
| de |
Anticipated short-term memory shortfall (Kbytes), this can be
regarded as memory turn over. It can peak high but should settle back
down very quickly |
| re |
The number of currently unused frames reclaimed by the system after being
placed on the free list. On AIX 4.x this will be zero, AIX 4.x
doesn't reclaim pages |
| pi |
The number of pages per second that have been paged in. The
number includes the page-ins due to starting a process. |
| po |
The number of pages per second that have been paged out.
|
| fr |
The number of frames freed to replenish the free list. |
| sr |
The number of frames examined for page out. The virtual memory manager
uses various criteria to select which page to write to the disk. The
objective is to page out those frames that probably will not be used in
the near future. This should be less than 200 |
| cy |
The number of cycles the virtual memory manager made while scanning
the Page Frame Table in search of candidates to be placed back on the
free list. [AIX output - not shown] |
Faults
A fault is a system interrupt, either hardware or software. A device
interrupt from a disk is an example of a hardware interrupt. A system
call from an application is a software interrupt.
| in |
The number of hardware interrupts. |
| sy |
The number of system calls. A request by a program for an
I/O is an example of a system call. |
| cs |
The number of context switches. This is a count of the number
of times UNIX passes control from one process to another. |
CPU
| us |
Percentage of user state CPU time. |
| sy |
Percentage of system state CPU time. |
| id |
Percentage of time the CPU was idle. |
| wa |
Percentage of time the CPU was idle with an I/O request
pending.
|
Memory and Swap
There is a common misconception that paging should be avoided at
all costs on a the Unix system. This is not the case, Unix is the
paging based system. The problem seems to be understanding the
difference between swap and paging. Paging will occur on a perfectly
healthy system, swap should never occurred on a healthy system.
vmstat 5 5
procs memory page disk faults cpu
r b w swap free re mf pi po fr de sr f0 s3 s6 -- in sy cs us sy id
0 0 0 9472 9100 0 0 1 0 1 0 0 0 0 0 0 18 861 74 8 30 62
0 0 0 182952 1980 0 1 1 0 3 0 1 0 2 0 0 39 369 75 22 78 0
0 0 0 182952 1980 0 0 0 0 0 0 0 0 0 0 0 32 284 73 21 79 0
0 0 0 182952 1980 0 0 0 0 0 0 0 0 0 0 0 33 367 76 20 80 0
0 0 0 182952 1980 0 0 0 1 1 0 0 0 0 0 0 33 425 73 21 79 0
When the machine is restarted the amount of swap used will be minimal,
as time progresses the amount of swap used has slowly increased. Even
though the process has stopped and the memory requirement no longer
remains there might not be corresponding decrease in the swap column
vmstat. The analogy here is with Informix's
log files,
the logs files are marked as unused but are not physically cleared.
Although swap should never be used, swap must be available for process
to start successfully. As the process starts the kernel will ensure
that there is enough swap available for the swappable image to be
swapped if required. The kernel merely the checks that the space
available and reserves it, nothing is written to these pages. nbsp;
However, if there is no swap available then the reservation will be
made against physical memory, in this case the area is flagged as
unpageable. Remember the swappable image size is not the same
as the process image the size. A process will only be swapped out
in its entirety when there is a severe memory shortage, typically
when there is only three per cent of total memory available.
The main columns of interest in the vmstat are the scan and the demand
level rate. The scan rate should be typically below 200, anything
significantly higher than this can indicate a shortfall of memory.
The demand for level can be seen as the churn rate of memory, this is
allowed to peak too quite high numbers but should fall back relatively
quickly to around the hundred.
Note: the above relates to SVR4 Unix, the paging within the
other flavours of Unix does not necessarily for the same rules.
Note: these numbers should be monitored over time, a sudden spike in any of the values should not necessarily be a cause for alarm.
|