0

From where does the System Monitor calculate its % utilization values?

alt text

I need to get those values at a particular instant, to do some rudimentary load balancing.

0

I'd guess it gets its values from /proc/loadavg. The values this gives are standard unix load average values, and would require some munging to get to what you're expecting - CPU usage as a percent.

Simplistically speaking, on a single-core system, a load average of 1.00 would be equivalent to 100% CPU usage. On a quad-core system, 4.00 would be equivalent to 100% load average, etc.

To get instantaneous load, check the first number of the fourth field of /proc/loadavg:

$ cat /proc/loadavg 
0.00 0.00 0.00 1/570 4471

In this case, the value is 1. That means there is one item in the task queue.

If you really think you need the instant load, then you can use that value. I'd not recommend it, though, as it's going to be very highly variable, and not a good read on what's actually going on with the system. Using this value for load balancing could create undue amounts of churn in your system which would not be ideal. There's a reason that the load average values are there - they're a much better view on what the system is currently dealing with.

  • I did check that option out, but loadavg has the values for the past 1 minute, 5 minutes & 10 minutes respectively, whereas I need the instantaneous value. – user54643 Sep 23 '10 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy