Linux Command -- vmstat, linuxvmstat
Vmstat -- Virtual Memory Statistics (Virtual Memory Statistics)
1. Role
Detects system resource changes, including CPU, memory, and disk input/output status.
2. Usage
Vmstat [parameter] [interval seconds] [detection times]
Parameters:
-A: inactive/active (active or not) is used to replace the Memory output information of buffer/cache;
-F: Number of processes that the system has copied (fork) since the startup;
-S: lists the memory changes caused by some events (BOOT till now;
-S: It can be followed by units, so that the displayed data has units. For example, K/M replaces bytes capacity;
-D: list the total read/write volume of a disk;
-P: The partition is listed later, and the total read/write count of the partition is displayed.
3. Example
3.1 vmstat
Display virtual memory usage:
Field description:
1) procs Process
R: Number of processes waiting for running;
B: Number of processes that cannot be awakened.
The more these two options, the more busy the system (because the system is too busy, so many processes cannot be executed or remain waiting and cannot be awakened ).
2) memory
Swpd: The capacity used by the virtual memory;
Free: memory capacity not used;
Buff: Used to buffer memory;
Cache: Used to tell the cache.
3) swap memory swap space
Si: number of programs retrieved from the disk;
So: the capacity to write unused programs to the disk's swap due to insufficient memory.
If the si/so value is too large, it indicates that the data in the memory is often transferred between the disk and the memory, and the system performance will be poor.
4) read and write io Disks
Bi: number of blocks written by the disk;
Bo: number of blocks written to the disk.
If the value is higher, the system IO is very busy.
5) system
In: Number of interrupted processes per second;
Cs: Number of event switches per second.
A larger value indicates that the system frequently communicates with interface devices, including disks, NICS, and clocks.
6) cpu
Us: The CPU usage status of the non-kernel layer. When the value of us is high, it indicates that the user process consumes more CPU time;
Sy: the CPU status used by the kernel layer. When the sy value is high, it indicates that the system kernel consumes many CPU resources;
Id: idle status;
Wa: CPU status consumed by waiting for IO. When the value of wa is high, the IO wait is serious, which may be caused by a large number of random access to the disk, disk bottlenecks may also occur (block operations );
St: the CPU usage status stolen by the virtual machine.
3.2 vmstat 1 3
1 time per second, 3 times in total:
3.3 vmstat-
Use inactive/active to replace buffer/cache:
3.4 vmstat-f
Number of processes that have been copied to the system (fork) since boot:
3.5 vmstat-s
A list of Memory changes caused by some events (BOOT till now:
3.6 vmstat-S M
Displayed in MB:
3.7 vmstat-d
List the total read/write volume of a disk:
3.8 vmstat-p/dev/sda1
Displays the total read/write count statistics for this partition: