Hey thanks a bunch for sharing. Very nice script!
On 12/30/07, Andreas Pfaffeneder <apfaffeneder at zuhause-local.de> wrote:
Hi folks,
to monitor the 5 minute average cpu-speed of your notebook or server capable of changing its cpu speed you can use the folling bits:
CLIENT: Place cpuspeed.sh in the clients ext-directory: cpuspeed.sh (requires bash, awk and loaded cpufreq_stats.ko) #!/bin/bash COLUMN=cpuspeed # Name of the column COLOR=green # By default, everything is OK MSG="" STATEFILE="/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state" SPEEDS=
awk '{print $1}' $STATEFILEfor SPEED in $SPEEDS; do export TICKS$SPEED=grep $SPEED $STATEFILE | awk '{print $2}'done sleep 300 for SPEED in $SPEEDS; do export TICKS${SPEED}_2=grep $SPEED $STATEFILE|awk '{print $2}'done for SPEED in $SPEEDS; do DIFF=$[TICKS${SPEED}_2 - TICKS$SPEED] DIFFSUM=$[$DIFFSUM + $DIFF ] if [ $DIFF -gt 0 ]; then CLOCKS=$[$CLOCKS + ($DIFF*$SPEED) ] fi done RESULT=$[$CLOCKS/$DIFFSUM/1000] MSG="Mhz:$RESULT" $BB $BBDISP "status $MACHINE.$COLUMN $COLORdate${MSG} " exit 0 /cpuspeed.shAdd to clientlaunch.cfg: [cpuspeed] ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg CMD $HOBBITCLIENTHOME/ext/cpuspeed.sh INTERVAL 5m
SERVER: Add the following lines to hobbitgraph.cfg: [cpuspeed] TITLE CPU Speed YAXIS Mhz DEF:speed=cpuspeed.rrd:Mhz:AVERAGE LINE2:speed#000000:AVERAGE GPRINT:speed:LAST: \: %5.1lf (cur) GPRINT:speed:MAX: \: %5.1lf (max) GPRINT:speed:MIN: \: %5.1lf (min) GPRINT:speed:AVERAGE: \: %5.1lf (avg)\n
Modify/Add hobbitserver.cfg: TEST2RRD: Add cpuspeed=ncv Add line: NCV_cpuspeed="Mhz:GAUGE" Optional: Add cpuspeed to line GRAPHS
The cpuspeed.sh could easily be extended to get values per CPU, but I have not seen CPUs changing their speeds independently so far.
Andreas
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
-- Josh Luthman Office: 937-552-2340 Direct: 937-552-2343 1100 Wayne St Suite 1337 Troy, OH 45373
Those who don't understand UNIX are condemned to reinvent it, poorly. --- Henry Spencer