Difference between revisions of "Hddtemp"

From ArchWiki
Jump to: navigation, search
(Daemon: Remove rc.d info. Not supported by Arch anymore.)
(simplification and beautification of wikilinks (interactive))
(Tag: wiki-scripts)
 
(41 intermediate revisions by 14 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|Conky}}
 +
{{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. You can list several drives 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.
 
  
Once hddtemp has been installed, standard systemctl procedures work to start the daemon:
+
{{Note|Block device naming under {{ic|/dev/}}, like {{ic|/dev/sdX}}, is inconsistent. See [[Persistent block device naming]] for information on using persistent device paths.
  # systemctl start hddtemp
+
}}
 +
 
 +
Further usage information is available in the manpage:
 +
 
 +
  $ man hddtemp
  
To start it on boot, enable it:
+
== Daemon ==
# systemctl enable hddtemp
 
  
{{Note|1=Arguments to {{ic|hddtemp}} are directly given in {{ic|/usr/lib/systemd/system/hddtemp.service}}. This is especially important if you have multiple disks, because in the default configuration only {{ic|/dev/sda}} is monitored. Here is how to add other drives:
+
Running the daemon allows access to the temperature information via TCP/IP as a regular user. This is useful for scripts and system monitors.  
* Change the {{ic|ExecStart}} line in {{ic|/usr/lib/systemd/system/hddtemp.service}} adding the drives you want to monitor, e.g.:
 
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb
 
* Reload systemd's unit files:
 
# systemctl --system daemon-reload
 
* Restart hddtemp service:
 
{{bc|# systemctl restart hddtemp}}
 
}}
 
  
===Usage===
+
The daemon is [[Systemd#Using_units|controlled]] by {{ic|hddtemp.service}}.
  
Another way to get the temperature is by connecting to the daemon which is listening on port 7634.
+
To get the temperature, connect to the daemon which listens on port 7634.
  
 +
With {{pkg|inetutils}}:
 
  $ 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:
  $ man hddtemp
+
 
 +
|/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}}
 +
 
 +
=== Override default disk ===
 +
 
 +
The default hddtemp daemon only monitors {{ic|/dev/sda}}. If you have multiple disks, you need to [[Systemd#Editing provided units|override]] the default configuration to monitor them.
 +
 
 +
You will need to know which hard drives support monitoring. You can check with {{Pkg|smartmontools}}.
 +
 
 +
First run this command which will open your default text editor:
 +
# systemctl edit hddtemp.service
 +
 
 +
Add the following text:
 +
{{hc|/etc/systemd/system/hddtemp.service.d/<temp file>|2=
 +
[Service]
 +
ExecStart=
 +
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc
 +
}}
 +
 
 +
Change the device names to the ones you want to monitor.
 +
 
 +
After editing, save the file and [[reload]] ''systemd'''s unit files then [[restart]] the {{ic|hddtemp}} service
 +
 
 +
You can also use the [https://github.com/AndyCrowd/auto-generate-configuration-files/blob/master/gen-customexec.conf-hddtemp.sh auto-generate] script will detect supported hard drives using {{Pkg|smartmontools}} and print to the stdout.
 +
 
 +
== Monitors ==
 +
 
 +
Hddtemp can be integrated with [[List_of_applications#System_monitoring|system monitors]]. [[Conky]] has built in support for hddtemp in daemon mode. You just need to add {{ic|$hddtemp °C}} to your conky configuration file.
 +
 
 +
== 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
  
==Monitors==
+
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 15:07, 24 March 2018

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. You can list several drives separated by spaces:

# hddtemp /dev/sdX1 /dev/sdX2 ... /dev/sdXn
Note: Block device naming under /dev/, like /dev/sdX, is inconsistent. See Persistent block device naming for information on using persistent device paths.

Further usage information is available in the manpage:

$ man hddtemp

Daemon

Running the daemon allows access to the temperature information via TCP/IP as a regular user. This is useful for scripts and system monitors.

The daemon is controlled by hddtemp.service.

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

Override default disk

The default hddtemp daemon only monitors /dev/sda. If you have multiple disks, you need to override the default configuration to monitor them.

You will need to know which hard drives support monitoring. You can check with smartmontools.

First run this command which will open your default text editor:

# systemctl edit hddtemp.service

Add the following text:

/etc/systemd/system/hddtemp.service.d/<temp file>
[Service]
ExecStart=
ExecStart=/usr/bin/hddtemp -dF /dev/sda /dev/sdb /dev/sdc

Change the device names to the ones you want to monitor.

After editing, save the file and reload systemd's unit files then restart the hddtemp service

You can also use the auto-generate script will detect supported hard drives using smartmontools and print to the stdout.

Monitors

Hddtemp can be integrated with system monitors. Conky has built in support for hddtemp in daemon mode. You just need to add $hddtemp °C to your conky configuration file.

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