Difference between revisions of "Hddtemp"

From ArchWiki
Jump to: navigation, search
(Added systemd start procedures, should probably remove the initscripts section soon™)
m (S.M.A.R.T -> S.M.A.R.T.)
 
(29 intermediate revisions by 12 users not shown)
Line 1: Line 1:
 
[[Category:Status monitoring and notification]]
 
[[Category:Status monitoring and notification]]
[https://savannah.nongnu.org/projects/hddtemp/ hddtemp] is a small utility (daemonizable) that gives you the temperature of your hard drive by reading S.M.A.R.T. information (for drives that support this feature).
+
[[ja:Hddtemp]]
 +
[[ru:Hddtemp]]
 +
{{Related articles start}}
 +
{{Related|lm sensors}}
 +
{{Related articles end}}
 +
[https://savannah.nongnu.org/projects/hddtemp/ 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==
+
== Installation ==
  
Sync and install with pacman:
+
[[Install]] {{Pkg|hddtemp}} from the [[official repositories]].
# pacman -S hddtemp
+
  
==Usage==
+
== Usage ==
  
Hddtemp can be invoked with the drive as the argument:
+
Hddtemp requires root privileges. The command {{ic|hddtemp}} must be followed by at least one drive's location, with several directories separated by spaces:
# hddtemp /dev/sd[x]
+
Where '''x''' is the drive.
+
  
==Daemon==
+
# hddtemp /dev/sd''X1'' /dev/sd''X2'' ... /dev/sd''Xn''
Running the daemon gives you the possibility to access the temperature via an TCP/IP request, so you could use this in order to check the temperature from outside, or within some scripts.
+
===Setup with systemd===
+
  
Once hddtemp has been installed, standard systemctl procedures work to start the daemon:
+
== Daemon ==
# systemctl start hddtemp
+
  
To start it on boot, enable it:
+
Running the daemon allows to access the temperature via TCP/IP, to use for example with scripts.
#systemctl enable hddtemp
+
  
===Setup with legacy initscripts===
+
The daemon is [[Systemd#Using_units|controlled]] by {{ic|hddtemp.service}}.
  
Start the daemon:
+
{{Note|1=Arguments to {{ic|hddtemp}} are directly given in {{ic|/usr/lib/systemd/system/hddtemp.service}}. This is especially important with multiple disks, as the default configuration only monitors {{ic|/dev/sda}}. Change {{ic|ExecStart}} [[Systemd#Editing provided units|to override]] {{ic|hddtemp.service}}:
# rc.d start hddtemp
+
  
Add the daemon to the DAEMONS array in /etc/rc.conf to facilitate auto-start on boot:
+
* Create a directory in {{ic|/etc/systemd/system}}:
# DAEMONS=(... '''hddtemp''' ...)
+
# mkdir /etc/systemd/system/hddtemp.service.d
 +
* Create {{ic|customexec.conf}} inside and add the drives you want to monitor, e.g.:
 +
{{hc|/etc/systemd/system/hddtemp.service.d/customexec.conf|2=
 +
[Service]
 +
ExecStart=
 +
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc
 +
}}
 +
You can also the [https://github.com/AndyCrowd/auto-generate-configuration-files/blob/master/gen-customexec.conf-hddtemp.sh auto-generate] script that detects with help of {{Pkg|smartmontools}} all supported by {{Pkg|hddtemp}} hard-drivers and generating to the stdout the {{ic|customexec.conf}} pattern file.
 +
* [[Reload]] systemd's unit files.
 +
* [[Restart]] the hddtemp service.
 +
}}
  
===Usage===
+
To get the temperature, connect to the daemon which listens on port 7634. With {{pkg|inetutils}}:
 
+
Another way to get the temperature is by connecting to the daemon which is listening on port 7634.
+
  
 
  $ telnet localhost 7634
 
  $ telnet localhost 7634
Or with netcat:
+
 
 +
With {{pkg|gnu-netcat}}:
 +
 
 
  $ nc localhost 7634
 
  $ nc localhost 7634
  
Refer to the manpage for information like supported drives, logging, etc.
+
Both outputs are similar to:
 +
 
 +
|/dev/sda|ST3500413AS|32|C||/dev/sdb|ST2000DM001-1CH164|36|C|
 +
 
 +
For a better looking statistic:
 +
 
 +
{{hc|<nowiki>$ nc localhost 7634 |sed 's/|//m' | sed 's/||/ \n/g' | awk -F'|' '{print $1 " " $3 " " $4}'</nowiki>|/dev/sda 32 C
 +
/dev/sdb 36 C}}
 +
 
 +
Refer to the manpage for more information:
 +
 
 
  $ man hddtemp
 
  $ man hddtemp
  
==Monitors==
+
== Monitors ==
 +
 
 +
Hddtemp can be integrated with [[List_of_applications#System_monitoring|system monitors]].
 +
 
 +
== Solid State Drives ==
 +
 
 +
Hddtemp usually reads field {{ic|194}} from the smart data of the drive. In SSDs temperature information is usually stored in field {{ic|190}}. To obtain this information, one can run:
 +
 
 +
$ smartctl -a /dev/sdX
 +
or
 +
$ hddtemp --debug /dev/sdX
 +
 
 +
where X is a character (e.g. a,b,c...) representing the drive. Use {{ic|lsblk}} to check this.
  
Hddtemp can be easily integrated with system monitors like [[Conky]], the {{pkg|sensors-applet}} for GNOME Panel or the {{pkg|xfce4-sensors-plugin}} for Xfce Panel.
+
Alternatively, add a new entry in {{ic|/usr/share/hddtemp/hddtemp.db}}. For example:
  
== See also ==
+
$ echo '"Samsung SSD 840 EVO 250G B" 190 C "Samsung SSD 840 EVO 250GB"' >> /usr/share/hddtemp/hddtemp.db
[[lm sensors]]
+

Latest revision as of 01:56, 19 November 2016

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.

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.

Solid State Drives

Hddtemp usually reads field 194 from the smart data of the drive. In SSDs temperature information is usually stored in field 190. To obtain this information, one can run:

$ smartctl -a /dev/sdX

or

$ hddtemp --debug /dev/sdX

where X is a character (e.g. a,b,c...) representing the drive. Use lsblk to check this.

Alternatively, add a new entry in /usr/share/hddtemp/hddtemp.db. For example:

$ echo '"Samsung SSD 840 EVO 250G B" 190 C "Samsung SSD 840 EVO 250GB"' >> /usr/share/hddtemp/hddtemp.db