average load and total %CPU in top

10,478

The reason your CPU % and load average are not agreeing is because they are two completely different values. The CPU % is exactly that, the percentage of the CPU a process is using. The load average is the weighted average of the processes in the run queue over 1, 5, and 15 minutes.

If you are concerned with how much CPU you are using (are you fully utilizing your CPU), your tally of the output of top will work well. You can run that occasionally and record the value (or use sar, which will do that for you).

Having a high load average means you have a lot of processes in the run queue - many processes are ready and waiting to run. High load doesn't automatically mean a lot of CPU usage.

Wikipedia has a good article describing the load average, and the differences between CPU load and CPU usage: http://en.wikipedia.org/wiki/Load_Average

Share:
10,478

Related videos on Youtube

baz
Author by

baz

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on September 17, 2022

Comments

  • baz
    baz almost 2 years

    I thought the average load by uptime and the summation of %CPU of all running processes in top (#9 column) should agree. But it seems not true. Here is my little experiments:

    On one server:

    $ top -b -n 1| awk '{ totuse = totuse + $9 } END { print totuse/100 }'; uptime
    
    6.29
    
    22:00:59 up 28 days,  7:03,  9 users,  load average: 7.03, 5.81, 4.51`
    

    On another server:

    $ top -b -n 1| awk '{ totuse = totuse + $9 } END { print totuse/100 }'; uptime
    
    4.93
    
    22:01:37 up 29 days,  8:27, 17 users,  load average: 18.83, 16.01, 13.86`
    

    So why is there such a difference between the two? Which one more truly reflect the usage of CPUs?

    If I try to evaluate how much CPU usage my running processes are using, is this a good way:

    top -b -n 1 | grep "tim"| awk '{ totuse = totuse + $9 } END { print totuse/100 }'
    

    ?

    Thanks and regards!