Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the vmstat command

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use the vmstat command, the article is very detailed, has a certain reference value, interested friends must read it!

The vmstat command is the most common Linux/Unix monitoring tool, which can show the status value of the server at a given time interval, including server CPU utilization, memory usage, virtual memory swap, IO read and write.

The vmstat tool provides a low-overhead way to observe system performance. (1) usage: vmstat [option parameters] or vmstat [option parameters] [number] [number] (2) function: function: report statistics of virtual memory, about the overall running status of the system, such as process, memory, and so on. (3) option parameter:\ 1)-d: displays disk-related statistics. \ 2)-a: shows active and inactive memory\ 3)-f: shows the number of fork since the system was started. \ 4)-p: displays specified disk partition statistics\ 5)-s: displays memory-related statistics and multiple system activity. \ 6)-m: displays the slabinfo (4) instance:

1) vmstat displays virtual memory usage linuxidc@linuxidc:~$ vmstatprocs-memory- swap---io-----system---cpu-r b swap free cache si so bi bo in cs us sy id wa st4 0 156252 61016 871752 0 76 29 53 138 1 98 0

Field description:

1.Procs (process)

R: the number of processes in the run queue, which can also determine whether CPU needs to be increased. (long-term greater than 1)

B: the number of processes waiting for IO.

2.Memory (memory)

Swpd: use virtual memory size, if the value of swpd is not 0, but the value of SI,SO is 0 for a long time, this situation will not affect system performance.

Free: the amount of free physical memory.

Buff: the amount of memory used as a buffer.

Cache: the amount of memory used for caching. If the value of cache is large, it means that there are a large number of files at cache. If frequently accessed files can be accessed by cache, then the read IO bi of the disk will be very small.

3.Swap

Si: the amount of memory written from the swap area to memory per second, transferred from disk to memory.

So: the amount of memory written to the swap area per second, transferred from memory to disk.

Note:

When there is enough memory, both values are 0. If these two values are greater than 0 for a long time, the system performance will be affected, and disk IO and CPU resources will be consumed. Some friends see free memory (free) very little or close to 0, they think that memory is not enough, can not just look at this point, but also combine si and so, if free is very little, but si and so are also very few (mostly 0), then do not worry, system performance will not be affected at this time.

4.IO (the current Linux version block size is 1kb)

Bi: number of blocks read per second

Bo: number of blocks written per second

Note:

When reading and writing to a random disk, the higher these two values (for example, more than 1024k), the greater the value that you can see CPU waiting for in IO.

5.system (system)

In: interrupts per second, including clock interrupts.

Cs: context switches per second.

Note:

The higher the above two values, the more CPU time you will see consumed by the kernel.

6.CPU (as a percentage)

Us: when the percentage of user process execution time (user time) us is relatively high, it means that the user process consumes more CPU time, but if the long-term use exceeds 50%, then we should consider optimizing the program algorithm or speeding up.

Sy: when the percentage of process execution time (system time) sy of the kernel system is high, it means that the system kernel consumes a lot of CPU resources, which is not a benign performance. We should check the reason.

Wa: when the percentage of IO wait time wa is high, the IO wait is serious, which may be caused by a large number of random access to the disk, or there may be a bottleneck on the disk (block operation).

Id: percentage of idle time

2) display statistics of system memory linuxidc@linuxidc:~$ vmstat 2procs-memory- swap---io-----system---cpu-r b swap free cache si so bi bo in cs us sy id wa st4 0 113256 61612 889820 0 0 74 29 53 143 11 98 0 00 00 113256 61612 889820 00 00 60 209 11 99 0 00 00 113256 61620 889820 00 08 52 157 01 99 0 01 00 99976 61620 890356 00 00 367 2337 31 7 63 0 01 00 99724 61620 890356 00 00 534 2508 35 9 56 0 02 00 99724 61620 890340 00 00 150 845 10 3 87 0 015 00 97196 61660 890368 0 134 78 464 162 82 00 109388 61680 890208 0 162 526 4604 37 12 51 0 03), Vmstat displays system memory statistics every two seconds A total of 5 times

Linuxidc@linuxidc:~/ Desktop / www.linuxidc.com$ vmstat 2 5 procs-memory-----swap- io---system- cpu-- RB Exchange Free buffer si so bi bo in cs us sy id wa st 500 111612 61776 889992 889992 74 29146 11 98 000 111360 617706 617706 000 58 201 11 99 000 0 111360 61784 8884 0012 54 16198 1 0 0 0 111360 61784 889992 0 0 0 55 163 11 98 0 0 0 111360 61784 889992 0 0 0 52 155 11 99 0 0

4), Vmstat-d displays information about the disk linuxidc@linuxidc:~/ desktop / www.linuxidc.com$ vmstat-ddisk--reads--writes--IO- total amount of merged sector ms total amount of merged sector ms cur secloop0 43 0 676 447 0 0 0 0loop1 38 0 226 450 0 0 0 0loop2 54 0 2124 998 0 0 0 0loop3 42 0 674 695 0 0 0 0loop4 37 0 664 117 0 0 0 0 0loop5 44 0 678 549 0 0 0 0loop6 40 0 230 127 0 0 0 0loop7 62 0 2140 846 0 0 0 0sda 23949 3166 1621538 221257 9490 10847 654856 221706 0 117sr0 35 0 2132 64 0 0 0 0loop8 1438 0 4802 27055 0 0 0 2loop9 216 0 2476 2324 0 0 0 0loop10 40 0 670 567 0 0 0 0loop11 92 0 2162 2091 0 0 0 0 0loop12 39 0 668 579 0 0 0 0loop13 54 0 2152 647 0 0 0 0loop14 47 0 2132 871 0 0 0 0loop15 64 0 2126 51 0 0 0

Merged: indicates that a write / read request comes from a merge, and the system generally combines multiple connection / adjacent read / write requests together.

5), vmstat-a shows active memory and inactive memory

When using the-an option to display active and inactive memory, the display is the same as in example 1, except for the addition of inact and active.

Linuxidc@linuxidc:~/ desktop / www.linuxidc.com$ vmstat-aprocs-memory- swap---io-----system---cpu-r b exchange inactive si so bi bo in cs us sy id wa st4 0 99324 408308 1046888 0 0 72 29 55 153 Introduction to the actual operation of the 1 98 0 0Linux vmstat command introduction to the actual operation of the Linux vmstat command 6) Vmstat-f to see how many times the system has been fork

Linuxidc@linuxidc:~/ Desktop / www.linuxidc.com$ vmstat-f 5100 forks

7), vmstat-p tmpfs to view the linuxidc@linuxidc:~/ desktop of a specific disk device / www.linuxidc.com$ vmstat-p / dev/sda1sda1 reads read sectors writes requested writes23879 1617802 10140 668056

Description: this information is mainly from / proc/diskstats. Reads: the number of reads from this partition. Read sectors: the number of times sectors are read from this partition. Writes: the number of writes from this partition. Requested writes: the number of write requests from this partition.

8), vmstat-m displays slabinfo

Linuxidc@linuxidc:~/ Desktop / www.linuxidc.com$ sudo vmstat-m

The above is all the contents of this article "how to use vmstat commands". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report