[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [hobbit] Hobbit viewing temperature in Hobbit
- To: hobbit (at) hswn.dk
- Subject: Re: [hobbit] Hobbit viewing temperature in Hobbit
- From: "leen smit" <leen.smit (at) gmail.com>
- Date: Wed, 10 Oct 2007 19:15:11 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=dtF2acIs5tfv2LfTNaU7Amdzrm1K29JnJR4sROKY+7Y=; b=k4ufFMIHiE17ejXNb+1vqS8W0kn+gv+gy+gl93hfFVbIbc2+tT/+N+V6F8EZMBI+IKbGvwVPpXOkwx/quegtpoNrhIUq+tsVpTX73C9DYcRCQOONCNSOloOSzU8YH1fCWu3DEOCdHcdrHUNfdOrqla+RSAXDNxGuN2EbAtvF778=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=hbcQyxkNFwBG9jeTRsyrtvtKgHQUdEc8+ndTROIWsDj4/vKiwCb8id7yi2AbI93wPyvkKKlJ7p7YVDvN6U5pPc9OCFkVA/NKxj5DiVHyl8KBGOz0shClGkkaMbo3Sr8YV4m+5SVIwWHS6xTP1ggAfQGb8aBZSZ/9hfilxbX+v64=
- References: <5755F71380ED8E4FB84076C0A855F5D67DC9EF (at) RAF01.raforninn.local>
I have been struggling with this as well. Basicly, you have make sure your
output of the output script looks like
Device Temp(°C) Temp(°F)
------------------------------
[image: green] Cpu1 33 91
[image: green] Mainboard 35 95
--------------------------------
I've ended up with the following, using lm_sensors input.
#!/bin/sh
COLUMN=temperature # Name of the column
TEST=temperature
echo " $BBTMP/$MACHINE.temperature.$$"
# Do whatever you need to test for something
# As an example, go red if /tmp/badstuff exists.
ENV_CELSIUS=$(sensors |grep 'CPU Temp'|awk '{print $3}'|sed -e 's/+//' -e
's/°C//' -e 's/..$//')
ENV_CELSIUSMAINB=$(sensors |grep 'M/B' |awk '{print $3}'|sed -e 's/+//' -e
's/°C//')
ENV_HIGHWARN=38
ENV_HIGHPANIC=42
ENV_CPU="Cpu1"
ENV_MAINB="Mainboard"
$AWK -v CELSIUS=$ENV_CELSIUS -v HIGHWARN=$ENV_HIGHWARN -v
HIGHPANIC=$ENV_HIGHPANIC -v CPU=$ENV_CPU \
-v CELSIUSMAINB=$ENV_CELSIUSMAINB -v MAINB=$ENV_MAINB \
'BEGIN {
print "Device Temp(°C) Temp(°F)";
print "------------------------------";
COLOR="green";
if (CELSIUS >= HIGHPANIC) {
COLOR="red";
printf("&red %-12s %3d
%3d\n",CPU,CELSIUS,CELSIUS*9/5+32);
printf("&green %-12s %3d
%3d\n",MAINB,CELSIUSMAINB,CELSIUSMAINB*9/5+32);
} else if (CELSIUS >= HIGHWARN) {
if (COLOR != "red")
COLOR = "yellow";
printf("&yellow %-12s %3d
%3d\n",CPU,CELSIUS,CELSIUS*9/5+32);
printf("&green %-12s %3d
%3d\n",MAINB,CELSIUSMAINB,CELSIUSMAINB*9/5+32);
} else {
printf("&green %-12s %3d
%3d\n",CPU,CELSIUS,CELSIUS*9/5+32);
printf("&green %-12s %3d
%3d\n",MAINB,CELSIUSMAINB,CELSIUSMAINB*9/5+32);
}
}
END {
print "-------------------------------------------------";
if (COLOR == "green") {
print "Status green: All devices look okay";
exit 0
} else if (COLOR == "yellow") {
print "Status yellow: Some devices are nearing
their operational limits";
exit 1
} else if (COLOR =="red") {
print "Status red : SYSTEM NEAR THERMAL
SHUTDOWN!!!";
exit 2
} else {
print "Status purple : Unknown status";
exit -1
}
}' > $BBTMP/$MACHINE.temperature.$$
COLOR=`$GREP Status $BBTMP/$MACHINE.temperature.$$| $SED 's/Status //'|$SED
's/:.*$//'`
#create log if NOT green
if [ $COLOR != "green" ]
then
TEMP=`$GREP $ENV_CPU $BBTMP/$MACHINE.temperature.$$| awk
'{print $3}'`
echo "$COLOR : `date '+%a %d %b %Y %H:%M:%S'`
Temperature: $TEMP" >> $HOBBITCLIENTHOME/logs/temp_alerts.log
fi
DATA="Temperature status:
`$CAT $BBTMP/$MACHINE.temperature.$$`
Last 10 Alerts:
`$TAIL $HOBBITCLIENTHOME/logs/temp_alerts.log`
"
LINE="status $MACHINE.$TEST $COLOR `date` $DATA"
Clean up our mess....
$RM -f $BBTMP/$MACHINE.temperature.$$
# Tell Hobbit about it
$BB $BBDISP "$LINE"