Subject: getting cpu utilization
To: None <netbsd-users@netbsd.org>
From: George Georgalis <george@galis.org>
List: netbsd-users
Date: 01/11/2007 19:39:19
I'm using a /bin/sh function to generate a the cpu utilization
util () { # CPU Utilization
idle=$(echo "2 k $(top -b -d2 | grep '^CPU states' | awk '{print $11}' | sed 's/%//') 1 + p" | dc)
echo "2 k 1 $idle / p" | dc ;}
That returns the inverse of the cpu idle % found in top. I add
1 to the value before I invert it to prevent divide by zero, so
output is pretty much between 0 and 1.
Running two top reports seems a pretty inefficient way to get the
value. I think I can tune top a bit, but is there a more direct
way to get the measurement?
// George
--
George Georgalis, systems architect, administrator <IXOYE><