In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use vmstat in the Linux command. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Vmstat, which stands for Virtual Meomory Statistics (Virtual memory Statistics), is a real-time system monitoring tool used to obtain information about processes, virtual memory, page swap space, and CPU activities. This information reflects the load of the system; this command Linux/Unix is supported, and compared to top, you can see the CPU, memory, and IO usage of the entire machine through this command, rather than just see the CPU utilization and memory utilization of each process (usage scenarios are different).
1. Command format
Vmstat [- a] [- n] [- S unit] [delay [count]]
Vmstat [- s] [- n] [- S unit]
Vmstat [- m] [- n] [delay [count]]
Vmstat [- d] [- n] [delay [count]]
Vmstat [- p disk partition] [- n] [delay [count]]
Vmstat [- f]
Vmstat [- V]
2. Command parameters
-a: displays active and inactive memory
-f: displays the number of fork since the system was started.
-m: display slabinfo
-n: displays each field name only once at the beginning.
-s: displays memory-related statistics and a variety of system activity.
Delay: refresh interval. If not specified, only one result is displayed.
Count: number of refreshes. If you do not specify the number of refreshes, but specify the refresh interval, the number of refreshes is infinite.
-d: displays disk-related statistics.
-p: displays the specified disk partition statistics
-S: displays in the specified units. The parameters are k, K, m, M, which represent 1000, 1024, 1000000, and 1048576 bytes (byte), respectively. The default unit is K (1024 bytes)
-V: displays vmstat version information.
3. Use examples
[root@seaing ~] # vmstat
Procs-memory--swap---io-----system---cpu-
R b swpd free buff cache si so bi bo in cs us sy id wa st
00 0 15700892 181712 385304 00 4 11 30 26 00 100 00
[root@seaing] # vmstat-a
Procs-memory--swap---io-----system---cpu-
R b swpd free inact active si so bi bo in cs us sy id wa st
00 0 15700892 272456 344768 00 4 11 30 26 00 100 00
-- collect server status every 2 seconds for a total of 6 times
[root@seaing ~] # vmstat 2 6
Procs-memory--swap---io-----system---cpu-
R b swpd free buff cache si so bi bo in cs us sy id wa st
00 0 15701016 181712 385308 00 4 11 32 26 00 100 00
00 0 15701016 181712 385308 00 00 1015 72 00 100 00
00 0 15701016 181712 385308 00 00 1016 71 00 100 00
00 0 15701016 181712 385308 00 0 14 1016 76 00 100 00
00 0 15701008 181712 385308 00 00 1014 73 00 100 00
00 0 15701008 181712 385308 00 00 1019 70 00 100 00
Description:
Category
Project
Meaning
Description
Procs (process)
R
Number of tasks waiting for execution
Shows the number of tasks that are executing and waiting for cpu resources. When this value exceeds the number of cpu, a cpu bottleneck occurs.
This also has something to do with the load of top. Generally, if the load exceeds 3, it is high, if it exceeds 5, it is high, and if it exceeds 10, it is abnormal. The state of the server is very dangerous. The load of top is similar to the run queue per second. If the running queue is too large, it means that your CPU is very busy, which generally results in high CPU utilization.
B
Number of processes waiting for IO
It can also be understood as the number of blocked processes.
Memory (memory)
Swpd
Virtual memory size is being used, in k
The size of the virtual memory that has been used, if it is greater than 0, indicates that your machine is out of physical memory. If it is not the cause of the program memory leak, then you should upgrade the memory or migrate memory-consuming tasks to other machines.
Free
The size of free physical memory
Buff
The size of the buff used to buffer the read and write of the block device
Cache
Cache size used, cache of the file system
Cache is directly used to memorize the files we open and buffer them. (here is the cleverness of Linux/Unix. Taking part of the free physical memory to cache files and directories is to improve the performance of program execution. When the program uses memory, buffer/cached will be used quickly.)
Swap
Si
Amount of virtual memory read from disk per second (in kb/s)
If this value is greater than 0, it means that there is not enough physical memory or there is a memory leak. Find a memory-consuming process to solve it.
So
Size of virtual memory written to disk per second
If this value is greater than 0, same as above
IO
Bi
Blocks read per second (read disk)
Block devices here refer to all disks and other block devices on the system. The default block size is 1024byte.
Bo
Number of blocks written per second (write disk)
For example, if we read a file, the bo should be greater than 0. Bi and bo are generally close to 0, or IO is too frequent and needs to be adjusted.
System
In
Number of interrupts per second of CPU, including clock interrupts
The higher these two values, the more cpu time will be consumed by the kernel.
Too many context switching times means that most of your CPU is wasted on context switching, resulting in less time for CPU to do serious things, and CPU is not fully utilized, which is not advisable.
Cs
Context switches per second
CPU (as a percentage)
Us
Cpu time consumed by user process execution (user time)
When the value of us is high, it means that the user process consumes more cpu time, but if the long-term use is more than 50%, then we should consider optimizing the program algorithm or other measures.
Sy
Cpu time consumed by system processes (system time)
When the value of sys is too high, it means that the system kernel consumes a lot of cpu resources, which is not a benign performance, and we should check the reason.
Id
Idle time (including IO wait time)
Generally speaking, id + us + sy = 100. generally speaking, I think id is the idle CPU utilization, us is the user CPU utilization, and sy is the system CPU utilization.
Wa
Waiting time for IO
When the wa is too high, the io wait is serious, which may be caused by a large number of random access to the disk, or it may be the bottleneck of the disk bandwidth.
-- display disk-related statistics
[root@seaing ~] # vmstat-d
Disk--reads--writes--IO-
Total merged sectors ms total merged sectors ms cur sec
Ram0 0 0 0
Ram1 0 0 0
Ram2 0 0 0
Ram3 0 0 0
Ram4 0 0 0
Ram5 0 0 0
Ram6 0 0 0
Ram7 0 0 0
Ram8 0 0 0
Ram9 0 0 0
Ram10 0 0 0
Ram11 0 0 0
Ram12 0 0 0
Ram13 0 0 0
Ram14 0 0 0
Ram15 0 0 0
Sda 19755 13057 834627 82098 488536 207361 5567304 207387 0 161
Sdb 941 2526 5713 361 842 70921 143526 2720 0 0
Sdc 449 191 2711 75 0 0 0
Sdd 237174 194 1896535 22173 1874 233855 1885832 328146 0 24
Sde 868 1757 4251 277 760 71240 144000 3584 00
Sdf 414 101 1711 34 0 0 0
Sdg 22910 101 181679 4143 189 22314 180024 32323 0 4
Sdh 877 1748 4251 84 623 71377 144000 65594 00
Sdi 418 95 1695 47 0 0 0
Sdj 22417 95 177687 2323 192 22797 183912 79565 0 3
Disk--reads--writes--IO-
Total merged sectors ms total merged sectors ms cur sec
Sdk 881 2145 4879 204 615 70984 143204 65317 0 0
Sdl 414 101 1711 30 0 0 0
Sdm 22413 101 177703 4086 186 21814 176000 75456 0 4
Dm-0 30821 0 829946 324147 695909 0 5567272 681182 0 161
Dm-1 112 0 896 905 0 0 0
Sr0 0 0 0
Md0 0 0 0
Loop0 0 0 0
Loop1 0 0 0
Loop2 0 0 0
Loop3 0 0 0
Loop4 0 0 0
Loop5 0 0 0
Loop6 0 0 0
Loop7 0 0 0
-- View the resource usage of the partition
[root@seaing] # vmstat-p / dev/sda1
Sda1 reads read sectors writes requested writes
124 2309 9 32
--
-- display everything in M units
[root@seaing] # vmstat-S m
Procs-memory--swap---io-----system---cpu-
R b swpd free buff cache si so bi bo in cs us sy id wa st
00 0 16077 186 394 00 4 11 31 26 00 100 00
-- displays information about the vmstat version
[root@seaing] # vmstat-V
Procps version 3.2.7
-displays memory-related statistics and the number of multiple system activities
[root@seaing] # vmstat-s
16426356 total memory
725216 used memory
344788 active memory
272460 inactive memory
15701140 free memory
181712 buffer memory
385320 swap cache
18481144 total swap
0 used swap
18481144 free swap
4478 non-nice user cpu ticks
2105 nice user cpu ticks
11814 system cpu ticks
38902423 idle cpu ticks
14495 IO-wait cpu ticks
13407 IRQ cpu ticks
4756 softirq cpu ticks
0 stolen cpu ticks
1654066 pages paged in
4289217 pages paged out
0 pages swapped in
0 pages swapped out
99503472 interrupts
10117715 CPU context switches
1508999388 boot time
8617 forks
Description:
Non-nice user cpu ticks the time, in jiffies user, that CPU has run non-nice processes in user mode since the system was started
Nice user cpu ticks the time, in jiffies nice, that CPU has run the nice process in user mode since the system was started
System cpu ticks the time in jiffies sys that CPU has been in the system state since the system was started
Idle cpu ticks the time in jiffies idle that CPU has been idle since the system was started
IO-wait cpu ticks the time, in jiffies iowait, that CPU handled IO interrupts since the system was started
IRQ cpu ticks the time in jiffies irq for CPU to handle hard interrupts since the system was started
Softirg cpu ticks the time in jiffies Softirq for CPU to handle soft interrupts since the system was started
Interrupts the number of interruptions that have occurred since the system was started Intr
CPU context switches the number of context exchanges that have occurred since the system was started Ctxt
The time in seconds that boot time has been running since the system was started. Btime
The number of tasks created by forks since the system was started. Process
4. Handling of frequently asked questions
If r is often greater than 4 and id is often less than 40, the load on cpu is very heavy.
If bi,bo is not equal to 0 for a long time, there is not enough memory.
This is the end of the article on "how to use vmstat in Linux commands". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.