Monitoring Temperature And Fan Speed In Linux By LM-Sensors
What’s LM-Sensors
Health monitoring is very important for critical servers because administrators can do proper actions before any impact on service. There is many third-party software for monitoring Linux and Windows servers but native agents are also useful.
We are going to review one of native solutions for hardware health monitoring in Linux.
LM-Sensors (Linux-Monitoring Sensors) is a free and open-source software for hardware health monitoring in Linux machines. Most Linux distributions have lm_sensors package and it will be installed on Linux machines by default.
But also administrators can download and install the software via distribution’s repositories manually.
We will skip installation process in this post because the installation is different in Linux distributions.
Configuring LM-Sensors
By default, lm_sensors can monitor CPU temperature and if administrator needs to monitor other devices, the below command should be run:
sensors-detect
Output would be like this:
$sensors-detect Stopping lm_sensors: [ OK ] # sensors-detect revision 1.1 # System: HP ProLiant DL580 G5 This program will help you determine which kernel modules you need to load to use lm_sensors most effectively. It is generally safe and recommended to accept the default answers to all questions, unless you know what you're doing. Some south bridges, CPUs or memory controllers contain embedded sensors. Do you want to scan for them? This is totally safe. (YES/no): Silicon Integrated Systems SIS5595... No VIA VT82C686 Integrated Sensors... No VIA VT8231 Integrated Sensors... No AMD K8 thermal sensors... No AMD Family 11h thermal sensors... No Intel digital thermal sensor... Success! (driver `coretemp') Intel AMB FB-DIMM thermal sensor... No VIA C7 thermal and voltage sensors... No Some Super I/O chips contain embedded sensors. We have to write to standard I/O ports to probe them. This is usually safe. Do you want to scan for Super I/O sensors? (YES/no): Probing for Super-I/O at 0x2e/0x2f Trying family `National Semiconductor'... No Trying family `SMSC'... Yes Found `SMSC SCH4307 Super IO Fan Sensors' Success! (address 0x820, driver `to-be-written') Probing for Super-I/O at 0x4e/0x4f Trying family `National Semiconductor'... No Trying family `SMSC'... No Trying family `VIA/Winbond/Nuvoton/Fintek'... No Trying family `ITE'... No Some systems (mainly servers) implement IPMI, a set of common interfaces through which system health data may be retrieved, amongst other things. We first try to get the information from SMBIOS. If we don't find it there, we have to read from arbitrary I/O ports to probe for such interfaces. This is normally safe. Do you want to scan for IPMI interfaces? (YES/no): Found `IPMI BMC KCS' at 0xca2... Success! (confidence 8, driver `ipmisensors') Some hardware monitoring chips are accessible through the ISA I/O ports. We have to write to arbitrary I/O ports to probe them. This is usually safe though. Yes, you do have ISA I/O ports even if you do not have any ISA slots! Do you want to scan the ISA I/O ports? (yes/NO): Lastly, we can probe the I2C/SMBus adapters for connected hardware monitoring devices. This is the most risky part, and while it works reasonably well on most systems, it has been reported to cause trouble on some systems. Do you want to probe the I2C/SMBus adapters now? (YES/no): Sorry, no supported PCI bus adapters found. Module i2c-dev loaded successfully. Next adapter: Radeon i2c bit bus DVI_DDC (i2c-0) Do you want to scan it? (YES/no/selectively): Next adapter: Radeon i2c bit bus VGA_DDC (i2c-1) Do you want to scan it? (YES/no/selectively): Next adapter: Radeon i2c bit bus MONID (i2c-2) Do you want to scan it? (YES/no/selectively): Next adapter: Radeon i2c bit bus CRT2_DDC (i2c-3) Do you want to scan it? (YES/no/selectively): Now follows a summary of the probes I have just done. Just press ENTER to continue: Driver `to-be-written': * ISA bus, address 0x820 Chip `SMSC SCH4307 Super IO Fan Sensors' (confidence: 9) Driver `coretemp': * Chip `Intel digital thermal sensor' (confidence: 9) Driver `ipmisensors': * ISA bus, address 0xca2 Chip `IPMI BMC KCS' (confidence: 8) Note: there is no driver for SMSC SCH4307 Super IO Fan Sensors yet. Check http://www.lm-sensors.org/wiki/Devices for updates. Warning: the required module ipmisensors is not currently installed on your system. If it is built into the kernel then it's OK. Otherwise, check http://www.lm-sensors.org/wiki/Devices for driver availability. Do you want to overwrite /etc/sysconfig/lm_sensors? (YES/no): Starting lm_sensors: loading module ipmi-si coretemp [ OK ] Unloading i2c-dev... OK
After all, run the below command to monitor sever health real-time:
watch -n 1 "sensors"