vmstat
| vmstat | ||||||||||||||||||||||||||||||||||||||||
|
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
Memory
FaultsA 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.
CPU
Memory and SwapThere 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. |