You can use the vmstat command to report virtual memory statistics and such information about system events as CPU load, paging, number of context switches, device interrupts, and system calls. The vmstat command can also display statistics on swapping, cache flushing, and interrupts.
Refer to vmstat(1M) for a more detailed description of this command.
Collect virtual memory statistics using the vmstat command with a time interval.
$ vmstat n |
-n |
Interval in seconds between reports. |
Table 64-1 describes the fields in the vmstat output.
Table 64-1 Output From the vmstat Command
Category |
Field Name |
Description |
---|---|---|
procs |
|
Reports the following states: |
|
r |
The number of kernel threads in the dispatch queue |
|
b |
Blocked kernel threads waiting for resources |
|
w |
Swapped out LWPs waiting for processing resources to finish |
memory |
|
Reports on usage of real and virtual memory: |
|
swap |
Available swap space |
|
free |
Size of the free list |
page |
|
Reports on page faults and paging activity, in units per second: |
|
re |
Pages reclaimed |
|
mf |
Minor and major faults |
|
pi |
Kbytes paged in |
|
po |
Kbytes paged out |
|
fr |
Kbytes freed |
|
de |
Anticipated memory needed by recently swapped-in processes |
|
sr |
Pages scanned by page daemon (not currently in use). If sr does not equal zero, the page daemon has been running. |
disk |
|
Reports the number of disk operations per second, showing data on up to four disks |
faults |
|
Reports the trap/interrupt rates (per second): |
|
in |
Interrupts per second |
|
sy |
System calls per second |
|
cs |
CPU context switch rate |
cpu |
|
Reports on the use of CPU time: |
|
User time |
|
|
System time |
|
|
The following example shows the vmstat display of statistics gathered at five-second intervals.
$ vmstat 5 procs memory page disk faults cpu r b w swap free re mf pi po fr de sr f0 s3 -- -- in sy cs us sy id 0 0 8 28312 668 0 9 2 0 1 0 0 0 1 0 0 10 61 82 1 2 97 0 0 3 31940 248 0 10 20 0 26 0 27 0 4 0 0 53 189 191 6 6 88 0 0 3 32080 288 3 19 49 6 26 0 15 0 9 0 0 75 415 277 6 15 79 0 0 3 32080 256 0 26 20 6 21 0 12 1 6 0 0 163 110 138 1 3 96 0 1 3 32060 256 3 45 52 28 61 0 27 5 12 0 0 195 191 223 7 11 82 0 0 3 32056 260 0 1 0 0 0 0 0 0 0 0 0 4 52 84 0 1 99 |
Run vmstat -s to show the total of various system events that have taken place since the system was last booted.
$ vmstat -s 0 swap ins 0 swap outs 0 pages swapped in 0 pages swapped out 1329913 total address trans. faults taken 25270 page ins 3787 page outs 38082 pages paged in 13417 pages paged out 3034 total reclaims 3033 reclaims from free list 335879 micro (hat) faults 994034 minor (as) faults 24210 major faults 300634 copy-on-write faults 141744 zero fill page faults 34341 pages examined by the clock daemon 5 revolutions of the clock hand 28134 pages freed by the clock daemon 11174 forks 1259 vforks 9086 execs 11479519 cpu context switches 95234544 device interrupts 1426943 traps 9100502 system calls 1939346 total name lookups (cache hits 88%) 496 toolong 185566 user cpu 977189 system cpu 92045953 idle cpu 130914 wait cpu |
Run vmstat -S to show swapping statistics.
$ vmstat -S procs memory page disk faults cpu r b w swap free si so pi po fr de sr f0 s1 s3 -- in sy cs us sy id 0 0 0 6224 5536 0 0 0 0 0 0 0 0 0 0 0 2 9 12 0 1 99 |
The additional fields are described in Table 64-2.
Table 64-2 Output From the vmstat -S Command
Field Name |
Description |
---|---|
si |
Average number of LWPs swapped in per second |
so |
Number of whole processes swapped out |
The vmstat command truncates the output of both of these fields. Use the sar command to display a more accurate accounting of swap statistics.
Run vmstat -c to show cache flushing statistics for a virtual cache.
$ vmstat -c flush statistics: (totals) usr ctx rgn seg pag par 14512 20201 0 1811 1857286 815505 |
It shows the total number of cache flushes since the last boot. The cache types are described in Table 64-3.
Table 64-3 Output From the vmstat -c Command
Cache Name |
Cache Type |
---|---|
usr |
User |
ctx |
Context |
rgn |
Region |
seg |
Segment |
pag |
Page |
par |
Partial-page |
Run vmstat -i to show interrupts per device.
$ vmstat -i |
The following example shows output from the vmstat -i command.
$ vmstat -i interrupt total rate --------------------------------- clock 104638405 100 esp0 2895003 2 fdc0 0 0 --------------------------------- Total 107533408 102 |