/hddtemp

smartctl-based replacement for hddtemp

Primary LanguageShellMIT LicenseMIT

Motivation

The original hddtemp is not maintained far too long. Due to that it was removed from the official repositories of Ubuntu (since 22.04) and Debian (since 12). This tool can be used instead to print the temps:

> sudo hddtemp-lt
/dev/sda    WDC WD10EFRX-68FYTN0       28
/dev/nvme0  Samsung SSD 950 PRO 256GB  40

Requirements

  • smartctl from smartmontools package
    • NVMe support: smartctl v6.5 (Ubuntu 16.10, Debian 8 (backports)) or higher

Usage

hddtemp-lt [options] [disk1 ..]

Without any disk arguments, show temperature for all sd and nvme disks.

Options

-h, --help
Show usage
-q
Suppress warnings
-V, --version
Show version
--classic
Replicate output format of the original hddtemp
--classic-tcp
Replicate TCP daemon output format of the original hddtemp
--hint path
Provide a file containing smartctl --scan-open output as a hint for device types (-d option value for smartctl)
-n, --numeric
Print only the temperature, unitless
-u, --units C|F
Use Celsius (default) or Fahrenheit scale

Sometimes you could see NA (Not Available) printed instead of info about some disk. It could mean smartctl failed to auto-detect the connection type. In the case, first scan your devices (it is important to use --scan-open, not just --scan):

sudo smartctl --scan-open | tee smart-scan.txt

Next, feed it to the --hint option:

sudo hddtemp-lt --hint smart-scan.txt

Notice: It is important to keep the hint file in sync with connected disks.

It is possible for sudo smartctl --scan-open to print nothing about your disk. It happens with devices not yet listed in some database smartctl uses. For example, as of Q3 2024, smartctl in a fully upgraded Ubuntu 22.04 system does not recognize a Ugreen USB disk enclosure 0bda:9201. In the case, you should craft a makeshift hint. If it is a generic USB disk enclosure, this would be it for a fictional /dev/sdX:

/dev/sdX -d sat

By default, output is aligned into columns. Device models can contain spaces like WDC WD10EFRX-68FYTN0 or Samsung SSD 950 PRO 256GB so fields are separated by at least two spaces.

When --classic is applied:

  • output is not aligned, fields are separated by a colon followed by a space
  • scale marker is added

Sample classic output:

> sudo hddtemp-lt --classic
/dev/sda: WDC WD10EFRX-68FYTN0: 28°C
/dev/nvme0: Samsung SSD 950 PRO 256GB: 40°C

When --classic-tcp is applied:

  • output is not aligned, fields are pipe separated
  • there are no newlines
  • units marker is a separate field

Sample classic-tcp output:

> sudo hddtemp-lt --classic-tcp
|/dev/sda|WDC WD10EFRX-68FYTN0|28|C||/dev/nvme0|Samsung SSD 950 PRO 256GB|40|C|

Under systemd/ you can find basic systemd unit files to run a hddtemp-compatible tcp server on port 7634.

Notice: hddtemp-lt@.service assumes the tool is installed into /opt/hddtemp.

Installation

Fetch the archive either from releases or from the development branch, extract it and put hddtemp-lt under /usr/local/bin/. In case you downloaded the script alone from github by a raw link, be sure to manually make it executable.

How to provide smartctl output samples

No serial numbers, no time:

sudo smartctl -q noserial -i -A -l scttempsts /dev/sda | grep -v 'Local Time is'