Vmstat: Reports virtual memory statistics
Purpose: The vmstat Command reports statistics about Kernel threads, virtual memory, disks, traps, and CPU activity. Reports generated by the vmstat command can be used to balance system load activities. The statistical information within the system range (in all processors) calculates the average value in percentage or calculates its sum.
Usage: vmstat [-V] [-N] [latency [times]
The main options are as follows.
-N: The switch only displays the information for the first time, instead of periodically generating the information.
Latency: refresh interval in seconds. If this delay time is not provided, only the average value from system startup to the present is displayed.
Number of times: the number of updates. If the latency is defined without a specified number of times, the default value of the number is infinite.
-V: The switch can be used to output the version information of the command.
The application example is as follows.
Run the vmstat 5 5 command to test:
-
- # Vmstat 5 5
- Procs memory swap Io system CPU
-
- R B W SWPD free buff cache Si so Bi Bo in CS us Sy ID
- 0 0 0 0 32188 6412 0 47252 47 200 89 8 6 85
-
- 0 0 0 0 32188 6420 0 0 0 6 47252 20 0 101
- 0 0 0 0 32188 6420 0 0 0 47252 19 0 0 101
-
- 0 0 0 0 32188 6420 0 0 0 47252 20 0 0 101
- 0 0 0 0 32188 6420 0 0 0 47252 22 0 0 101
The result is a summary of the data, which can reflect the real system situation. The vmstat command output is divided into six parts.
(1) process procs
R: Number of processes waiting in the running queue.
B: Number of processes waiting for I/O.
W: processes that can enter the running queue but are replaced.
(2) Memory
SWPD: available swap memory, in KB.
Free: idle memory, in KB.
Buff: the number of memories in the buffer, in KB.
Cache: The amount of memory used as the cache, measured in KB.
(3) Swap switching page
Si: Number of swap pages from disk swap to memory, measured in kb/s.
So: the number of swap pages from memory swap to disk, measured in kb/s.
(4) I/O BLOCK Devices
BI: The number of blocks sent to the block device. The unit is block/second.
Bo: number of blocks received from the block device. Unit: block/second.
(5) System
In: The number of interrupts per second, including clock interruptions.
CS: the number of environment (context) switches per second.
(6) CPU central processor
CS: the time used by the user process, expressed in percentage.
Sy: the time used by the system process, in percent.
ID: the idle time of the central processor, expressed in percentage.
If R is often greater than 4 and the ID is often less than 40, the central processor is under heavy load. If Bi and Bo are not equal to 0 for a long time, the physical memory capacity is too small.