LMSensors

Install lm_sensors if you want to monitor your system's health in real time. Note that your system may already have lm_sensors installed because of some screwed up dependencies in one of the other RPMs that you needed to install. If this is the case, you can probably install right over it, providing you don't ever update lm_sensors with newer packages from the mother ship.

Also, you may need to delete the old sensor libraries from /usr/lib or monkey with the library options on your compiles to get newer code to use the newer libraries. However, this may not be a great idea because older modules that referenced the older lm_sensors may stop working. Since the install puts its library files in /usr/local/lib, you can aim new stuff there and it should work OK while not breaking older modules that rely on the libraries in /usr/lib.

Begin by downloading the appropriate source archive for your kernel version. For 2.4.10+ kernels, you need:

     lm_sensors-2.x.y.tar.gz
     i2c-2.m.n.tar.gz

For 2.6.x kernels, you need:

     lm_sensors-3.x.y.tar.bz2

To build and install the user space tools for 2.6 kernels, do:

     bunzip2 lm_sensors-3.x.y.tar.bz2
     tar -xvf lm_sensors-3.x.y.tar
     make user
     su
     make user install

/etc/ld.so.conf.d/usr-local.conf:

Pay attention to the stuff that the install tells you about /usr/local/lib and running /sbin/ldconfig. If /usr/local/lib is missing from /etc/ld.so.conf, the easiest way to add it is to create the file usr-local.conf in /etc/ld.so.conf.d. It should contain one line:

     /usr/local/lib

Once you've created this file, run:

     su
     /sbin/ldconfig

Run sensors-detect to find out what's up with your mobo. Note that the idiots who built the shell script assume that /usr/sbin will be in your PATH environment variable (although nothing could be further from the truth) and the script will crap out, if it isn't. So, you need to set it first, if it isn't there.

     su
     PATH=$PATH:/usr/sbin
     sensors-detect

Note that, if you have an Asus P4B mobo, the clever people at Asus have decided that the PCI device in the IHC chip, that does mobo health monitoring, should be hidden so that mere mortals like us can't monkey with it. See below for instructions on how to fix this problem.

If you have a 2.6.x kernel, in order for lm_sensors to see the device, you must run the unhide_ICH_SMBus script. But first, the writer of the script unwisely assumed that /sbin will be in your PATH environment variable (although nothing could be further from the truth) and the unhide script will crap out, if it isn't. So, you need to set it first, if it isn't there.

     su
     PATH=$PATH:/sbin
     prog/hotplug/unhide_ICH_SMBus

If this works, you can go back and run sensors_detect again and it should work. Note that, under no circumstances should you use suspend/resume after you run this script because unpleasantries will surely ensue.

/etc/modprobe.conf or /etc/modules.conf (on older systems):

The sensors-detect script will output several lines of stuff to add to modeprobe.conf (or modules.conf). You may or may not add the lines it tells you to. Typically, they look like:

     # I2C module options.
     alias char-major-89 i2c-dev

You only need to add them if the lm_sensors startup script doesn't load the i2c-dev module at startup.

/etc/sysconfig/lm_sensors:

The sensors-detect normally writes this config file. It is used by the startup script in /etc/rc.d/init.d/lm_sensors to load the appropriate modules for your system. If you choose to allow sensors-detect to create this file you need do nothing else. However, if you don't allow it to create this file or it can't create this file, you should add the lines that it tells you to some rc* file. Typically, they'd look something like this:

     # I2C adapter drivers
     modprobe i2c-i801
     # I2C chip drivers
     modprobe w83781d

If you are running on an Asus P4B under a 2.6.x kernel and you'd like to take advantage of the changes to the lm_sensors startup script (see below), you can add the following line to /etc/sysconfig/lm_sensors:

     # Asus P4B motherboard kludge.
     P4BKLUDGE=yes
     PCIBUS="/sys/bus/pci/slots"
     DEVICE="00:1f"

/etc/rc.d/init.d/lm_sensors:

