Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

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