I'm a bad man.

I modified the script that was suggested, commented it heavily and slapped it into a cron job. Works fantastically well - and I have it sending mail to an account that is checked all the time (every minute) so it will hollar at me pretty quickly if the temp ever gets too hot.

Thanks!


- Kimball
http://www.kimballlarsen.com

On Feb 2, 2009, at 4:05 PM, Joseph Hall wrote:

On Mon, Feb 2, 2009 at 3:45 PM, Kimball Larsen
<kimb...@kimballlarsen.com> wrote:
Thanks for the ugly one-liner. :)

In attempting to understand what it does, I have pulled it apart to run it a
piece at a time.  I find the following:

/etc# TEMP=$(sensors -f | grep -m 1 F); echo $TEMP
Core0 Temp: +82.4°F
/etc# TEMP=$(sensors -f | grep -m 1 F); TEMP=$(echo $TEMP | sed
's/[^[:digit:]]//g'); echo $TEMP;
0824

Looks like it is taking the +82.4°F and making it become 0824, which is always > 160. So, what is it, exactly, that the magical sed is doing, and
how can I get it to convert the value correctly?

Oog. Decimals. Didn't think about that. Your output is different than
mine, I'm afraid. Assuming your temps are given as whole numbers,
here's what the script does:

# Grab the first line with an F
TEMP=$(sensors -f | grep -m 1 F)

# Kill anything that isn't a digit
TEMP=$(echo "$TEMP" | sed 's/[^[:digit:]]//g')

# Check to see if the resulting digit is =< 160
if [ "$TEMP" -ge 160 ]; then
      # Send an email to root, which will never be read
      echo 'TOO HOT' | mail root -s 'TOO HOT'
fi

Easy enough if you have whole numbers in your output, but decimals
will throw it off. Adding this line after the grep line will throw
away the decimal point and anything after it.

TEMP=$(echo "$TEMP" | sed 's/\..*//')

But really, I'm going to echo Doran's comment, that Nagios really is
the best tool for monitoring stuff like this.

And add a Jayce^++ for his comment as well.

--
Joseph
http://blog.josephhall.com/

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/


/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to