Xymon Mailing List Archive search

Monitoring average CPUspeed on Systems with dynamic CPUspeed

list Josh Luthman
Sun, 30 Dec 2007 17:44:09 -0500
Message-Id: <user-c878d7470f87@xymon.invalid>

Hey thanks a bunch for sharing. Very nice script!


On 12/30/07, Andreas Pfaffeneder <user-827a5cb89c9c@xymon.invalid> 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}' $STATEFILE`
for 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 $COLOR `date`
${MSG}
"
exit 0
/cpuspeed.sh

Add 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

-- 
Josh Luthman
Office: XXX-XXX-XXXX
Direct: XXX-XXX-XXXX
XXXX Wayne St
Suite XXXX
Troy, OH XXXXX

Those who don't understand UNIX are condemned to reinvent it, poorly.
--- Henry Spencer