Ryan:
You can read /proc/stat and parse the cpu line. The time unit is 1/100th of a second (jiffy). The fields mean the following (in their order):
jiffy_user jiffy_nice jiffy_system jiffy_idle
The counters are started from the system boot, so to get the current percentages you'll need to sample twice, and then subract and calculate percentages. Of course, remember that division by 0 is an error :-)
While this is more programmer labor intensive than your solution, you are more likely to actually get a page when things go wrong :-) If you ever tried running top on a loaded system, and then try to fork a process, you'll know what I'm talking about.
-- Sasha Pachev Create online surveys at http://www.surveyz.com/
____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
