==>vmstat of Linux monitoring commands

Source: Internet
Author: User
Tags switches cpu usage

I. Description of Use

Vmstat can monitor the operating system's memory information, process status, CPU activity, disk and other information, the disadvantage is that a process cannot be analyzed in depth.

II. Usage and parameter description

    • -A: Show active and inactive memory
    • -F: Shows the number of fork from system start up to now
    • -M: Display Slabinfo
    • -N: Displays the field names only once at the beginning
    • -S: Displays memory-related statistics and 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 a refresh time, but the refresh interval is specified, the number of refreshes is infinite
    • -D: Display disk-related statistics
    • -P: Display 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: Show Vmstat version information
    • -P: Display specified disk partition statistics
    • -D: Show disk overall information

Iii. Description of the results

2 means that the server state is collected two seconds, and5 means the acquisition 5 times. In the actual application process, the general will be monitored for a period of time, do not want to monitor the direct end of the line, as follows:

  • The R column represents the number of processes running and waiting for CPU time slices, which, if longer than the number of system CPUs, indicates that the CPU is low and needs to be increased.
  • Column B indicates the number of processes waiting on the resource, such as waiting for I/O or memory exchange.
  • The SWPD column indicates the size of the virtual memory used, if the swap value is not 0 or larger, as long as the value of Si, so long 0, generally belong to the normal situation.
  • The free column represents the size of the idle physical memory, in kilobytes.
  • The Buff column represents the baffers cached memory size, which is the buffer size, which is generally required to read and write to the block device.
  • The cache column represents the size of the page cached memory, that is, the cache size, generally buffered as a file system, frequently accessed files are cached, if the cache value is very large, if there is a lot of cached files, if the bi in IO is relatively small, the file system efficiency is better.
  • The SI column indicates the size of the virtual memory read from disk per second, if the value is greater than 0 for a long time, indicating that the physical memory is not sufficient to increase system memory.
  • The so column represents the size of the virtual memory written to disk per second, and if the value is greater than 0 for a long time, it also indicates that the physical memory is insufficient to increase system memory.
  • The BI column represents the total amount of data that is read by the block device, that is, read disk, Unit kb/s.
  • The Bo column represents the total amount of data written to the block device, that is, the write disk, Unit kb/s. If the Bi+bo value is too large and the WA value is large, the system disk IO bottleneck is indicated.
  • The in column represents the number of interrupts per second of the CPU, including time interruptions.
  • The CS column represents the number of context switches produced per second, and the larger the two values, the more CPU is consumed by the kernel. The smaller the value of the better, too big, to consider the number of threads or processes, such as in Apache and Nginx Web server, we generally do performance testing in thousands of concurrent or even tens of thousands of concurrent testing, the process of selecting a Web server can be the peak of the process or thread has been down, the pressure test , until CS to a relatively small value, the process and the number of threads is the more appropriate value. System calls are also, each time the system function is called, our code will enter the kernel space, resulting in context switching, this is very resource-intensive, but also try to avoid frequent calls to system functions. Too many context switches means that most of your CPU is wasted in context switching, resulting in less time for the CPU to do serious work, and the CPU not being fully utilized, is undesirable.
  • The US column represents the percentage of CPU time consumed by the user process, and the higher the US value, the more CPU time the user process consumes, and the optimizer or algorithm to consider if the long-term is greater than 50%.
  • The SY column represents the percentage of CPU time that the system kernel process consumes, generally us+sy should be less than 80%, and if 80%, there may be a CPU bottleneck.
  • The ID column represents the percentage of time that the CPU is in idle state.
  • The WA column represents the percentage of CPU time that I/O waits, and the higher the WA value, the more serious I/O waits, the more the reference value of WA is 20%, and more than 20% indicates that I/O waits are severe, and the cause of I/O waits may be caused by a large number of random reads and writes. It can also be caused by a disk bottleneck (mostly block operations).

Key parameters: R,b,swpd,free,buff,cache,si,so,bi,bo

Iv. Performance Analysis information

1. Io/cpu/men Chain Reaction

    • Free drops sharply
    • Buff and cache are recycled down, but it doesn't help
    • Still need to use large swap swap partition SWPD
    • Number of wait processes, B increased
    • Read-write Io,bi Bo increased
    • Si so greater than 0 starts reading from the hard drive
    • CPU wait time for IO wait, WA increased

2. Insufficient memory

    • Start using SWPD,SWPD not for 0
    • Si so greater than 0 starts reading from the hard drive

3. Io bottleneck

    • Read-write Io,bi Bo increased by more than 2000
    • CPU wait time for IO wait, WA increased by more than 20
    • SY system call time is long, IO operation frequently leads to increase >30%
    • WA io wait Time long
    • iowait% <20% Good
    • iowait% <35% General
    • iowait% >50%
    • Further use of Iostat observation

4, CPU bottleneck: Load,vmstat in R column

    • Response to CPU Queue Length
    • Over time, the sum of the number of processes the CPU is processing and waiting for the CPU to process, directly reflects the CPU usage and application status.
    • Ideal load average: *cpu number of cores *0.7
    • Number of CPUs: grep ' physical id '/proc/cpuinfo | Sort-u
    • Number of cores: grep ' core ID '/proc/cpuinfo | Sort-u | Wc-l
    • Exceeding this value means that it is already a CPU bottleneck.

==>vmstat of Linux monitoring commands

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.