http://www.debian-administration.org/articles/327
by fsateler on Thu 5 Jan 2006
*Tags*: hardware, monitoring, temperature
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.
!! |
% sensors-detect
# sensors-detect revision 4171 (2006-09-24 03:37:01 -0700)
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.
We can start with probing for (PCI) I2C or SMBus adapters.
Do you want to probe now? (YES/no):
Probing for PCI bus adapters...
Use driver `i2c-viapro' for device 0000:00:11.0: VIA Technologies VT8237 South Bridge
We will now try to load each adapter module in turn.
Module `i2c-viapro' already loaded.
We are now going to do the I2C/SMBus adapter probings. Some chips may
be double detected; we choose the one with the highest confidence
value in that case.
Next adapter: SMBus Via Pro adapter at 0400
Do you want to scan it? (YES/no/selectively):
Client found at address 0x4a
Probing for `Analog Devices ADM1034'... No
Probing for `SPD EEPROM'... Success!
(confidence 8, driver `eeprom')
Probing for `SPD EEPROM'... Success!
(confidence 8, driver `eeprom')
Some chips are also 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):
Probing for `VIA VT8231 Integrated Sensors'... No
Probing for `AMD K8 thermal sensors'... Success!
(confidence 9, driver `k8temp')
Some Super I/O chips may also contain 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 `VIA/Winbond/Fintek'... Yes
Found `Winbond W83697HF Super IO Sensors' Success!
(address 0x290, driver `w83627hf')
Now follows a summary of the probes I have just done.
Just press ENTER to continue:
Driver `eeprom' (should be inserted):
Detects correctly:
* Bus `SMBus Via Pro adapter at 0400'
Busdriver `i2c-viapro', I2C address 0x50
Chip `SPD EEPROM' (confidence: 8)
* Bus `SMBus Via Pro adapter at 0400'
Busdriver `i2c-viapro', I2C address 0x51
Chip `SPD EEPROM' (confidence: 8)
EEPROMs are *NOT* sensors! They are data storage chips commonly
found on memory modules (SPD), in monitors (EDID), or in some
laptops, for example.
Driver `k8temp' (should be inserted):
Detects correctly:
* ISA bus, undetermined address (Busdriver `i2c-isa')
Chip `AMD K8 thermal sensors' (confidence: 9)
Driver `w83627hf' (should be inserted):
Detects correctly:
* ISA bus address 0x0290 (Busdriver `i2c-isa')
Chip `Winbond W83697HF Super IO Sensors' (confidence: 9)
I will now generate the commands needed to load the required modules.
Just press ENTER to continue:
To make the sensors modules behave correctly, add these lines to
/etc/modules:
#----cut here----
# I2C adapter drivers
i2c-viapro
# Chip drivers
eeprom
k8temp
w83627hf
#----cut here----
Do you want to add these lines to /etc/modules automatically? (yes/NO)yes
% modprobe i2c-viapro eeprom w83627hf
% sensors
k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:
+51 Cdocumented on: 2007.08.01