proc-stat

       Under Linux, CPU utilization is divided into user state, system state and idle state, which represent the execution time of the CPU in user state, the execution time of the system kernel, and the execution time of idle system processes. The sum of the three is the total CPU utilization. Time, when there is no user process, system process, etc. to be executed, the CPU executes the system default idle process. From the usual way of thinking, CPU utilization is the proportion of the time occupied by non-idle processes, that is, the time the CPU executes non-idle processes/the total execution time of the CPU.

       for example:

  user nice system idle iowait irq softirq
cpu 79553 925 20963 998213 3096 0 96
cpu0 21392 115 5332 247984 798 0 55
cpu1 18727 503 5479 250038 729 0 19
cpu2 20963 141 5508 248286 876 0 12
cpu3 18469 163 4643 251904 691 0 9

        The first line is the sum, if the CPU is multi-core (including hyper-threading) there will be cpu 0 ~ cpu n

 

user The CPU time in user mode from the start of the system to the current moment, excluding the nice value is a negative process.
nice The CPU time occupied by the process with a negative nice value from the start of the system to the current moment
system Accumulated from the start of the system to the current moment, the core time
idle Accumulated from the start of the system to the current time, other waiting times except the IO waiting time
iowait IO waiting time accumulated from the system startup to the current moment
irq Accumulated from the start of the system to the current moment, the hard interrupt time
Softirq Accumulated from the start of the system to the current moment, the soft interrupt time

 

 

       The calculation formula of the instant utilization of CPU:

       Total CPU usage time from t1 to t2 = ( user2+ nice2+ system2+ idle2+ iowait2+ irq2+ softirq2) - ( user1+ nice1+ system1+ idle1+ iowait1+ irq1+ softirq1)

       CPU idle usage time from t1 to t2 = (idle2 - idle1)

       CPU instant utilization in the time period from t1 to t2 = 1 - CPU idle usage time / total CPU usage time

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327084293&siteId=291194637