"Linux" performance monitoring directive Vmstat

Source: Internet
Author: User
Tags switches cpu usage

I. Overview

Monitoring is usually divided into machine monitoring and service monitoring, machine monitoring is the basic monitoring, the purpose is to obtain the current state of operation of the system, service monitoring is the main purpose, but also the most should be concerned about the monitoring, machine monitoring is also for better service monitoring exists, simply speaking, service monitoring and system deployment of specific services, But the monitoring mode can be unified.

Monitoring is to obtain the relevant target data, the data is for the exception of the analysis, the purpose of the analysis is to solve the online case and performance tuning. This is basically the meaning of monitoring existence. The machine monitoring of an on-line server can basically be divided into four categories: CPU monitoring, disk capacity monitoring, IO monitoring and network card monitoring. Different businesses will lead to different server bottlenecks, depending on the business. This paper mainly discusses the common command line for obtaining CPU status under Linux: Vmstat.


second, the use of detailed

Before using the instructions, you should understand the specifics of the monitoring and what it means. CPU monitoring is divided into two types: CPU usage and IPC/CPI, the application scenarios are not the same, usually using CPU usage monitoring, basically the operating system will be provided, and IPC/CPI monitoring needs the assistance of performance experts, the operating system basically no relevant instructions.

Non-compute-intensive only requires monitoring CPU usage, while CPU usage requires attention to user-state CPU usage and system-state CPU usage, which indicates the percentage of CPU time that the system is running on, and which represents the percentage of the system that is getting CPU times. User-configured CPU percentages of 100% are ideal for users, but this is often not possible, and the system-state CPU usage increases more when program scheduling, thread context switching, and IO interactions occur. It should be clear that the application consumes a lot of CPU does not mean that performance or scalability reached the highest or bottleneck. If the long-time system state CPU utilization is high, then it is necessary to pay attention to, it is possible that the program is not elegant, it is possible that the disk is about to be damaged due to the long IO consumption time, the need for CPU monitoring to analyze the results.

For compute-intensive applications, it is not enough to monitor only CPU usage, but also to monitor the IPC (number of instructions per clock) or CPI (per instruction clock cycle). Why do I need to know this data? Either the IPC or CPI can reflect the percentage of CPU clock cycles that are consumed when no instruction is executed, in short, the percentage of time that the CPU waits for an instruction to load registers from memory, that is, stagnation (stall). Stagnation-When the CPU executes the instruction and the operand is not in the register or cache and the current clock cycle is not invalidated, the CPU needs to stall waiting for the data to be loaded into the register from memory, and once the stall occurs, it typically wastes hundreds of CPU ticks. To improve the performance of compute-intensive applications, you need to obtain IPC/CPI monitoring data, reduce the latency of the CPU waiting for memory data, or improve the cache.

1. Vmstat usage

[Email protected] ~]$ Vmstat--helpusage:vmstat [-v] [-n] [delay [count]]              -V prints version.              -N Causes the headers is reprinted regularly.              -A Print inactive/active page stats.              -D Prints Disk statistics-              d prints Disk table-              p prints disk partition statistics-              s Prints VM table-              m P Rints Slabinfo              -t add timestamp to output              -s unit size delay is the              delay between updates in seconds.               Unit size k:1000 k:1024 m:1000000 m:1048576 (default is K) count is the number of              updates.

2. Vmstat Example

[[email protected] ~]$ vmstat 1procs-----------memory-------------Swap-------io------System-------CPU-----R B    SWPD free buff cache si so bi bo in CS us sy ID WA St 0 0 0 56400 43444 324868 0 0      20 14 28 45 0 0 99 1 0 0 0 0 56400 43452 324864 0 0 0 48 36 58 0 0 98 2 0 0 0     0 56400 43452 324868 0 0 0 0 22 34 0 0 100 0 0 0 0 0 56400 43452 324868 0 0 0   0 34 48 0 1 99 0 0 1 0 0 56400 43452 324868 0 0 0 0 22 31 0 1 99 0 0 0 0 0     56400 43452 324868 0 0 0 0 31 48 0 0 100 0 0 0 0 0 56400 43452 324868 0 0 0 0 129 163 3 1 96 0 0 0 0 0 56400 43452 324868 0 0 0 0 35 56 0 2 98 0 0 0 0 0 5   6400 43452 324868 0 0 0 0 22 32 0 0 100 0 0 0 0 0 56400 43452 324868 0 0 0 0 58 61 0 0 100 0 0 0 0 0 56400 43452 324868 0 0 0 0 24 38 0 1 99 0 0 

3. Vmstat detailed

Vmstat 1: Every second to collect, show the data, to stop to Ctrl+d can, if you want to specify the number of acquisition, then use "Vmstat 1 10", means that every second to collect data, a total of 10 times.

procs:

R: Indicates that in addition to the CPU resources have been prepared for the process queue, that is, the number of processes waiting for the available CPU, to obtain this value to determine the system load situation, if the value of a long time than the number of processor hardware threads, you need to pay attention to, the system may face high load condition, if the long time is the processor hardware Requires immediate attention and action, the system can already feel a noticeable performance degradation, either by increasing the CPU or by analyzing the current system process status.

Note: The concept of the number of hardware threads, for example, a dual-core four-thread CPU, represents 2 physical CPUs, but each CPU has two logical threads, and for the operating system, it thinks there are 4 CPUs.

B: Indicates a blocked process queue, while the process is still in memory (not the same as hang, note the difference), but requires additional resources (such as IO).

CPU:

US: Indicates user-state CPU utilization, which is the percentage of the total CPU time that the application obtains CPU execution time, and the high ratio does not indicate a system bottleneck.

SY: Indicates a system-state CPU usage, often referred to as the percentage of total CPU time that the system is scheduled to occupy.

ID: Indicates the percentage of system idle time.

The purpose of these three data is to analyze and reduce the percentage of sy, in fact, to judge that the application anomaly requires a lot of monitoring data to be synthesized, depending on experience.

Swap:

Si: The size of the virtual memory (swap) read from the disk per second, if the value is large, it means that the system is resource-intensive and requires frequent memory exchange.

So: the size of writes from memory to the virtual storage per second, and Si consistent, but note that two values are used in conjunction, when two values are large, it really means that memory resources are tense.

IO:

BI: Block device (disk) receives the number of blocks per second, corresponding to the write operation in Io, too large to indicate frequent IO operations.

BO: Block device output per second of the number of blocks, corresponding to the read operation in Io, too large to indicate frequent IO operations.

System:

In: Number of CPU interrupts per second.

CS: The number of context switches per second, such as calling system functions, thread context switches, process switching, will cause this value to grow, the context switch wastes the CPU clock, and the in value, so if the value is too long, you need to consider whether the number of threads in your app is open too much, and so on.



Note:

If there are mistakes in this article, please do not hesitate to correct, thank you!


"Linux" performance monitoring directive 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.