From where does the System Monitor calculate its % utilization values?
I need to get those values at a particular instant, to do some rudimentary load balancing.
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
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
$ 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.