It is often overlooked that hard drives which are available on the market provide temperature measurements. This temperature can be effortlessly monitored using hddtemp application by Emmanuel Varagnat.

Installation

Use the following command to install hddtemp package.

$ sudo apt-get install hddtemp

Basic usage

Provide hard drive device as an application argument to print its temperature.

$ sudo hddtemp /dev/sda
/dev/sda: ST1000DM003-1CH162: 31°C
Notice that application requires root privileges.

Add an --numeric argument to print only the temperature.

$ sudo hddtemp --numeric /dev/sda
31

You can easily provide multiple devices.

$ sudo hddtemp /dev/sda /dev/sdb
/dev/sda: ST1000DM003-1CH162: 31°C
/dev/sdb: ST1000DM003-1CH162: 33°C
$ sudo hddtemp /dev/sd[a-z]
/dev/sda: ST1000DM003-1CH162: 31°C
/dev/sdb: ST1000DM003-1CH162: 33°C

Specify an --unit argument to use Celsius or Fahrenheit.

$ sudo hddtemp --unit C /dev/sda
/dev/sda: ST1000DM003-1CH162: 31°C
$ sudo hddtemp --unit F /dev/sda
/dev/sda: ST1000DM003-1CH162: 89°F

Daemon mode – syslog

Switch into daemon mode and log to syslog every hour (3600 seconds).

$ sudo hddtemp --syslog 3600 /dev/sda
$ tail /var/log/syslog
[...]
Aug 26 21:34:27 fileserver hddtemp[17924]: /dev/sda: ST1000DM003-1CH162: 31 C
[...]
Aug 26 22:34:27 fileserver hddtemp[17927]: /dev/sda: ST1000DM003-1CH162: 32 C
[...]
Aug 26 23:34:28 fileserver hddtemp[17927]: /dev/sda: ST1000DM003-1CH162: 31 C
[...]

Daemon mode – network server

Switch into daemon mode and listen on every interface using port 7634.

$ sudo hddtemp -d /dev/sda
$ sudo netstat -tapn | grep hddtemp
tcp        0      0 0.0.0.0:7634            0.0.0.0:*               LISTEN      18256/hddtemp
$ nc localhost 7634 && echo
|/dev/sda|ST1000DM003-1CH162|32|C|

Switch into daemon mode and listen on localhost using port 7634.

$ sudo hddtemp -d --listen localhost --port 7634  /dev/sd[a-z]
$ nc localhost 7634 && echo
|/dev/sda|ST1000DM003-1CH162|32|C|
|/dev/sdb|ST1000DM003-1CH162|31|C|

I will post more information next week so stay tuned.