How hot am I?

2006-01-08 4-minute read

Knowing the temperature of your CPU is not something you need every day, but when you do need, well, it’s good to have the tools in place.

There are at least two ways to find out the temperature:

  • acpi - Advanced Configuration and Power Interface is a standard that defines common interfaces for hardware recognition, motherboard and device configuration and power management (see http://en.wikipedia.org/wiki/Acpi).

On a debian system:

apt-get install acpi

Then, have fun cat’ing files in /proc/acpi.

In particular, look for the “temperature” file in your /proc/acpi/thermal_zone/*/ directories. On my laptop I have THRC and THRS directories in my thermal_zone directory. THRC is the zone for my chip and THRS is the zone for the “system.” Not sure where the sensor for the “system” is placed. The point is - there are two thermometers (and your system might have less or more).

For reference purposes, I get the following when I cat my chip’s temperature zone:

jamie@liberace:~$ cat /proc/acpi/thermal_zone/THRC/temperature
temperature:             51 C

I like ACPI because it’s simple and provides information via an easy to navigate file system hierarchy. Unfortunately, ACPI doesn’t work for all systems.

Consider poor chavez:

mayfirst@chavez:~$ cat /proc/acpi/thermal_zone/THRM/temperature
temperature:             0 C

I’m not sure where the THRM zone is, perhaps the M stands for the Moon (although I think it’s colder on the moon).

In any event, for chavez, we had to use lm-sensors

  • lm-sensors - Lm-sensors is a hardware health monitoring package for Linux. It allows you to access information from temperature, voltage, and fan speed sensors. It works with most newer systems. (From apt-cache show lm-sensors).

    Setting up lm-sensors involves:

    apt-get install lm-sensors
    

    Then, run the terrifying sensors-detect script as root to determine which kernel modules you need to insert in order for lm-sensors to work. The script spends so much time telling you that the commands you are about to execute are (probably) safe and won’t cause your system to crash that it makes you wish you were doing something safer, like brain surgery.

    After running sensors-detect (if your system hasn’t crashed), you will be asked if you want the script to modify your /etc/modules file to include the new kernel modules on reboot. This is generally a good idea.

    Then, run the sensors command (you don’t need to be root).

    If all goes well, it should say something like this:

    mayfirst@chavez:~$ sensors
    w83627hf-isa-0290
    Adapter: ISA adapter
    VCore 1:   +1.36 V  (min =  +1.10 V, max =  +1.86 V)
    VCore 2:   +3.28 V  (min =  +2.96 V, max =  +3.62 V)
    +3.3V:     +3.36 V  (min =  +2.96 V, max =  +3.62 V)
    +5V:       +5.19 V  (min =  +4.49 V, max =  +5.48 V)
    +12V:     +12.04 V  (min = +10.76 V, max = +13.19 V)
    -12V:     -11.62 V  (min = -12.77 V, max = -10.47 V)
    -5V:       -3.09 V  (min =  -3.49 V, max =  -2.54 V)
    V5SB:      +5.64 V  (min =  +4.87 V, max =  +5.94 V)
    VBat:      +3.15 V  (min =  +2.82 V, max =  +3.46 V)
    fan1:     6750 RPM  (min =  712 RPM, div = 8)                     (beep)
    fan2:        0 RPM  (min =  712 RPM, div = 8)              ALARM
    fan3:        0 RPM  (min =  712 RPM, div = 8)              ALARM
    temp1:       +30°C  (high =   +50°C, hyst =   +45°C)   sensor = thermistor
    temp2:     -48.0°C  (high =   +75°C, hyst =   +70°C)   sensor = thermistor
    temp3:     +42.0°C  (high =   +75°C, hyst =   +70°C)   sensor = diode           (beep)
    vid:      +1.388 V  (VRM Version 10.0)
    alarms:
    beep_enable:
    Sound alarm enabled
    

    And presto, you are up and running.

    All too often, however, you will get:

    jamie@liberace:~$ sensors
    No sensors found!
    Make sure you loaded all the kernel drivers you need.
    Try sensors-detect to find out which these are.
    

    instead.

    If this happens, you should try upgrading to the most recent kernel. That’s not particularly helpful advice, but it’s the best I can do. And it might not work. Sorry.