nixCraft Poll

Topics

Linux: Monitor hard disks temperature with hddtemp

Posted by Vivek Gite [Last updated: October 9, 2007]

There is a nice utility to monitor hard drive temperature. Most modern x86 computer hard disk comes with S.M.A.R.T (Self-Monitoring, Analysis, and Reporting Technology). It is a monitoring system for computer hard disks to detect and report on various indicators of reliability, in the hope of anticipating failures.

hddtemp utility will give you the temperature of your hard drive by reading data from S.M.A.R.T. on drives that support this feature. Only modern hard drives have a temperature sensor. hddtemp supports reading S.M.A.R.T. information from SCSI drives too. hddtemp can work as simple command line tool or as a daemon to get information from all servers.

Install hddtemp

To install hddtemp under Debian / Ubuntu Linux, enter:
$ sudo apt-get install hddtemp
You can also perform source code installation. Download source code tar ball here.
$ wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp-0.3-beta15.tar.bz2
Untar and install hddtemp:
$ tar -jxvf hddtemp-0.3-beta15.tar.bz2
$ cd hddtemp-0.3-beta15
$ ./configure
$ make
$ sudo make install

Install hard disk temperature database at /usr/share/misc or /etc directory:
$ cd /usr/share/misc
# wget http://download.savannah.nongnu.org/releases/hddtemp/hddtemp.db

How do I monitor hard disk temperature?

To see temperature for /dev/sda, enter the following command:
# hddtemp /dev/sda
Output:

/dev/sdb: WDC WD2500YS-01SHB1:  25°C

Above output indicate that my hard disk temperature is 25°C. if temperature is higher than 60°С , consider cooling options immediately.

How do I find out remote server temperature?

By default hddtemp bind to TCP/IP port 7634.
You need to run hddtemp in daemon mode. Login on remote box and start it as follows to monitor /dev/sda, /dev/sdb..,/dev/sdd:
# hddtemp -d /dev/sd[abcd]
Use telnet or nc / netcat command to to get a temperature from a remote box:
$ telnet remotebox 7634
OR
$ nc 192.168.1.100 7634

Shutdown Linux computer if temperature >= 55

To power off / shutdown computer, run following command via cron tab file:
[ $(hddtemp /dev/sda | awk '{ print $4}' | awk -F '°' '{ print $1}') -ge 55 ] && /sbin/shutdown -h 0 || :
Sample shell script to shutdown box if temperature >= 55°C (download link):

#!/bin/bash
HDDS="/dev/sda /dev/sdb /dev/sdc"
HDT=/usr/sbin/hddtemp
LOG=/usr/bin/logger
DOWN=/sbin/shutdown
ALERT_LEVEL=55
for disk in $HDDS
do
  if [ -b $disk ]; then
	HDTEMP=$($HDT $disk | awk '{ print $4}' | awk -F '°' '{ print $1}')
        if [ $HDTEMP -ge $ALERT_LEVEL ]; then
           $LOG "System going down as hard disk : $disk temperature $HDTEMP°C crossed its limit"
           sync;sync
           $DOWN -h 0
        fi
  fi
done

smartctl utility

If you have smartctl utility installed, try it as follows:
# smartctl -d ata -A /dev/sda | grep -i temperature
Output:

194 Temperature_Celsius     0x0022   122   095   000    Old_age   Always       -       28

Set ALERT_LEVEL as per your requirements. Please refer to your hard disk manual for working temperature guideline. Here is general temperature guideline (extracted from Seagate SV35.2 Series Hard Drives Web Page):

Operating 0 to 60 degrees C
Nonoperating -40 to 70 degrees C
Maximum operating temperature change 20 degrees C per hour
Maximum nonoperating temperature change 30 degrees C per hour
Maximum operating case temperature 69 degrees C

A note for Windows XP / Vista / Server users

hddtemp is UNIX / Linux only program. You can download hddtemp trial version here. There is also Dtemp (it is not updated in ages).

Related tutorials

Further readings

Updated for accuracy!

Want to stay up to date with the latest Linux tips, news and announcements? Subscribe to our free e-mail newsletter or RSS feed to get all updates. You can Email this page to a friend.

You may also be interested in other helpful articles:

Discussion on This Article:

  1. Mace Moneta Says:

    35C is a little premature to be shutting down the system, or even to get additional cooling. Most manufacturers specify a maximum operating temperature of 60C as being fully within specifications. Check your drive manufacturer’s web site for the specifications for your particular drive. During periods of high activity (e.g., backups, RAID sync), a drive can easily exceed 50C. Shutting down every time that happens is not productive.

  2. vivek Says:

    Mace,

    I agree with you. 35C is just for example. You can set ALERT_LEVEL as per your requirements or just send an email. The post has been updated to reflect your views.

    Appreciate your post!

  3. the polarizer Says:

    Neat little howto. Instant success

    box@ubuntu:~$ sudo hddtemp /dev/sda
    /dev/sda: SAMSUNG SPXXXX: 33°C
    box@ubuntu:~$ sudo hddtemp /dev/sdb
    /dev/sdb: SAMSUNG SPXXXX: 32°C

    Here on my striped raid.

    I would welcome a warning instead of immediate box shutdown w/o named reason. Some speaker beeps would fulfill that approach.

    the polarizer

    PS: Have to check whether the sda drive which is more hot is on the top.

  4. Sweta Says:

    Vivek,

    Nice program. I’m gonna try out hddtemp for windows xp sp2.

    Cheers,

    STT

  5. marxjo Says:

    For example. Seagate disks work normally even at 50C, but if such temp will last longer, Seagate drives will start to squel, but if you have a server room…

  6. I_LOVE_Missouri Says:

    I personally think that you are the best Linux blogger that I’ve ever seen. I read your blog all the time and I think it’s so well done. My browser home page set to cyberciti.biz!

  7. vivek Says:

    Thanks for the feedback! You made my day :D

  8. Pragadeshv Says:

    Its Really use full for me. Thanks vivek.

  9. pete Says:

    this program has an error with my version of hddtemp.
    $4 should read $3
    ‘ should read ‘
    so the line should be:
    HDTEMP=$($HDT $disk | awk ‘{ print $3}’ | awk -F ‘°’ ‘{ print $1}’)

    additionally, if a shutdown is to occur, and there is more than one hard drive, the shutdown command will be executed for the number of hard drives that exceed the temperature. i am a linux newbie and don’t know if this is relevant.
    P.

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

Tags: , , , , , ,

Copyright © 2004-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Sitemap - Powered by Open source software.