HDDのS.M.A.R.Tから温度を取得して表示してくれるhddtemp

hddtempというコマンドを知りました.熱いし熱が気になる時期だしお手軽に温度を知れるのは良さそうと試してみました.

導入

$ sudo apt install hddtemp

help

$ hddtemp -h
 Usage: hddtemp [OPTIONS] [TYPE:]DISK1 [[TYPE:]DISK2]...
 
   hddtemp displays the temperature of drives supplied in argument.
   Drives must support S.M.A.R.T.
 
  TYPE could be SATA, PATA or SCSI. If omitted hddtemp will try to guess.
 
  -b   --drivebase   :  display database file content that allow hddtemp to
                        recognize supported drives.
  -D   --debug       :  display various S.M.A.R.T. fields and their values.
                        Useful to find a value that seems to match the
                        temperature and/or to send me a report.
                        (done for every drive supplied).
  -d   --daemon      :  run hddtemp in TCP/IP daemon mode (port 7634 by default.)
  -f   --file=FILE   :  specify database file to use.
  -F   --foreground  :  don't daemonize, stay in foreground.
  -l   --listen=addr :  listen on a specific interface (in TCP/IP daemon mode).
  -n   --numeric     :  print only the temperature.
  -p   --port=#      :  port to listen to (in TCP/IP daemon mode).
  -s   --separator=C :  separator to use between fields (in TCP/IP daemon mode).
  -S   --syslog=s    :  log temperature to syslog every s seconds.
  -u   --unit=[C|F]  :  force output temperature either in Celsius or Fahrenheit.
  -q   --quiet       :  do not check if the drive is supported.
  -v   --version     :  display hddtemp version number.
  -w   --wake-up     :  wake-up the drive if need.
  -4                 :  listen on IPv4 sockets only.
  -6                 :  listen on IPv6 sockets only.
 
Report bugs or new drives to <hddtemp@guzu.net>.
hddtemp version 0.3-beta15

デバイスを指定すると温度が取得できます./dev/sd[a-z]とか/dev/sd?とかも使えました.
/dev/sdd, /dev/sdeはS.M.A.R.Tを使えないUSBアダプタ経由で繋いでいるので取得できませんでした.

$ sudo hddtemp /dev/sda
/dev/sda: VB0250EAVER: 37°C
$ sudo hddtemp /dev/sda /dev/sdb
/dev/sda: VB0250EAVER: 38°C
/dev/sdb: Hitachi HDS5C3030ALA630: 39°C
$ sudo hddtemp /dev/sd?
/dev/sda: VB0250EAVER: 37°C
/dev/sdb: Hitachi HDS5C3030ALA630: 37°C
/dev/sdc: WDC WD30EZRX-00MMMB0: 40°C
/dev/sdd: WDC WD30EZRX-00DC0B0: S.M.A.R.T. not available
/dev/sde: TOSHIBA DT01ACA300: S.M.A.R.T. not available

デーモン化もできます.tcp 7634にアクセスると値が取得できます.

$ sudo hddtemp -d /dev/sda
$ nc localhost 7634
|/dev/sda|VB0250EAVER|37|C|

停止

$ pgrep hddtemp
11832
$ sudo kill 11832

複数デバイスも行けるけどそのままでは見にくいですね.

$ sudo hddtemp -d /dev/sd?
$ nc localhost 7634
|/dev/sda|VB0250EAVER|38|C||/dev/sdb|Hitachi HDS5C3030ALA630|39|C||/dev/sdc|WDC WD30EZRX-00MMMB0|41|C||/dev/sdd|WDC WD30EZRX-00DC0B0|NA|*||/dev/sde|TOSHIBA DT01ACA300|NA|*|
$ nc localhost 7634|sed -e 's/||/|\n|/g'
|/dev/sda|VB0250EAVER|37|C|
|/dev/sdb|Hitachi HDS5C3030ALA630|38|C|
|/dev/sdc|WDC WD30EZRX-00MMMB0|40|C|
|/dev/sdd|WDC WD30EZRX-00DC0B0|NA|*|
|/dev/sde|TOSHIBA DT01ACA300|NA|*|

S.M.A.R.Tの値を元にしているのでこのツールを使わず大抵の環境で入っているsmartctlでも良い気もします.

$ sudo smartctl -a /dev/sda|grep -i temp
190 Airflow_Temperature_Cel 0x0022   063   056   045    Old_age   Always       -       37 (Min/Max 31/43)
194 Temperature_Celsius     0x0022   037   044   000    Old_age   Always       -       37 (0 11 0 0 0)

環境

$ lsb_release -d
Description:    Ubuntu 16.04.4 LTS
$ uname -m
x86_64
$ dpkg-query -W hddtemp smartmontools
hddtemp 0.3-beta15-52
smartmontools   6.4+svn4214-1

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)