August 4, 2015

Linux: Monitor Hard Disks Temperature With hddtemp

There is a nice utility to  hard drive temperature. Most modern x86 computer hard 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  line tool or as a daemon to get information from all servers.

 hddtemp

To install hddtemp under  / , enter:
$ sudo apt-get install hddtemp
You can also perform source code installation.  the 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//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/sda: 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 HDD Temperature?

By default hddtemp bind to TCP/ 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/sdc, and /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 (cron job) 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 :
#!/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 to get temperature data:
# 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):
Operating0 to 60 degrees C
Nonoperating-40 to 70 degrees C
Maximum operating temperature change20 degrees C per hour
Maximum nonoperating temperature change30 degrees C per hour
Maximum operating case temperature69 degrees C

A note for  XP / Vista / Server Users

hddtemp is UNIX / Linux only program. You can download hddtemp trial version here.

Further readings

Updated for accuracy!
source; http://www.gocit.vn/

Related Posts:

  • 50 UNIX / Linux Sysadmin Tutorials I’ve collected 50 UNIX / Linux sysadmin related tutorials that we’ve posted so far. This is lot of reading. Bookmark this article for your future reference and read it whenever you get free time. Disk to disk backup using d… Read More
  • Hướng dẫn resize phân vùng /tmp Trong bài viết này, Hostvn sẽ hướng dẫn các bạn thay đổi dung lượng phần vùng /tmp thông qua scripts của cPanel. Các bạn làm tuần tự theo các bước dưới đây để tránh gặp lỗi trong quá trình resize. 1. Đầu tiên… Read More
  • Xem lượng RAM đã dùng trên Linux đúng cách Có rất nhiều bạn phàn nàn vấn đề rằng VPS luôn sử dụng full RAM, lượng RAM trống lúc nào cũng rất ít. Tuy nhiên, các bạn đã xem thông tin RAM đúng cách chưa? Hãy tham khảo bài viết bên dưới. Để xem lượng RAM đã sử dụng chún… Read More
  • Vô hiệu hóa chức năng PHP sử dụng disable_functions trong php.ini PHP là ngồn ngữ kịch bản có rất nhiều tính năng (hàm) phong phú. Tuy nhiên một số hàm này có thể dẫn đến những cuộc tấn công không mong muốn, hoặc làm giảm hiệu suất hoạt động của hệ thống. Để vô hiệu hóa các hàm này PHP cho… Read More
  • Hướng dẫn reset password cho VPS Linux Có thể vì 1 nguyên nhân nào đó, chủ quan hay khách quan khiến thông tin quản trị hiện tại của bạn không kết nối SSH đến server VPS linux đặt tại hệ thống của chúng tôi. Hoặc bạn không thể nhớ chính xác thông tin q… Read More

0 comments:

Post a Comment