Posted by fsateler on Thu 5 Jan 2006 at 10:36
Sometimes it is useful to know the temperature of your hardware, to prevent it from frying. This information can easily be found, if your hardware provides the sensors needed, and we have the necessary software.
Most computers come with temperature sensors, which can be used to prevent your hardware from excessive heat. The most important thing to watch is, of course, your CPU temperature. This is where lm-sensors comes in. So, lets install it:
# apt-get install lm-sensors
Please notice that lm-sensors needs a recent version of i2c, so your kernel must have it installed (either via a 2.6 kernel (debian's default kernel works), or a patch to your 2.4 kernel). Once we have it installed, we need to configure it. A tool, sensors-detect can be used, but first we must ensure the necessary files are created under /dev. If you have a static /dev, you must manually create them:
# cd /dev && ./MAKEDEV i2c
If you have a dynamic /dev, then you need to load the i2c-dev module (I have only dynamic /dev systems, so I don't know if this module needs to be loaded also on those systems).
# modprobe i2c-dev
After this, you can proceed with the configuration.
# sensors-detect
Follow the instructions, throughout the wizard. Finally, we need to load the modules sensors-detect told us that should be loaded. In my case, it was i2c-viapro, i2c-isa, eeprom and w83627hf.
# modprobe -a i2c-viapro i2c-isa eeprom w83627hf
After this, we should be able to read sensor information. Just run the sample sensors program shipped with lm-sensors, and watch all your sensors! Now, there may be problems with the output: Information given by the hardware must be translated, and sometimes the configuration file doesn't handle your chip nicely. Check with your CMOS hardware monitor (probably by rebooting) that the readings are correct, and if not, modify /etc/sensors.conf (this file is extensively self-documented).
After you are done with /etc/sensors.conf, you can proceed to install a sensor monitor compatible with lm-sensors (eg: ksensors, xsensors, wmtemp). Alternatively, you might want to install the sensord daemon, which logs to syslog.
Now that we have our CPU covered, we can get worried about the next important thing: hard drives. This is simpler to set up. Just install the hddtemp package.
# apt-get install hddtemp
With the package installed, we can now check our drives temperature. Note that hddtemp must be run as root.
# hddtemp /dev/hd? /dev/hda: Maxtor 6E040L0: 40 C /dev/hdb: ST340824A: 47 C /dev/hdc: CREATIVE CD-RW RW8439E: S.M.A.R.T. not available /dev/hdd: LTN526: S.M.A.R.T. not available
As you can see, both my hard drives support temperature sensors, but my two CD drives don't. Note that hddtemp is not limited to IDE drives, it's just that I only have these.
Also, hddtemp has the ability to run as a daemon, but the
Debian installation comes disabled by default. To enable it, we must edit
/etc/default/hddtemp, and set it to RUN_DAEMON="true"
(if you want, you can set also which hard drives to check, to speed things up
a bit). Then you can run the provided init script, and hddtemp will be running.
Running hddtemp as a daemon, has the advantage of letting regular
users check the hard drives temperature, if we have netcat (or equivalent
software) installed:
$ nc localhost 7634 ; echo |/dev/hda|Maxtor 6E040L0|39|C||/dev/hdb|ST340824A|47|C|
Now you can install a frontend (such as sensors-applet), and watch your hardware's temperature in real time, and maybe be alerted of too high temperatures.
This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):
This article is copyright 2006 fsateler - please ask for permission to republish or translate.