Vmstat is the abbreviation of Virtual Meomory Statistics (virtual memory statistics), which can monitor the virtual memory, process, IO read and write, CPU activity of the operating system. It is to make statistics on the overall situation of the system, but the disadvantage is that it cannot conduct in-depth analysis of a certain process.
The path of the instruction: /usr/bin/vmstat
Meaning of output field:
Procs
r: The number of processes waiting for run time.
The number of processes waiting to run. If there are more processes waiting to run, it means that the CPU is very busy. In addition, if this parameter is greater than or equal to the number of logical CPUs for a long time, there may be a large bottleneck in CPU resources.
b: The number of processes in uninterruptible sleep.
The number of processes in a non-interruptible sleep state. Means that the process is blocked. Mainly refers to the number of process pairs blocked by resources (such as IO resources, paging, etc.). When this value is large, it needs to be analyzed according to the application, such as database products, middleware applications, etc.
Memory
swpd: the amount of virtual memory used.
The amount of virtual memory used. If the virtual memory is used a lot, the physical memory of the system may be tight, and appropriate measures need to be taken to reduce the use of physical memory. If swapd is not 0, it does not mean that the physical memory is tight. If swapd does not change, the values of si and so will be 0 for a long time, which is not a problem.
free: the amount of idle memory.
The size of free physical memory
buff: the amount of memory used as buffers.
The amount of memory used as buffer (caching, mainly used for block device cache), unit: KB
cache: the amount of memory used as cache.
Memory used for cache (caching, mainly used for caching files), unit: KB
inact: the amount of inactive memory. (-a option)
Total amount of inactive memory
active: the amount of active memory. (-a option)
The total amount of active memroy.
Swap
si: Amount of memory swapped in from disk (/s).
The number of swap pages from disk swap to swap virtual memory, unit: KB/sec. If this value is greater than 0 , it means that the physical memory is not enough or the memory is leaked
so: Amount of memory swapped to disk (/s).
The number of swap pages from swap virtual memory to disk, unit: KB/sec. If this value is greater than 0 , it means that the physical memory is not enough or the memory is leaked.
When there is enough memory, these two values are both 0. If these two values are greater than 0 for a long time, system performance will be affected, and disk IO and CPU resources will be consumed.
When you see that the free memory (free) is very small or close to 0, it is considered that the memory is not enough. This is incorrect. You can’t just look at this point, but also combine si and so,
If there is very little free, but very few si and so (mostly 0), then don't worry, the system performance will not be affected at this time.
When the demand for memory is greater than the amount of RAM, the server starts the virtual memory mechanism. Through virtual memory, the RAM segment can be moved to the special disk segment of SWAP DISK.
This will cause page export and page import of virtual memory. Page export does not indicate RAM bottlenecks. Virtual memory systems often page out memory segments.
However, the page import operation indicates that the server needs more memory. The page import needs to copy the memory segment from the SWAP DISK back to RAM, causing the server to slow down.
I
bi: Blocks received from a block device (blocks/s).
The number of blocks received from the block device per second, unit: block/second, which is the block reading device.
bo: Blocks sent to a block device (blocks/s).
The number of blocks sent to the block device per second, unit: block/sec. That is to write to the block device.
System
in: The number of interrupts per second, including the clock.
Number of interrupts per second, including clock interrupts
cs: The number of context switches per second.
The number of environment (context) switches per second. For example, when we call system functions, we need to perform context switching, and too many context switching will waste more cpu resources. This value should be as small as possible.
CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
User CPU time (time occupied by non-kernel processes) (unit is percentage). When the value of us is relatively high, it means that the user process consumes more CPU time
sy: Time spent running kernel code. (system time)
The CPU time used by the system (in percentage). When the value of sy is high, it indicates that the system kernel consumes a lot of CPU resources. This is not a benign performance, and we should check the reason.
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
Idle CPU time (percentage). Before Linux 2.5.41, this part includes IO wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero.
CPU time waiting for IO. Before Linux 2.5.41, this value is 0. This indicator means the time the CPU is waiting for hard disk read and write operations, expressed as a percentage. The larger the wait, the worse the IO performance of the machine. It shows that the IO wait is serious, which may be caused by a large number of random accesses to the disk, or a bottleneck (block operation) may occur on the disk.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
Use example:
1: View the help information of the vmstat command
[root@DB-Server ~]# man vmstat
2: Display active and inactive memory
[root@DB-Server ~]# vmstat -a 2 10
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free inact active si so bi bo in cs us sy id wa st
0 0 242752 56264 1294680 2365840 0 0 1 18 2 2 0 2 97 0 0
1 0 242752 56504 1294676 2365736 0 0 0 0 1010 511 0 1 100 0 0
0 0 242752 55844 1294716 2366616 0 0 0 16 1011 768 1 5 94 0 0
0 0 242752 56760 1294716 2365888 0 0 0 190 1015 554 0 1 99 0 0
0 0 242752 55472 1294744 2366636 0 0 0 0 1007 751 1 6 94 0 0
0 0 242752 56636 1294748 2365904 0 0 0 16 1009 554 0 1 99 0 0
0 0 242752 55844 1294772 2366656 0 0 0 178 1020 746 1 6 93 0 0
0 0 242752 56884 1294768 2365940 0 0 0 0 1007 543 0 1 99 0 0
1 0 242752 55208 1294816 2367220 0 0 0 206 1021 726 0 4 95 0 0
0 0 242752 56760 1294796 2365960 0 0 0 16 1009 606 0 2 98 0 0
3: Without any parameters, the vmstat command only outputs one record. This data is the average value since the last restart of the system.
[root@DB-Server ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 242752 32496 112680 2724840 0 0 1 18 3 2 0 2 97 0 0
4: Display various event counter tables and memory statistics, this display is not repeated.
[oracle@mylnx01 bdump]$ vmstat -s
33011144 total memory
32799072 used memory
24606736 active memory
6175700 inactive memory
212072 free memory
52288 buffer memory
30158708 swap cache
12582904 total swap
610348 used swap
11972556 free swap
44159969 non-nice user cpu ticks
8172 nice user cpu ticks
6077972 system cpu ticks
389217442 idle cpu ticks
40807984 IO-wait cpu ticks
123964 IRQ cpu ticks
383333 softirq cpu ticks
0 stolen cpu ticks
10331447387 pages paged in
2287459081 pages paged out
1524480 pages swapped in
1433512 pages swapped out
2358479992 interrupts
1876082783 CPU context switches
1481100317 boot time
15573677 forks
5: The length of the field can be expanded. When the memory is large, the default length is not enough to fully display the memory, which will cause the field value to shift, causing inconvenience to view
[root@DB-Server ~]# vmstat -w 2 5
procs -------------------memory------------------ ---swap-- -----io---- --system-- -----cpu-------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 243852 73556 110908 2678492 0 0 1 18 3 3 0 2 97 0 0
0 0 243852 72252 110916 2678484 0 0 0 172 1016 701 0 4 95 0 0
0 0 243852 73556 110916 2678544 0 0 0 0 1005 636 0 2 98 0 0
0 0 243852 72004 110916 2678540 0 0 0 16 1005 694 0 5 95 0 0
0 0 243852 73432 110924 2678580 0 0 0 192 1015 629 0 2 98 0 0 As shown below, due to the large value of some fields, the following offset appears, which is inconvenient to view.
[root@DB-Server ~]# vmstat 2 5
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r b swpd free buff cache si so bi bo in cs us sy id wa st
0 0 243852 79284 110928 2678640 0 0 1 18 3 3 0 2 97 0 0
0 0 243852 78988 110928 2678648 0 0 0 0 1006 753 0 5 95 0 0
0 0 243852 80400 110936 2678696 0 0 0 194 1015 565 0 1 99 0 0
0 0 243852 78352 110936 2678748 0 0 0 16 1008 680 0 5 95 0 0
0 0 243852 79532 110936 2678748 0 0 0 0 1007 669 0 2 98 0 0
[root@DB-Server ~]#
6: Display disk partition statistics (disk partition statistics)
[oracle@mylnx01 ~]$ vmstat -p sdc5 2 10
sdc5 reads read sectors writes requested writes
54270570 7234336956 8939045 276196850
54270570 7234336956 8939045 276196850
54270570 7234336956 8939050 276196978
54270570 7234336956 8939053 276197074
54270574 7234337260 8939053 276197074
54270577 7234337292 8939066 276197346
54270622 7234339700 8939066 276197346
54270622 7234339700 8939069 276197442
54270859 7234342828 8939078 276197634
54271074 7234345452 8939080 276197666
If you think this article is not bad, welcome to like, forward and share, thanks~~ https://www.cnblogs.com/feng0815/p/8613547.html