Archive for September, 2009

Living in Southern California without A/C I’m always a little worried about the temperature inside my computer cases.  I just rebuilt a system and forgot to plug in the 120mm fan in front of the drives.  When I opened the case up to reconnect the fan the hard drives where scorching hot.  After rebooting I checked the drive temperatures using hddtemp, 59C-66C.  Ouch!  Now with the fan connect, the drives are 42C-48C.

Nothing kills a drive faster then heat, so I decided to start monitoring them.   Here is a script that uses hddtemp to monitor the drive temperature and send out an alert and if the drive reaches critical condition will shut the machine down. To install hddtemp on Ubuntu run: sudo apt-get install hddtemp

#! /bin/bash

#List of devices to monitor
DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf"

#Email address to send alerts to

#Mail program

#Alert temperature before sending alerts

#Max temperature before shutting down down

SHUTDOWN_CMD="/sbin/shutdown -h now"

for HD in $DEVICES
    TEMP=`/usr/sbin/hddtemp -n $HD`
    logger "Checking temperature on $HD... ($TEMP C)";
    if [ "$TEMP" -gt "$ALERT_TEMP" ]; then

        DATA=`/usr/sbin/hddtemp $HD`
        MSG="$HOSTNAME Drive temperature critical"
        echo " "
        echo "$DATA"
        echo " "
        ) | $MAIL -s "$MSG" $SYSADMIN

    if [ "$TEMP" -gt "$KILL_TEMP" ]; then


The following added to cron.d runs the script every 5mins.

*/5 * * * * root /usr/local/bin/