Wednesday, 26 May 2004
LMSensors is a package that lets you read out the sensors inside your
PC/Server.., sensors like Fanspeed, Motherboard temprature, CPU
Voltage, etc, etc..
This howto will take a quick peek on how to set it up and read it our through SNMP..First, look if the lm_sensors package and snmp have already been installed: rpm -qa | grep lm_sensors It should return something like lm_sensors-2.8.1-1 If nothing comes up, you'll have to install the lm_sensors rpm, it should be available through one of the fedora mirrors, and should be called something like: lm_sensors-2.8.1-1.i386.rpm and lm_sensors-devel-2.8.1-1.i386.rpm.. Same
story with snmp, you'll need the SNMP packages like:
net-snmp-devel-5.1-2.1, net-snmp-utils-5.1-2.1 and net-snmp-5.1-2.1..
(version can vary of course ;) We'll want snmpd (the snmp daemon) to start at bootup, we can use the setup utility for that, or just type chkconfig snmpd on Next time you'll reboot snmpd will automatically start too.. Now
to configure your sensors, in order for lm_sensors to know which type
and vendor sensors your motherboard and system casing is using, you'll
need to execute: /usr/sbin/sensors-detect You'll now be
provided with a whole range of detections and questions, you can
default the most with yes, if all goes well, it'll load some modules
needed to read out your sensor data, and save it to /etc/sysconfig/lm_sensors We'll also need to copy the initscript for lm_sensors to the bootup scripts directories, issue the command: cp /usr/share/doc/lm_sensors-2.8.1/lm_sensors.init /etc/rc.d/init.d/lm_sensors If it can't find the file, do find / -name lm_sensors.init, it should look for the file, and give you the directory when found.. Let's start lm_sensors: /etc/init.d/lm_sensors start Starting up sensors: starting module __i2c-viapro__ starting module __i2c-isa__ starting module __w83781d__ starting module __via686a__ /etc/init.d/lm_sensors: line 61: /usr/local/bin/sensors: No such file or directory [FAILED] Well that sucks.., the initscript points to the wrong directory for the sensors binary, open up /etc/init.d/lm_sensors and look for the directive that says: PSENSORS=/usr/local/bin/sensors, and change this to PSENSORS=/usr/bin/sensors, and try starting it again: /etc/init.d/lm_sensors start Starting up sensors: starting module __i2c-viapro__ starting module __i2c-isa__ starting module __w83781d__ starting module __via686a__ [ OK ] That's better, the lm_sensors package works.. Next step: configuring snmp.. The default config of snmpd is located in /etc/snmp/snmpd.conf, plain to say, this file is a mess of text and what not, I always start with a blank and easy file.. cd /etc/snmp/ mv snmpd.conf snmpd.conf.old
Now open your favorite editor and create something simple like: rocommunity putapasswordhere disk / 10000 disk /boot 10000 disk /var 10000 disk /tmp 10000 disk /home 10000
The
rocommunity means: read only community, and fill in a password you'll
be using to read the data (don't use a very important one like your
root pass, since it'll go in plain text over the internet) The disk entries allow your parititons to be included into SNMP too.. Save the file, and start snmp: /etc/init.d/snmpd restart Now let's see if you can read the sensor values, type: snmpwalk localhost -v 1 -c putapasswordhere host.hrSensor If you did everything right, you should get output like: HOST-RESOURCES-MIB::hrSensorValue.10 = STRING: 5.040000 HOST-RESOURCES-MIB::hrSensorValue.11 = STRING: 4.720800 HOST-RESOURCES-MIB::hrSensorValue.12 = STRING: 5.241600 HOST-RESOURCES-MIB::hrSensorValue.13 = STRING: 12.084000 HOST-RESOURCES-MIB::hrSensorValue.14 = STRING: 10.792000 HOST-RESOURCES-MIB::hrSensorValue.15 = STRING: 13.186000 HOST-RESOURCES-MIB::hrSensorValue.16 = STRING: -12.317881 HOST-RESOURCES-MIB::hrSensorValue.17 = STRING: -13.192053 HOST-RESOURCES-MIB::hrSensorValue.18 = STRING: -10.728477 HOST-RESOURCES-MIB::hrSensorValue.19 = STRING: -5.146987 HOST-RESOURCES-MIB::hrSensorValue.20 = STRING: -5.237285 HOST-RESOURCES-MIB::hrSensorValue.21 = STRING: -4.740646
That means it works.., that's it.., you have SNMP and lm_sensors running together.. 'Right'..,
you'll say, 'wtf am I supposed to do with that' ?, the advanced
sysadmin will most likely be able to work with all this and integrate
it in his/her favorite applications and scripts, A lot of others
however will most likely still need a good use for this.. ;-)
A good pointer to start is cacti.net, this is a graphing tool which allows you to create custom graphs using all sorts of (snmp) data
helpful resource I used: http://people.redhat.com/harald/snmp-lmsensors/HOWTO-SENSORS-SNMPD.html |