Cpu display information that you may not understand in CentOS command top

Source: Internet
Author: User

Cpu display information that you may not understand in CentOS command top

When using the top Command, the following line is displayed:

What are the meanings of each value in it?

I was asked this question today and found that the answer is not very clear. Sure enough, the most frequently used top commands every day are still unknown... Shame... So I checked some information:

Official explanation

Cpu (s) indicates cpu information. The meaning of each value is:

Us: user cpu time (or) % CPU time spent in user spacesy: system cpu time (or) % CPU time spent in kernel spaceni: user nice cpu time (or) % CPU time spent on low priority processesid: idle cpu time (or) % CPU time spent idlewa: io wait cpu time (or) % CPU time spent in wait (on disk) hi: hardware irq (or) % CPU time spent servicing/handling hardware interruptssi: software irq (or) % CPU time spent servicing/handling software interruptsst: steal time--% CPU time in involuntary wait by virtual cpu while hypervisor is servicing another processor (or) % CPU time stolen from a virtual machine

Us: User-mode cpu time ratio sy: System-mode cpu time ratio ni: User-mode cpu time ratio id allocated by nice-weighted process: idle cpu time ratio wa: cpu waiting for disk write completion time hi: Hard interrupt consumption time si: Soft Interrupt consumption time st: Virtual Machine stealing time

Well, if I say I understand the above rules, I am deceiving myself. Below is my understanding

First, how is the percentage calculated?

For example, if there are 100 cpu time slices in one second, the cpu time slice is the minimum unit of cpu operation. Then the 100 cpu time slices are used in different regions and purposes, which indicates the cpu time ratio occupied in this region. That is, the cpu time percentage obtained here.

For example, the following program:

Copy the file from the src position of the disk to the dst position of the disk. The file will be read from src first to the kernel space, then read to the user space, and then copy the data to the buf of the user space, and then through the user space, the kernel space, data is sent to the dst of the disk.

So from the above process, the cpu consumption in the kernel space is sy (percentage of cpu used in the system state ), the cpu consumption is us (the cpu usage percentage in the user State) when the user space is used ).

Okay. Let's talk about hi and si.

If there is no problem with the program, there is no hi or si, But there is actually a concept of hard interrupt and Soft Interrupt. For example, when a hard interrupt occurs and the cpu is executing a program, the peripheral hardware (for example, the hard disk is faulty) must immediately notify the cpu to perform on-site storage. At this time, context switching will occur for the cpu. That is, the cpu will be occupied by hard interruptions for some time. This time is hi. Similarly, si is the cpu usage time of the Soft Interrupt, And the Soft Interrupt is triggered by the instructions of the software.

For the concepts of soft and hard interruptions, refer:

Http://blog.csdn.net/pxz_002/article/details/7327668

Below is ni

Ni indicates nice. What is nice? Every linux Process has a priority. A process with a higher priority has the right to execute first. This is called pri. In addition to the priority, the process also has a priority correction value. For example, if your original priority is 20 and the value is-2, your final process priority is 18. This correction value is called the nice value of the process.

So nice is a process's priority correction value. Why does it take up cpu time?

Ni refers to the user-mode cpu time ratio used by nice-weighted processes. In my understanding, the so-called correction value of a process means that more cpu time is allocated to the user-mode of the process, the cpu time allocated in the middle is our ni. (I am not sure about this understanding. If there is an error, please help me to point it out)

Below is wa

Wa refers to the time when the CPU waits for the disk to write data, that is, the premise is that the I/O operation is required, and the CPU waits for the time when the I/O operation is performed. For example, the last step of the above program, from the system space to the dst hard disk space, if the program is blocked, then the cpu will wait for the data to be written to the disk to complete the write operation. So the cpu wait time is wa.

Therefore, if a machine sees that wa is particularly high, it generally indicates that disk IO is faulty. You can use commands such as iostat to continue detailed analysis. Below is the st

The name of st is very vivid and stolen... Specifically for virtual machines, one physical machine can Virtualize several virtual machines. On one of the virtual machines, the top check shows that the st is not 0, which means that there are so many cpu time schedules for this virtual machine, but due to a certain virtual technology, the cpu time is allocated to other virtual machines. This is called stealing.

Id

The remaining id is the cpu time slice except the preceding cpu processing context. Of course, the cpu is idle on these time slices.

The total cpu time of top is 100%. Dstat

In other words, a dstat command can also view cpu information. Is the dstat-c display.

It is easy to map usr with us, sys and sy, idl and id, wai and wa, hig and hi, siq and si.

However, we can see that dstat does not include the statistics of st and ni, and the total sum of all its parts may not be 100. This shows that dstat is not actually against st, ni is used for cpu statistics. Pay attention to this when using it.

References:

Http://hi.baidu.com/higkoo/item/70600834426247483075a1df

Http://blog.csdn.net/codestinity/article/details/7496962

Http://book.51cto.com/art/200812/99435.htm

Http://unix.stackexchange.com/questions/18918/in-linux-top-command-what-are-us-sy-ni-id-wa-hi-si-and-st-for-cpu-usage

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.