A method is:
1. open /proc/stat
2. read in the idle (and perhaps iowait) times for each processor (see man /proc for a description of the format)
3. wait one second
4. read in the idle times again
5. find the differences and divide by the tick frequency
This will give you the idle fraction for each cpu over the last second.
Last edited by neonsignal; 02-03-2010 at 11:13 PM.
|