/Proc metric data to obtain CPU Information

Source: Internet
Author: User

Refer:Http://www.icsmile.com/2013/07/02/monitor_from_proc_cpu_mem.html



CPU data is mainly obtained from "/proc/stat". We can calculate the CPU usage.
650) this. width = 650; "src =" http://note.youdao.com/yws/public/resource/bb0429654d7d3fadc2c0be647849aaa6/AD3C5EA4669C4395A16CB1A3C071D6B7 "alt =" AD3C5EA4669C4395A16CB1A3C071D6B7 "/> 650) this. width = 650; "src =" http://note.youdao.com/yws/public/resource/bb0429654d7d3fadc2c0be647849aaa6/D3EB3B3A5752433CB2AC81ADA615EFA4 "alt =" D3EB3B3A5752433CB2AC81ADA615EFA4 "/>
What does the above mean?

CPU and CPU 0, CPU1, CPU2, CPU3, CPU4, CPU5 each parameter meaning in each line
Parameters Explanation
User

Nice

System
Idle

Iowait

Irq

Softirq


Steal

Guest

From the system start to the current time point, the CPU time unit of the user State is jiffies. The nice value is not included in the process. 1 jiffies = 0.01 seconds
CPU time units occupied by processes with a negative nice value from system start to current time: jiffies)
From system startup to current time, the core time unit is jiffies)
From system startup to current time, except hard disk IO wait time, other wait time units: jiffies)
From system startup to current time, hard disk IO wait time unit: jiffies ),
From system startup to current time, the unit of hard interruption time is jiffies)
From system startup to current time, Soft Interrupt time unit: jiffies)


 

The "intr" line shows the number of interruptions. The first line is the number of all interruptions that have occurred since the system was started; then each number corresponds to the number of times a specific interruption has occurred since the system was started.

"Ctxt" indicates the number of times the CPU context has been exchanged since the system was started.

"Btime" indicates the time (in seconds) that has elapsed since the system was started.

The number of tasks created since the system started "processes (total_forks.

"Procs_running": number of tasks in the current queue.

"Procs_blocked": Number of blocked tasks.


Obtain two samples
Roughly calculate the CPU usage
Run the following command to obtain the result twice and then calculate it:
cat  /proc/stat|grep ^cpu && echo '##' &&sleep 1 &&cat  /proc/stat|grep ^cpu

Output
650) this. width = 650; "src =" http://note.youdao.com/yws/public/resource/bb0429654d7d3fadc2c0be647849aaa6/D79838A6A50046339184C47C006D4797 "alt =" D79838A6A50046339184C47C006D4797 "/>
The total cpu usage is calculated.
# Cpu 488 0 3567 8501952 4776 303 0 0 0 # cpu 924 0 488 3568 8502646 4788 0 0 # formula total = user + nice + system + idle + iowait + irq + softirq + steal + guest


total1=8512010total2=8512717


# Cpu idle book calculation formula cpu_idle = (idle2-idle1)/(total2-total1) * 100 # substituted (8502646-8501952)/8512717-8512010) * 100 = 98.1612446959

# Formula for Calculating CPU usage cpu_usage = 100-cpu_idle # cpu_usage = 100-98.1612446959 = 1.8387553041

Computing is complete now


This article from the "pure natural otaku" blog, please be sure to keep this source http://tianranzhai.blog.51cto.com/7235933/1304632

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.