One Linux command per day: Vmstat

Source: Internet
Author: User
Tags switches

1. Introduction to Commands

Vmstat The virtual Memory Statistics command is used to display the virtual memory status of the Linux system, as well as to report on the overall operating state of the system, such as process, memory, I/O, etc.

2. Usage

Vmstat [-A] [-n] [-T] [-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]
3. Options
-A: Displays active and inactive memory-F: Displays the number of fork from the system since it was started. -M: Display slabinfo-n: Displays the field names only once at the beginning. -S: Displays memory-related statistics and the number of system activities. Delay: Refresh time interval. If not specified, only one result is displayed. Count: Number of refreshes. If you do not specify the number of refreshes, but the refresh interval is specified, the number of refreshes is infinite. -D: Displays disk-related statistics. -P: Displays the specified disk partition statistics-S: Displayed using the specified units. The parameters are K, K, M, M, respectively, representing 1000, 1024, 1000000, 1048576 bytes (byte). The default unit is K (1024x768 bytes)-V: Displays Vmstat version information.
4. Example Example 1:vmstat command description

Procs (Process)
R: The number of processes in the running queue, which can also be used to determine if the CPU needs to be increased. (longer than 1)
B The number of processes waiting for IO.
Memory (RAM)
Swpd With virtual memory size, if the value of SWPD is not 0, but the Si,so value is 0 long, this situation does not affect system performance.
Free The free physical memory size.
Buff The amount of memory used as a buffer.
Cache As the memory size of the cache, if the cache value is large, it indicates that the number of files in the cache, if the frequently accessed files can be the cache, then the disk read IO bi will be very small.

Swap
Si The size of the memory that is written from the swap area per second, which is transferred into memory by the disk.
So The amount of memory written to the swap area per second, which is transferred from memory to disk.

Note: When memory is sufficient, these 2 values are 0, and if these 2 values are longer than 0 o'clock, system performance will be affected and both disk IO and CPU resources will be consumed. Some friends see that free memory is very small or close to 0 o'clock, think that memory is not enough, not to see this, but also to combine SI and so, if it is very small, but Si and so are very few (mostly 0), then do not worry, the system performance will not be affected. Because Linux always runs out of memory first.

Io
Bi Number of blocks read per second
Bo Number of blocks written per second

Note: When the random disk reads and writes, these 2 values are larger (such as exceeding 1024k), you can see the CPU in the IO waiting value will be greater.

System (Systems)
Inch Number of interrupts per second, including clock interrupts.
Cs The number of context switches per second.

Note: The larger the 2 values above, the greater the CPU time that is consumed by the kernel.

CPU (expressed as a percentage)
us When the user process execution time percentage is higher, the user process consumes more CPU time, but if it is used over a long period of 50%, then we should consider optimizing the program algorithm or accelerating it.
Sy: When the kernel system process Execution time percentage is high, the system kernel consumes more CPU resources, which is not a benign performance, we should check the cause.
Wa Io wait time percentage when the value of WA is high, the IO wait is more severe, which may be caused by random access to the disk, or it may be a disk bottleneck (block operation).
Id Percentage of idle time
The instance 2:vmstat–a shows active and inactive memory, and the display adds inact and active columns,

Example 3:vmstat-s view details of memory usage
[Email protected] ~]# vmstat-s      3922280 total  memory      1294648  used memory       705808  Active Memory       398728  inactive memory      2627632 free  memory       132816  buffer memory       802932  Swap Cache      8339448 Total  swap            0  used swap      8339448 free  swap         2162 Non-nice User CPU ticks-nice           user CPU ticks         3257 system CPU ticks      3015131 idle CPU ticks         1685 io-wait CPU Ti CKS          582 IRQ CPU Ticks          269 SOFTIRQ CPU ticks            0 stolen CPU Ticks       935206 pages paged in        43585 pages Paged out            0 pages swapped in            0 pages swapped out       532677 interrupts       656731 CPU Context Switches   1 461999263 boot time         5706 forks
Example 4:vmstat-d viewing disk read/write
[[email protected] ~]# vmstat-ddisk-------------reads------------------------writes----------------IO------      Total merged sectors Ms Total merged sectors Ms Cur SECRAM0 0 0 0 0 0       0 0 0 0 0ram1 0 0 0 0 0 0 0 0 0 0ram2 0       0 0 0 0 0 0 0 0 0ram3 0 0 0 0 0 0        0 0 0 0ram4 0 0 0 0 0 0 0 0 0 0ram5 0 0       0 0 0 0 0 0 0 0ram6 0 0 0 0 0 0 0       0 0 0ram7 0 0 0 0 0 0 0 0 0 0ram8 0 0      0 0 0 0 0 0 0 0ram9 0 0 0 0 0 0 0 0   0 0RAM10 0   0 0 0 0 0 0 0 0 0ram11 0 0 0 0 0 0 0       0 0 0ram12 0 0 0 0 0 0 0 0 0 0ram13 0 0       0 0 0 0 0 0 0 0ram14 0 0 0 0 0 0 0 0       0 0RAM15 0 0 0 0 0 0 0 0 0 0loop0 0 0 0       0 0 0 0 0 0 0loop1 0 0 0 0 0 0 0 0 0      0LOOP2 0 0 0 0 0 0 0 0 0 0loop3 0 0 0 0 0 0 0 0 0 0loop4 0 0 0 0 0 0 0 0 0 0      LOOP5 0 0 0 0 0 0 0 0 0 0loop6 0 0 0 0 0  0 0 0    0 0LOOP7 0 0 0 0 0 0 0 0 0 0sr0 0 0 0     0 0 0 0 0 0 0sda 26814 24219 1867212 35021 3238 7679 87202 8343 0 22
Example 5: Viewing the read/write of a/dev/sda1 disk
[Email protected] ~]# vmstat-p/dev/sda1 sda1          reads   read Sectors  writes requested writes                 666       5466          7         50

One Linux command per day: Vmstat

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.