[ubuntu-uk] Temperature
Avi
lists at avi.co
Mon Jun 27 20:31:27 UTC 2011
Dave Hanson wrote:
> So know I guess is a good time to be thinking about home server
> temperatures (after the heat of course) Does anyone have a
> recommendation for a program which could send an email when the
> machines temp reaches a certain degree. Obviously without a GUI?
lm-sensors, cron & perl or bash? I've not seen a ready made thing, but
something like this untested bit of bash cronned to run every five or so
minutes would do:
#! /bin/bash
# threshold above which we're concerned about
THRESHOLD=28
# The temperature (probably of core 1)
TEMP=$(sensors -u | grep temp1 | tail -n1 | awk '{print $2}')
# A file to touch to keep track of things
TOUCHFILE=/root/.sensors
if [[ $TEMP > $THRESHOLD ]]; then
if [ ! -f $TOUCHFILE ]; then
touch $TOUCHFILE
echo "Temperature is $TEMP celsius" | mail -s
"Sweltering Servers" you at yourdomain.com
fi
else
if [ -f $TOUCHFILE ]; then
rm $TOUCHFILE
fi
fi
It's not tested, but it should be a reasonable starting point from
which you can get to something that works :)
Might be worth graphing the data, too, with something like Munin?
Especially if you can get several temperature sensors on the go, it'll
help you determine which is generally the hottest.
--
Avi
More information about the ubuntu-uk
mailing list