Difference between revisions of "Hddtemp"

From ArchWiki
Jump to: navigation, search
(Installation: Font change)
(change category to Category:System monitors)
 
(66 intermediate revisions by 25 users not shown)
Line 1: Line 1:
[[Category:Mainboards and BIOS (English)]]
+
[[Category:System monitors]]
[[Category:HDD (English)]]
+
[[ja:Hddtemp]]
[[Category:Daemons and system services (English)]]
+
[[ru:Hddtemp]]
[[Category:HOWTOs (English)]]
+
{{Related articles start}}
=Description=
+
{{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).
  
'''Hddtemp''' is a daemon that monitors and reports hard disk temperature. It is a lightweight daemon and is useful for retrieving temperature readings for hard disks that have temperature sensors built into them.
+
== Installation ==
  
=Installation=
+
[[Install]] {{Pkg|hddtemp}} from the [[official repositories]].
  
Sync and install with pacman:
+
== Usage ==
# pacman -S hddtemp
 
  
Start the daemon:
+
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:
# /etc/rc.d/hddtemp start
 
  
Add the daemon to the DAEMONS array in /etc/rc.conf to facilitate auto-start on boot:
+
# hddtemp /dev/sd''X1'' /dev/sd''X2'' ... /dev/sd''Xn''
# DAEMONS=(coretemp it87 ... '''hddtemp''' ...)
 
  
=Usage=
+
{{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.
 +
}}
  
Hddtemp can be invoked with the drive as the argument:
+
Further usage information is available in the manpage:
# hddtemp /dev/sd[x]
 
Where '''x''' is the drive.
 
  
Another way to get the temperature is by connecting to the daemon which is listening on port 7634.
+
$ man hddtemp
  
# telnet localhost 7634
+
== Daemon ==
Or with [[netcat]]:
 
# netcat localhost 7634
 
  
For other information like hard drives supported, logging e.t.c. refer to the manpage:
+
Running the daemon allows access to the temperature information via TCP/IP as a regular user. This is useful for scripts and system monitors.  
# man hddtemp
 
  
=Monitors=
+
The daemon is [[Systemd#Using_units|controlled]] by {{ic|hddtemp.service}}.
  
Hddtemp can be easily integrated with system monitors like [[Conky]] or the GNOME sensors applet.
+
To get the temperature, connect to the daemon which listens on port 7634.
 +
 
 +
With {{pkg|inetutils}}:
 +
$ telnet localhost 7634
 +
 
 +
With {{pkg|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:
 +
 
 +
{{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 monitors|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
 +
 
 +
where X is a character (e.g. a,b,c...) representing the drive. Use {{ic|lsblk}} to check this.
 +
 
 +
Alternatively, add a new entry in {{ic|/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

Latest revision as of 17:21, 20 October 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