On Tue, May 05, 2009 at 10:16:18AM -0700, Manuel Rotter wrote:
top -b -d 1 -n 2|grep Cpu|awk 'BEGIN { FS = " " } { print $2 }'|tail
-n 1 | sed 's/us,//g')

This should echo the right cpu usage...top -n 1 seems to be not
right(sometimes?).
We also had another Way of doing it, probably more reliable, but i am
sorry, i can't tell you that. It has to do something with /proc/stat,
but for me this was enough.

The only real problem I have with this is that the wall time of top -n 1 is ~.5sec on my machine, and it has to compute a lot of data other than overall CPU utilization. I don't think it's suitable for a status script when used as such.

--
Kris Maglione

Saying that Java is good because it works on all platforms is like
saying anal sex is good because it works on all genders.
        --Unknown


Reply via email to