Linux OS Service ‘lm_sensors’

Service Name

lm_sensors

Description

The lm_sensors is a service, set up to monitor hardware like CPU temperature or fan speed. Not all system hardware provides the necessary sensor hardware resource for the lm_sensors service to be useful. Later lm_sensor packages include the sensors_detect utility, which can be used to probe which sensors your hardware provides and which drivers you need.

lm_sensors drivers include two groups:

  • Bus drivers are provided for the I2C(Inter IC-bus)/SMSbus(System Management Bus) buses;
  • Sensor Chips on PCI or ISA busses do not need a special bus driver. Chip drivers are used to access the sensor chips themselves.

The SMBus is a specific implementation of the more general I2C. In fact, both I2C devices and SMBus devices may be connected to the same (I2C) bus. The SMBus (or I2C bus) starts at the host controller, used for starting transactions on the SMBus. From the host interface, individual sensor chips are called as slave devices.

The lm_sensors service consists of application programs, lm_sensors script and several kernel modules. Depending on the kernel version and system hardware, some kernel modules are necessary, such as I2C core modules. The sensors-detect application mentioned earlier can be used to determine which kernel modules must be loaded.

lm_sensors is provided by the lm_sensors rpm package. Type the following command to install the package:

# yum install lm_sensors

Service Control

This service is handled by init.d script /etc/init.d/lm_sensors below:

# /sbin/service lm_sensors
Usage: -bash {start|stop|status|restart|condrestart}

The service lm_sensors will issue the command ‘sensors‘, which is used to show all the current readings of all sensor chips, and to set all limits as specified in the configuration file.

Configuration

lm_sensors service uses the config file /etc/sysconfig/lm_sensors to define the modules loaded by lm_sensors. Run sensors-detect to generate the config file. The default file is:

# more /etc/sysconfig/lm_sensors

# This file is used by /etc/rc.d/init.d/lm_sensors and defines the modules to
# be loaded/unloaded. This file is sourced into /etc/rc.d/init.d/lm_sensors.
#
# The format of this file is a shell script that simply defines the modules
# in order as normal variables with the special names:
#    MODULE_0, MODULE_1, MODULE_2, etc.
#
# List the modules that are to be loaded for your system
#
# Generated by sensors-detect on Wed Jan 14 21:46:56 2009
MODULE_0=i2c-i801
MODULE_1=eeprom

Another configuration file is /etc/sensors.conf, which describes how libsensors, and so all programs using it, should translate the raw readings from the kernel modules to real-world values. An example is as follows:

# more /etc/sensors.conf

chip "lm78-*" "lm78-j-*" "lm79-*" "w83781d-*"

    label in0 "VCore 1"
    label in1 "VCore 2"
    label in2 "+3.3V"
    label in3 "+5V"
    label in4 "+12V"
    label in5 "-12V"
    label in6 "-5V"

    compute in3 ((6.8/10)+1)*@ ,  @/((6.8/10)+1)
    compute in4 ((28/10)+1)*@  ,  @/((28/10)+1)
    compute in5 -(210/60.4)*@  ,  -@/(210/60.4)
    compute in6 -(90.9/60.4)*@ ,  -@/(90.9/60.4)

    set in0_min vid*0.95
    set in0_max vid*1.05
    set in1_min vid*0.95
    set in1_max vid*1.05
    set in2_min 3.3 * 0.95
    set in2_max 3.3 * 1.05
    set in3_min 5.0 * 0.95
    set in3_max 5.0 * 1.05
    set in4_min 12 * 0.95
    set in4_max 12 * 1.05
    set in5_max -12 * 0.95
    set in5_min -12 * 1.05
    set in6_max -5 * 0.95
    set in6_min -5 * 1.05

Refer to the manual page of sensors.conf(5) for more information.

Related Post