Pages

Saturday, January 4, 2014

Combining SNMP and LM-SENSORS

Little known is that you can query lm-sensors with snmp. Unfortanatly the Slackware net-snmp package does not support that. This article will describe the current situation and how to change it.
First take a look at my lm-sensors output on the command line:

# sensors
atk0110-acpi-0
Adapter: ACPI interface
Vcore Voltage:    +1.42 V  (min =  +0.85 V, max =  +1.60 V)
 +3.3 Voltage:    +3.34 V  (min =  +2.97 V, max =  +3.63 V)
 +5 Voltage:      +4.95 V  (min =  +4.50 V, max =  +5.50 V)
 +12 Voltage:    +11.98 V  (min = +10.20 V, max = +13.80 V)
CPU FAN Speed:   2667 RPM  (min =  600 RPM, max = 7200 RPM)
CPU Temperature:  +71.0°C  (high = +60.0°C, crit = +75.0°C)
MB Temperature:   +49.0°C  (high = +60.0°C, crit = +95.0°C)

k8temp-pci-00c3
Adapter: PCI adapter
Core0 Temp:   +76.0°C 
Core1 Temp:   -49.0°C


The above output shows several voltage, temperatures and other values. When I try to query these values via snmp I get the following:

# snmpwalk -v2c -c public localhost lmSensors             
No log handling enabled - using stderr logging
lmSensors: Unknown Object Identifier (Sub-id not found: (top) -> lmSensors)


Meeeh. No lm-sensors support via snmp. To change that the Slackware net-snmp package has to be rebuild. First grab the sources from the DVD or any mirror for net-snmp. Not just the source the whole n/net-snmp directory. Then reconfigure the net-snmp.SlackBuild script like this and add the two extra lines after --without-rpm:

# vi net-snmp.SlackBuild
...
# Configure:
CFLAGS="$SLKCFLAGS" \
./configure \
...
  --without-rpm \
  --with-mib-modules="ucd-snmp/lmsensorsMib" \
  --with-ldflags="-lsensors" \
  --program-suffix= \
  --program-prefix= \
  --build=$ARCH-slackware-linux
...


Then run the build script to create a new net-snmp package with lm-sensors support:

# ./net-snmp.SlackBuild
...


After the rebuild of the package is completed reinstall the package. First create a copy of the current snmp configuration file, eg.:

# cp /etc/snmp/snmpd.conf /root/

In case that snmp is running stop it:

# /etc/rc.d/rc.snmpd stop
Shutting down snmpd: . DONE


Now remove the old net-snmp package:

# removepkg net-snmp
...


And replace it with your build:

# installpkg /tmp/net-snmp-5.6.1-x86_64-5.txz
...


Copy your backup snmp configuration:

# cp /root/snmpd.conf /etc/snmp/

And start the snmp daemon again:

# /etc/rc.d/rc.snmpd start
Starting snmpd:  /usr/sbin/snmpd -A -p /var/run/snmpd -a -c /etc/snmp/snmpd.conf


For the final test rerun the snmpwalk command:

# snmpwalk -v2c -c public localhost lmSensors
LM-SENSORS-MIB::lmTempSensorsIndex.6 = INTEGER: 6
LM-SENSORS-MIB::lmTempSensorsIndex.7 = INTEGER: 7
LM-SENSORS-MIB::lmTempSensorsIndex.8 = INTEGER: 8
LM-SENSORS-MIB::lmTempSensorsIndex.9 = INTEGER: 9
LM-SENSORS-MIB::lmTempSensorsDevice.6 = STRING: CPU Temperature
LM-SENSORS-MIB::lmTempSensorsDevice.7 = STRING: MB Temperature
LM-SENSORS-MIB::lmTempSensorsDevice.8 = STRING: Core0 Temp
LM-SENSORS-MIB::lmTempSensorsDevice.9 = STRING: Core1 Temp
LM-SENSORS-MIB::lmTempSensorsValue.6 = Gauge32: 71000
LM-SENSORS-MIB::lmTempSensorsValue.7 = Gauge32: 49000
LM-SENSORS-MIB::lmTempSensorsValue.8 = Gauge32: 76000
LM-SENSORS-MIB::lmTempSensorsValue.9 = Gauge32: 4294918296
LM-SENSORS-MIB::lmFanSensorsIndex.5 = INTEGER: 5
LM-SENSORS-MIB::lmFanSensorsDevice.5 = STRING: CPU FAN Speed
LM-SENSORS-MIB::lmFanSensorsValue.5 = Gauge32: 3026
LM-SENSORS-MIB::lmVoltSensorsIndex.1 = INTEGER: 1
LM-SENSORS-MIB::lmVoltSensorsIndex.2 = INTEGER: 2
LM-SENSORS-MIB::lmVoltSensorsIndex.3 = INTEGER: 3
LM-SENSORS-MIB::lmVoltSensorsIndex.4 = INTEGER: 4
LM-SENSORS-MIB::lmVoltSensorsDevice.1 = STRING: Vcore Voltage
LM-SENSORS-MIB::lmVoltSensorsDevice.2 = STRING:  +3.3 Voltage
LM-SENSORS-MIB::lmVoltSensorsDevice.3 = STRING:  +5 Voltage
LM-SENSORS-MIB::lmVoltSensorsDevice.4 = STRING:  +12 Voltage
LM-SENSORS-MIB::lmVoltSensorsValue.1 = Gauge32: 1424
LM-SENSORS-MIB::lmVoltSensorsValue.2 = Gauge32: 3344
LM-SENSORS-MIB::lmVoltSensorsValue.3 = Gauge32: 4974
LM-SENSORS-MIB::lmVoltSensorsValue.4 = Gauge32: 11921


Voila, lm-sensors queries via snmp.

No comments:

Post a Comment