Health Monitoring with lm_sensors
March 11th, 2003 by Steve Hastings in
A few years ago, a friend of mine had problems with his computer. It became unreliable; he would get odd errors, or the system would hang. He re-installed the operating system and his key applications, but the problems persisted. This cost him time, and his time is valuable.
The problem turned out to be simple: the cooling fan on his CPU's heat sink was dead. The overheating CPU, in turn, caused random problems. He wound up replacing the CPU as well as the heat sink, because the CPU had been damaged.
He could have avoided all of this if he had been running some sort of computer health monitoring system, such as lm_sensors.
lm_sensors is a set of Linux kernel modules for monitoring the vital signs of a computer: the voltages from the power supply, the temperature of the system and the CPU and fan speeds. lm_sensors includes a command-line utility for checking the current readings. A variety of graphical tools also are available for putting a pretty face on lm_sensors.
Before you attempt to install the lm_sensors kernel module, you should have the I2C driver modules installed. I2C, which stands for Inter-IC bus, is a simple serial data system for connecting chips so they can talk to one another. Most motherboards with health monitoring features use an I2C bus to access those features.
Make sure the I2C drivers are installed on your system. (If you build your own kernel, the I2C options are located under Character Devices.)
Install the packages that provide lm_sensors, or build it from source code and install. Then enter sensors-detect, a script that figures out how to install lm_sensors on your system. It will try various I2C modules and then try various lm_sensors modules, until it finds a combination that works on your system. When it is done, it provides instructions for how to set up configuration files in /etc, which load the correct modules when your system boots.
Once the modules for lm_sensors are installed and working, you can run the sensors command from a shell and receive some useful output. But you probably aren't done yet.
Your next step is to edit the /etc/sensors.conf file. This file sets some custom parameters that make lm_sensors work with your computer system. For example, you can add a label that changes Temp1 to CPU Temp; you can disable Temp3 completely if you don't have a sensor and it is reporting nonsense; and you can customize the math functions used to calculate the displayed values.
Ideally, before you edit /etc/sensors.conf, you should reboot your computer and enter the BIOS setup screens. (For most computers, you hit the Del key or the F1 key during bootup to enter the BIOS. Check the owner's manual for your system, or watch the screen during bootup for a message like Hit <Del> to enter Setup.) The BIOS setup should have a sub-menu showing the same numbers you would like lm_sensors to report. Make a note of the readings you are seeing. For example, if the CPU temperature is about 60 degrees Celsius, write that down.
Now, booted back into Linux, run the sensors command. If the numbers are all there and look correct, you are done. If not, you need to customize /etc/sensors.conf.
Take a look at the top of the output of the sensors command; it shows you with which chip lm_sensors is communicating. Find that chip in /etc/sensors.conf and look at the settings you can customize. /etc/sensors.conf is liberally commented, making it easier to figure out what you need to do. You also can read the man page, man sensors.conf.
Once you have customized /etc/sensors.conf, you must run the command sensors -s to put your changes into effect. Then run the sensors command once again to inspect the values it reports.
Additionally, you should make sure sensors -s runs each time your system boots.
You have the option to install sensord, the lm_sensors monitoring dæmon. You can configure this to log either to standard log files or to a round-robin database (a constant-size database set up to hold, for example, a week's worth of readings; new readings overwrite the oldest). By editing /etc/syslog.conf, you can arrange to receive e-mail when sensor readings go out of bounds.
lm_sensors creates files under /proc with sensor values in them. You can create a custom monitoring system by writing scripts that check the values from these files or parse the results of the sensors command.
The source distribution for lm_sensors includes a simple Bourne shell dæmon, healthd.sh, that sends e-mail to the root account if any sensors indicate an alarm state.
A bunch of programs are available that check lm_sensors values or display them in some cool-looking fashion, including applets for KDE and GNOME and several window managers. The resources section has some links to get you started.
I've been running the elaborate GKrellM, a GTK applet designed to make an impressive panel of monitors. The screenshot to the right shows it running on my system, with not only lm_sensors data but also with S.M.A.R.T. hard disk temperature data and the BubbleFishyMon plugin. (BubbleFishyMon represents memory load as the water level, CPU activity as bubbles and network packets as fish swimming back and forth. The rubber duck is just for fun.)
It takes a bit of work to get lm_sensors working on your system, but it's well worth it. You might catch a hardware malfunction early, before it becomes serious. Even if you don't have any problems, it's reassuring to be able to check up on the health of your system quickly.
lm_sensors Related Projects at Freshmeat.net
GKrellM, the System Monitor from the Forbidden Planet
BubbleFishyMon, a Plugin for GKrellM
hddtemp, a Plugin that Monitors Hard Disk Temperature Using S.M.A.R.T.
xsensors, a Simple lm_sensors Display that Uses GTK widgets
Steve Hastings first used UNIX on actual paper teletypes. He enjoys bicycling, music, petting his cat and making his Linux computers do new things.
Special Magazine Offer -- 2 Free Trial Issues!
Receive 2 free trial issues of Linux Journal as well as instant online access to current and past issues. There's NO RISK and NO OBLIGATION to buy. CLICK HERE for offer
Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.
Sorry, offer available in the US only. International orders, click here.
Subscribe now!
Recently Popular
| Linux HOWTO: Video Editing Magic with ffmpeg | Jul-23-08 |
| Man vs. Myth: Greg Kroah-Hartman and the Kernel Driver Project | Jul-21-08 |
| Google Gadgets for Linux | Jul-21-08 |
| Building a Call Center with LTSP and Soft Phones | Aug-25-05 |
| Review: HP 2133 Mini-Note | Jul-16-08 |
| Boot with GRUB | May-01-01 |
Featured Videos
Non-linear video editing tools are great, but they're not always the best tool for the job. This is where a powerful tool like ffmpeg becomes useful. This tutorial by Elliot Isaacson covers the basics of transcoding video, as well as more advanced tricks like creating animations, screen captures, and slow motion effects.
Shawn Powers reviews the HP Mini-Note portable computer.
Thanks to our sponsor: Silicon Mechanics
Silicon Mechanics is a leading manufacturer of rackmount servers, storage, and high performance computing hardware. The best warranty offerings available are backed by experts dedicated to customer satisfaction.
From the Magazine
August 2008, #172
There's nuttin like a Cool Project to give you some relief from the summer heat, so get out your parka cuz we got a bunch of em. First up is the BUG, not a bug, The BUG. It's got a GPS, camera and more, in a hand-sized package that's user programmable. The BUG does everything. It's both a floor wax and a dessert topping. Get one now. Need a software version of a Swiss Army knife? Take a look at Billix, and don't leave home without it. Then, chew on this one, an X server on a Gumstix device driving an E-Ink display. Need more storage? How about 16 Terabytes? Can do.
And, of course, we have the usual cast of characters: Marcel, Reuven, Dave, Kyle, Doc, plus the new kid on the block Shawn Powers. But it doesn't stop there: build a MythTV box on a budget, build your own GIS system, set up the tools to monitor your enterprise and more. Finally, remember The War of the Worlds? Now you can play too.


Delicious
Digg
Reddit
Newsvine
Technorati







Lm_sensors; Adam Curtis
On March 18th, 2003 Anonymous says:
Sensors in most cases would have been useful when my computer malfunctioned. What I would like to know is are there sensors for video cards. GPU's like to overheat somtimes.
Re: Lm_sensors; Adam Curtis
On May 10th, 2003 Anonymous says:
the S3 savage4 has one. There's a module for Matrox g400, so I think it does it too.
Moaning Goat Meter
On March 14th, 2003 steveha (not verified) says:
I really, really wanted to mention the Moaning Goat Meter in this article. I didn't because it was too much of a stretch (since MGM doesn't yet support lm_sensors). But check it out:
http://www.xiph.org/mgm/
Do not miss the FAQ!
If you are a Perl hacker, maybe you can add lm_sensors support to MGM. MGM is crying out for it (or moaning for it, perhaps).
If you use KDE, you can monitor lm_sensors with KSysGuard
On March 14th, 2003 Anonymous says:
You may need to add sensors to the list of inputs in the /etd/ksysguard.conf file, but it it will allow the hardware sensor status to be displayed in the KDE 'panel'.
It's not as pretty as GKrellM, though. It also won't do logarithmic scaling (useful for things like network data traffic). I've still to investigate if GKrellM can do that either.
warning to Thinkpad owners
On March 11th, 2003 Anonymous says:
Be very careful with LMsensors if you have a IBM ThinkPad laptop. There is a risk of damaging it with these programs.
for more information see:
http://www.linux-thinkpad.org/bm/tp_mailing.html