Hddtemp

Related articles

hddtemp is a small utility (with daemon) that gives the hard-drive temperature via S.M.A.R.T. (for drives supporting this feature).

Installation

Install hddtemp from the official repositories.

Usage

Hddtemp requires root privileges. The command hddtemp must be followed by at least one drive's location, with several directories separated by spaces:

# hddtemp /dev/sdX1 /dev/sdX2 ... /dev/sdXn

Daemon

Running the daemon allows to access the temperature via TCP/IP, to use for example with scripts.

The daemon is controlled by hddtemp.service.

Note: Arguments to hddtemp are directly given in /usr/lib/systemd/system/hddtemp.service. This is especially important with multiple disks, as the default configuration only monitors /dev/sda. Change ExecStart to override hddtemp.service:
  • Create a directory in /etc/systemd/system:
# mkdir /etc/systemd/system/hddtemp.service.d
  • Create customexec.conf inside and add the drives you want to monitor, e.g.:
/etc/systemd/system/hddtemp.service.d/customexec.conf
[Service]
ExecStart=
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc

You can also the auto-generate script that detects with help of smartmontools all supported by hddtemp hard-drivers and generating to the stdout the customexec.conf pattern file.

  • Reload systemd's unit files:
# systemctl --system daemon-reload
  • Restart the hddtemp service:
# systemctl restart hddtemp

To get the temperature, connect to the daemon which listens on port 7634. With inetutils:

$ telnet localhost 7634

With gnu-netcat:

$ nc localhost 7634

Both outputs are similar to:

|/dev/sda|ST3500413AS|32|C||/dev/sdb|ST2000DM001-1CH164|36|C|

For a better looking statistic:

$ nc localhost 7634 |sed 's/|//m' | sed 's/||/ \n/g' | awk -F'|' '{print $1 " " $3 " " $4}'
/dev/sda 32 C 
/dev/sdb 36 C

Refer to the manpage for more information:

$ man hddtemp

Monitors

Hddtemp can be integrated with system monitors.