Monitoring temperature, fan-speed and voltage sensors

Configuring kernel options

To allow the monitoring of various hardware sensors the Linux kernel provides a variety of device drivers. Those which are required to be enabled, either built in to the kernel or as modules, are shown in the kernel configuration sections below. As these options are kernel version dependent they may look slightly different on the version you are using.

Device Drivers
  • [*]
  • [*]
  • [*]
  • I2C support  --->
  • Hardware Monitoring support  --->
  • Generic Thermal sysfs driver  --->
  • CONFIG_I2C
  • CONFIG_HWMON
  • CONFIG_THERMAL

As you can see from the example above the drivers which are required are I2C support, which has a host of options of its own as described below, Hardware Monitoring support which provides drivers for the actual sensor devices, and the Generic Thermal sysfs driver which offers a new generic method for thermal management.

When selecting the Hardware Monitoring support drivers one can either refer to the documentation which was provided by the hardware manufacturer or, more commonly, simply build every possible driver as a module and use the sensors-detect application provided by the lm_sensors package to detect which drivers are required. The remainder can then be disabled if desired and the kernel rebuilt.

I2C support
  • ---
  • [ ]
  • [*]
  • [*]
  •  
  • [ ]
  • [ ]
  • [ ]
  • I2C support
    • Enable compatibility bits for old user-space
    • I2C device interface
    • Autoselect pertinent helper modules
    • I2C Hardware Bus support  --->
    • I2C Core debugging messages
    • I2C Algorithm debugging messages
    • I2C Bus debugging messages
  •  
  • CONFIG_I2C_COMPAT
  • CONFIG_I2C_CHARDEV
  • CONFIG_I2C_HELPER_AUTO
  •  
  • CONFIG_I2C_DEBUG_CORE
  • CONFIG_I2C_DEBUG_ALGO
  • CONFIG_I2C_DEBUG_BUS

The drivers contained in the I2C Hardware Bus support provide access to the various types of I2C bus. You can either identify which types of bus your hardware uses or enable everything here as a module. The Miscellaneous I2C Chip support section contains drivers for miscellaneous I2C devices which are usually only rarely found on current hardware. These can either be enabled as modules or ignored.

Generic Thermal sysfs driver
  • ---
  • [*]
  • Generic Thermal sysfs driver
    • Hardware monitoring support
  •  
  • CONFIG_THERMAL_HWMON

Installing the package

Before we install any packages we should ensure that the correct use-flags are configured so that all required functionality is made available and unnecessary functionality is not included. The lm_sensors package and its dependencies provide a variety of use-flags only some of which will be discussed further here. As usual feel free to add and remove use-flags at will although the minimum set which are required for using this guide in its entirety are shown below.

lisa emerge -pv lm_sensors
 
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild      ] media-libs/freetype-2.3.9-r1  USE="-X -bindist -debug -doc -fontforge -utils"
[ebuild      ] x11-libs/pixman-0.17.2  USE="mmx sse2 -debug"
[ebuild      ] media-libs/libpng-1.2.40
[ebuild      ] media-libs/fontconfig-2.8.0  USE="-doc"
[ebuild      ] app-admin/eselect-fontconfig-1.0
[ebuild      ] x11-libs/cairo-1.8.8  USE="svg -X -cleartype -debug -directfb -doc -glitz -opengl -xc"
[ebuild      ] x11-libs/pango-1.24.5-r1  USE="-X -debug -doc -test"
[ebuild      ] net-analyzer/rrdtool-1.3.8  USE="nls perl python -doc -rrdcgi -ruby -tcl"
[ebuild      ] sys-apps/lm_sensors-3.1.2  USE="sensord"

Once you are confident that the correct use-flags are set for the lm_sensors package, and any dependencies it may require, you can proceed with the installation by issuing the emerge command shown below.

lisa emerge lm_sensors

Detecting and configuring sensors

When the installation is complete we can use the interactive sensors-detect application, which we just installed as part of the lm_sensors package, to detect which hardware sensors are provided by the hardware we are using and which of those are supported by drivers which we have built in the previous section.

lisa sensors-detect

As the detection process is very well documented on-screen during the detection process, in the sensors-detect manual and on the Internet we shall not describe the process in any way and simply trust that some sensors were detected and that if they were not sufficient information is available elsewhere to enable successful troubleshooting of this problem.

Once the sensors have been detected the lm_sensors daemon can be started, as shown below.

lisa /etc/init.d/lm_sensors start
lisa rc-update add lm_sensors default

Assuming that the lm_sensors daemon started correctly, and that the correct kernel modules were automatically loaded during daemon startup, the sensors can be interrogated using the sensors application as shown below.

lisa sensors
w83793-i2c-0-2f 
Adapter: SMBus nForce2 adapter at 4c00 
VcoreA:      +1.20 V  (min =  +0.00 V, max =  +2.05 V) 
VcoreB:      +1.20 V  (min =  +0.00 V, max =  +2.05 V) 
in2:         +1.20 V  (min =  +0.00 V, max =  +2.05 V) 
in3:         +1.78 V  (min =  +0.00 V, max =  +4.08 V) 
in4:         +0.00 V  (min =  +0.00 V, max =  +4.08 V) 
in5:         +3.33 V  (min =  +0.00 V, max =  +4.08 V) 
in6:         +0.99 V  (min =  +0.00 V, max =  +2.04 V) 
+5V:         +5.12 V  (min =  +4.52 V, max =  +5.50 V) 
5VSB:        +5.12 V  (min =  +4.52 V, max =  +5.50 V) 
Vbat:        +3.04 V  (min =  +2.70 V, max =  +3.30 V) 
fan1:       1211 RPM  (min =    0 RPM) 
fan2:       1245 RPM  (min =    0 RPM) 
fan3:       1196 RPM  (min =    0 RPM) 
fan4:          0 RPM  (min =    0 RPM) 
fan5:          0 RPM  (min =    0 RPM) 
fan6:          0 RPM  (min =    0 RPM) 
fan7:          0 RPM  (min =    0 RPM) 
fan8:          0 RPM  (min =    0 RPM) 
fan9:          0 RPM  (min =    0 RPM) 
fan10:      2551 RPM  (min =    0 RPM) 
fan11:      2602 RPM  (min =    0 RPM) 
fan12:         0 RPM  (min =    0 RPM) 
temp1:       +55.5 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermal diode 
temp2:       +55.2 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermal diode 
temp3:      -128.0 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermal diode 
temp4:      -128.0 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermal diode 
temp5:       +34.0 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermistor 
temp6:       +39.0 C  (high = +100.0 C, hyst = +95.0 C)  sensor = thermistor 
beep_enable:disabled 

Logging sensor data

Now that we have detected and configured the hardware sensors correctly, and verified that this is the case using the sensors application as shown above, we can start the monitoring daemon to periodically check and log the values of those sensors as shown below.

lisa /etc/init.d/sensord start
lisa rc-update add sensord default