If you are running an Asus P4B mobo and a 2.6.x kernel, you can modify the lm_sensors startup script to make the PCI device visible to lm_sensors at startup time. Here's the complete script:

     #!/bin/sh
     #
     # chkconfig: 2345 26 74
     # description: sensors is used for monitoring motherboard sensor values.
     # config: /etc/sysconfig/lm_sensors
     #
     #    This program is free software; you can redistribute it and/or modify
     #    it under the terms of the GNU General Public License as published by
     #    the Free Software Foundation; either version 2 of the License, or
     #    (at your option) any later version.
     #
     #    This program is distributed in the hope that it will be useful,
     #    but WITHOUT ANY WARRANTY; without even the implied warranty of
     #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     #    GNU General Public License for more details.
     #
     #    You should have received a copy of the GNU General Public License
     #    along with this program; if not, write to the Free Software
     #    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     # See also the lm_sensors homepage at:
     #     http://www2.lm-sensors.nu/~lm78/index.html
     # It uses a config file /etc/sysconfig/lm_sensors that contains the modules
     # to be loaded/unloaded. That file is sourced into this one.
     # The format of that file a shell script that simply defines the modules 
     # in order as normal shell variables with the special names:
     #    MODULE_1, MODULE_2, MODULE_3, etc.
     # If sensors isn't supported by the kernel, try loading the module...
     [ -e /sys/bus/i2c ] || /sbin/modprobe i2c-dev &>/dev/null
     [ -e /sys/bus/i2c ] || sleep 1
     # Don't bother if /sys/bus/i2c still doesn't exist, kernel doesn't have
     # support for sensors.
     [ -e /sys/bus/i2c ] || exit 0
     CONFIG=/etc/sysconfig/lm_sensors
     [ -r "$CONFIG" ] || exit 0
     egrep '^MODULE_' $CONFIG &>/dev/null || exit 0
     # Load config file
     . "$CONFIG"
     PSENSORS=/usr/bin/sensors
     # Source function library.
     . /etc/init.d/functions
     RETVAL=0
     prog="lm_sensors"
     start() {
         echo -n $"Starting $prog: "
         /sbin/MAKEDEV i2c
         if [ "x$P4BKLUDGE" == "xyes" ] ; then
             p4bkludge
         fi
             modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
             i=0
             while [ $i -lt $modules ] ; do
                 module=`eval echo '$'MODULE_$i`
     #           echo starting module __${module}__
                 /sbin/modprobe $module &>/dev/null
                 i=`expr $i + 1`
             done
             $PSENSORS -s
      RETVAL=$?
      if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lm_sensors ; then
          echo_success
          echo
      else
          echo_failure
          echo
      fi

}

     stop() {
         echo -n $"Stopping $prog: "
      modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
      i=`expr $modules`
      while [ $i -ge 0 ] ; do
          module=`eval echo '$'MODULE_$i`
          /sbin/modprobe -r $module &>/dev/null
          i=`expr $i - 1`
      done
      RETVAL=$?
      if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/lm_sensors ; then
          echo_success
          echo
      else
          echo_failure
          echo
      fi

}

     dostatus() {
         $PSENSORS
         RETVAL=$?
     }
     restart() {
         stop
         start
         RETVAL=$?
     }
     condrestart() {
         [ -e /var/lock/subsys/lm_sensors ] && restart || :
     }
     p4bkludge() {
      # Let's begin by checking to see if the PCI device is already there.
      # If so, there's no need to make it visible.
      smbus=`/sbin/lspci -n -s $DEVICE.3 | grep -i '0c05: *8086'`
      if [ -n "$smbus" ] ; then
          return
      fi
      # We use fakephp to hotplug the hidden device.
      /sbin/modprobe fakephp &> /dev/null
      # Make the hidden device visible.
      newval=$( printf '%x' $((0x$(/sbin/setpci -s $DEVICE.0 f2.w) & 0xfff7))) 
      /sbin/setpci -s $DEVICE.0 f2.w=$newval
      # Make sure the device is there.
      echo 1 > $PCIBUS/0000:$DEVICE.0/power 2>/dev/null
      if [ ! -d "$PCIBUS/0000:$DEVICE.3" ] ; then
          echo "Failed to hotplug the P4B PCI device"
          return
      fi
      # Looks good to me.
      return

}

     # See how we were called.
     case "$1" in
         start)
             start
             ;;
         stop)
             stop
             ;;
         status)
             dostatus
             ;;
         restart|reload)
             restart
             ;;
         condrestart)
             condrestart
             ;;
         *)
         echo $"Usage: $0 {start|stop|status|restart|condrestart}"
         exit 1
     esac
     exit $RETVAL

You should install the script with:

     su
     chkconfig --add lm_sensors
     chkconfig lm_sensors on

Note that, under no circumstances should you use suspend/resume if you use this kludge to start lm_sensors because unpleasantries will surely ensue.

/usr/bin/sensors:

If you installed lm_sensors on top of a prexisting lm_sensors (probably from an ill-begotten RPM), you may want to symlink /usr/bin/sensors to the newer /usr/local/bin/sensors:

     su
     mv /usr/bin/sensors /usr/bin/sensors.orig
     ln -s /usr/local/bin/sensors /usr/bin/sensors