lm_sensors

From LinuxReviews
Jump to navigationJump to search
lm_sensors
Typical lm_sensors output.
Typical lm_sensors output.
Repositorygithub.com /lm-sensors/lm-sensors
Written inC
Operating systemLinux
TypeSystem utility for hardware sensors and fan control
LicenseGNU General Public License
Temperature-icon.svg

lm_sensors, or just sensors, is a system utility for displaying information from the Linux kernels hardware monitor sensors. It can display a wide range of information like temperatures, voltages, fan speeds and more depending on what kernel modules are loaded and what information they provide. lm_sensors comes with a simple bash script called fancontrol that can be used to adjust fan speeds depending on the system temperature.

lm_sensors does not include any graphical program for displaying sensor information. There is also no graphical front-end for creating fan speed curves or anything like that. There's the simple sensors program that displays sensor information in a terminal and a bash script called fancontrol and a systemd that can start and stop that script (it runs in a loop).

Utilities

The only three tools from the lm_sensors package you need are likely sensors, for getting sensor output in a terminal, pwmconfig to figure out how to write a /etc/fancontrol configuration file and fancontrol to control your system fans if you figure out how to write a configuration file for it that will actually work on your machine. You may have use for sensors-detect once in your lifetime but it's not very likely.

Utility Function
sensors Displays sensor information in a terminal

Lm sensors output.jpg

sensors-conf-convert Converts ancient lm_sensors configurations to the "new" format now standard and used for a decade. Just ignore it, it's there for historical purposes.
fancontrol Fan control script that runs as a systemd service (fancontrol.service). Reads the configuration file /etc/fancontrol which is nice if you have one for your machine and border-line black magic to configure if you don't.
isadump Manual page story[1] is for what it does what it sounds like: "examine ISA registers"
isaset "set ISA registers". We have no idea why you would want to do that. The manual page[2] has this scary warning: Poking around in ISA data space is extremely dangerous. Running isaset with random parameters can cause system crashes, data loss, and worse! Be extremely careful when using this program.
pwmconfig Tests the PWM controllers the kernel modules you have loaded exposes. Those would likely be fan control interfaces. pwmconfig can ask fan headers to set the speed to zero, max and various in between so you can figure out what mysterious Linux kernel names belong to actual controllable fans on your system. It can propose a /etc/fancontrol configuration file based on the results.
sensors-detect Tries to detect what sensors are present on your system. This can be useful but it's probably not. It can be used to tell you what kernel modules you should load in case the proper modules are not loaded automagically.

lm_sensors does not come with any graphical programs. A lot of graphical programs that will display the sensors programs output do exists. The KDE System Monitor and psensor are examples that let you see the sensors output in fancy graphical graph output.

Device-Specific Drivers

Some hardware requires modules that are not included in the stock Linux kernel in order to produce proper sensor output (and fan control).

AMD AM4 Motherboards

The Linux kernel does not have support for a lot of sensors found on AMD motherboards. A now unmaintained out-of-tree version of the it87 module, available from a lot of GitHub mirrors created by random people who cloned the module until development seized, like github.com/a1wong/it87, can be used to get sensors output on a lot of AMD B350/X370 and B450/X470 motherboards. Using this module with most modern motherboards requires a module configuration file in /etc/modprobe.d:

File: /etc/modprobe.d/it87.conf
options it87 ignore_resource_conflict=1

Configuration

The sensors systemd service will read a file called /sysconfig/lm_sensors and load whatever modules are listed as HWMON_MODULES= in that file. You can use that to load sensor-related kernel modules if you really want to. You can, alternatively, simply create a file in /etc/modules-load.d/ that lists modules like:

File: /etc/modules-load.d/load-it87.conf
## The order MATTERS for PCI names used in /etc/fancontrol
k10temp
it87

It does not matter how you load the modules required to get temperature output from sensors, what rally matters is that the modules are loaded.

The sensors program from lm_sensors will read any and all configuration files present in /etc/sensors.d/ and adjust it's output accordingly. Consider this example for the amdgpu kernel module:

File: /etc/sensors.d/amdgpu-temp.conf
chip "amdgpu-pci-*"
	label fan1   "GPU fan"
	label power1 "GPU power"
	label temp1  "GPU temp"

The default sensors output for the amdgpu kernel module on modern Linux kernels looks like this:

amdgpu-pci-0700
Adapter: PCI adapter
vddgfx:        1.04 V  
fan1:        1226 RPM  (min =    0 RPM, max = 4500 RPM)
edge:         +54.0°C  (crit = +94.0°C, hyst = -273.1°C)
power1:       49.18 W  (cap = 120.00 W)

With a sensors configuration file with labels the sensors output becomes:

amdgpu-pci-0700
Adapter: PCI adapter
vddgfx:        1.04 V  
GPU fan:     1225 RPM  (min =    0 RPM, max = 4500 RPM)
GPU temp:     +54.0°C  (crit = +94.0°C, hyst = -273.1°C)
GPU power:    62.21 W  (cap = 120.00 W)

Sensor configuration files can also include adjustments to the kernel readings, specific sensors to ignore and a lot more.

It is worth checking out the lm_sensors git master/configs folder. it contains a lot of configuration files that are, for whatever reason, NOT included in the lm_sensors package. There is a /etc/sensors3.conf file included. It has configuration for like 5 ancient sensor chips nobody's used in a decade. You will likely want to get a configuration file for your hardware, if it exists, to get proper labels and output.

Footnotes

  1. manpage: isadump.8
  2. manpage: isaset.8

See also

Add your comment
LinuxReviews welcomes all comments. If you do not want to be anonymous, register or log in. It is free.