Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.