Net-SNMP and lm-sensors on Ubuntu 10.04

From Net-SNMP Wiki
Revision as of 05:26, 5 March 2011 by Ckmac97 (Talk | contribs) (Install and Configure Net-SNMP Source)

Jump to: navigation, search
Notes

This is a Wiki tutorial for using Net-SNMP and lm-sensors on Ubuntu 10.04.1 LTS.

Source Download

You can download the latest sources of Net-SNMP from here:

  Net-SNMP Download Page

You can download the latest sources of lm-sensors from here:

  lm-sensors Download Page

Configure lm-sensors

Ubuntu 10.04.1 includes lm-sensors 3.1.2 pre-installed. To verify your version of lm-sensors, run:

> sensors -v
sensors version 3.1.2 with libsensors version 3.1.2

Lm-sensors needs to be configured using sensors-detect before it can be used. Sensors-detect is an interactive script for detecting hardware sensor chips. Run the following command, and then follow the on-screen instructions:

> sudo sensors-detect

Reboot your system, or use the following command to load the necessary kernel modules:

> sudo /etc/init.d/module-init-tools start

To verify that lm-sensors is operating properly, use the sensors command. Example output is shown below.

> sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +36.0°C  (high = +82.0°C, crit = +100.0°C)  

coretemp-isa-0001
Adapter: ISA adapter
Core 3:      +36.0°C  (high = +82.0°C, crit = +100.0°C)  

coretemp-isa-0002
Adapter: ISA adapter
Core 1:      +36.0°C  (high = +82.0°C, crit = +100.0°C)  

coretemp-isa-0003
Adapter: ISA adapter
Core 2:      +32.0°C  (high = +82.0°C, crit = +100.0°C)  

it8718-isa-0290
Adapter: ISA adapter
in0:         +1.34 V  (min =  +0.00 V, max =  +4.08 V)   
in1:         +1.98 V  (min =  +0.00 V, max =  +4.08 V)   
in2:         +3.30 V  (min =  +0.00 V, max =  +4.08 V)   
in3:         +2.93 V  (min =  +0.00 V, max =  +4.08 V)   
in4:         +0.80 V  (min =  +0.00 V, max =  +4.08 V)   
in5:         +0.21 V  (min =  +0.14 V, max =  +0.26 V)   
in6:         +0.10 V  (min =  +0.00 V, max =  +4.08 V)   
in7:         +3.06 V  (min =  +0.00 V, max =  +4.08 V)   
Vbat:        +3.23 V
fan1:          0 RPM  (min =    0 RPM)
fan2:          0 RPM  (min =    0 RPM)
fan3:          0 RPM  (min =    0 RPM)
fan4:       1834 RPM  (min =    0 RPM)
temp1:       +37.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermistor
temp2:       +27.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermal diode
temp3:        -2.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermistor
cpu0_vid:   +1.219 V

Install and Configure Net-SNMP Packages

Ubuntu 10.04 does not have Net-SNMP pre-installed. To install basic Net-SNMP functionality, run the following:

> sudo apt-get install snmp
> sudo apt-get install snmpd

Several other SNMP packages are available for Ubuntu. The Ubuntu Software Center (Applications > Ubuntu Software Center) is a good resource for determining which packages are currently installed (search for "snmp").

To test that the SNMP Daemon was successfully installed, run the following:

> snmpwalk -v 2c -c public localhost system

General system information should be printed to the terminal window. An example is shown below.

SNMPv2-MIB::sysDescr.0 = STRING: Linux ubuntu 2.6.32-29-generic-pae #58-Ubuntu SMP Fri Feb 11 19:15:25 UTC 2011 i686
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1218) 0:00:12.18
SNMPv2-MIB::sysContact.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)
SNMPv2-MIB::sysName.0 = STRING: ubuntu
SNMPv2-MIB::sysLocation.0 = STRING: Unknown (configure /etc/snmp/snmpd.local.conf)
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.8 = No more variables left in this MIB View (It is past the end of the MIB tree)

The SNMP Daemon requires additional setup. The snmpconf command is an interactive script for configuring Net-SNMP functionality (it can be used to generate snmp.conf and snmpd.conf). Run the following:

> sudo snmpconf -i -g basic_setup

NOTE: If you are unfamiliar Net-SNMP, it might be easier to create a simple snmpd.conf file manually. Using a text editor, create a file named "snmpd.conf". Add the following text:

rocommunity  public

Copy the new snmpd.conf file to the correct path (In Ubuntu, the default paths for Net-SNMP applications are slightly different):

> sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.old
> sudo cp /usr/share/snmp/snmpd.conf /etc/snmp/snmpd.conf

Restart the SNMP daemon:

>sudo /etc/init.d/snmpd restart
 * Restarting network management services:              

Use snmpwalk to test the lm-sensors MIB. The OID for the lm-sensors MIB is 1.3.6.1.4.1.2021.13.16.

> snmpwalk -v 2c -c public localhost lmSensors
> snmpwalk -v 2c -c public localhost 1.3.6.1.4.1.2021.13.16

Example Output:

LM-SENSORS-MIB::lmMiscSensorsIndex.1 = INTEGER: 0
LM-SENSORS-MIB::lmMiscSensorsIndex.2 = INTEGER: 1
LM-SENSORS-MIB::lmMiscSensorsIndex.3 = INTEGER: 2
LM-SENSORS-MIB::lmMiscSensorsIndex.4 = INTEGER: 3
LM-SENSORS-MIB::lmMiscSensorsIndex.5 = INTEGER: 4
LM-SENSORS-MIB::lmMiscSensorsIndex.6 = INTEGER: 5
LM-SENSORS-MIB::lmMiscSensorsIndex.7 = INTEGER: 6
LM-SENSORS-MIB::lmMiscSensorsIndex.8 = INTEGER: 7
LM-SENSORS-MIB::lmMiscSensorsIndex.9 = INTEGER: 8
LM-SENSORS-MIB::lmMiscSensorsIndex.10 = INTEGER: 9
LM-SENSORS-MIB::lmMiscSensorsIndex.11 = INTEGER: 10
LM-SENSORS-MIB::lmMiscSensorsIndex.12 = INTEGER: 11
LM-SENSORS-MIB::lmMiscSensorsIndex.13 = INTEGER: 12
LM-SENSORS-MIB::lmMiscSensorsIndex.14 = INTEGER: 13
LM-SENSORS-MIB::lmMiscSensorsIndex.15 = INTEGER: 14
LM-SENSORS-MIB::lmMiscSensorsIndex.16 = INTEGER: 15
LM-SENSORS-MIB::lmMiscSensorsIndex.17 = INTEGER: 16
LM-SENSORS-MIB::lmMiscSensorsIndex.18 = INTEGER: 17
LM-SENSORS-MIB::lmMiscSensorsIndex.19 = INTEGER: 18
LM-SENSORS-MIB::lmMiscSensorsIndex.20 = INTEGER: 19
LM-SENSORS-MIB::lmMiscSensorsDevice.1 = STRING: Core 0
LM-SENSORS-MIB::lmMiscSensorsDevice.2 = STRING: Core 0
LM-SENSORS-MIB::lmMiscSensorsDevice.3 = STRING: Core 0
LM-SENSORS-MIB::lmMiscSensorsDevice.4 = STRING: Core 0
LM-SENSORS-MIB::lmMiscSensorsDevice.5 = STRING: Core 1
LM-SENSORS-MIB::lmMiscSensorsDevice.6 = STRING: Core 1
LM-SENSORS-MIB::lmMiscSensorsDevice.7 = STRING: Core 1
LM-SENSORS-MIB::lmMiscSensorsDevice.8 = STRING: Core 1
LM-SENSORS-MIB::lmMiscSensorsDevice.9 = STRING: Core 3
LM-SENSORS-MIB::lmMiscSensorsDevice.10 = STRING: Core 3
LM-SENSORS-MIB::lmMiscSensorsDevice.11 = STRING: Core 3
LM-SENSORS-MIB::lmMiscSensorsDevice.12 = STRING: Core 3
LM-SENSORS-MIB::lmMiscSensorsDevice.13 = STRING: Core 2
LM-SENSORS-MIB::lmMiscSensorsDevice.14 = STRING: Core 2
LM-SENSORS-MIB::lmMiscSensorsDevice.15 = STRING: Core 2
LM-SENSORS-MIB::lmMiscSensorsDevice.16 = STRING: Core 2
LM-SENSORS-MIB::lmMiscSensorsDevice.17 = STRING: in0
LM-SENSORS-MIB::lmMiscSensorsDevice.18 = STRING: in0
LM-SENSORS-MIB::lmMiscSensorsDevice.19 = STRING: in0
LM-SENSORS-MIB::lmMiscSensorsDevice.20 = STRING: in0
LM-SENSORS-MIB::lmMiscSensorsValue.1 = Gauge32: 37000
LM-SENSORS-MIB::lmMiscSensorsValue.2 = Gauge32: 82000
LM-SENSORS-MIB::lmMiscSensorsValue.3 = Gauge32: 100000
LM-SENSORS-MIB::lmMiscSensorsValue.4 = Gauge32: 0
LM-SENSORS-MIB::lmMiscSensorsValue.5 = Gauge32: 39000
LM-SENSORS-MIB::lmMiscSensorsValue.6 = Gauge32: 82000
LM-SENSORS-MIB::lmMiscSensorsValue.7 = Gauge32: 100000
LM-SENSORS-MIB::lmMiscSensorsValue.8 = Gauge32: 0
LM-SENSORS-MIB::lmMiscSensorsValue.9 = Gauge32: 36000
LM-SENSORS-MIB::lmMiscSensorsValue.10 = Gauge32: 82000
LM-SENSORS-MIB::lmMiscSensorsValue.11 = Gauge32: 100000
LM-SENSORS-MIB::lmMiscSensorsValue.12 = Gauge32: 0
LM-SENSORS-MIB::lmMiscSensorsValue.13 = Gauge32: 33000
LM-SENSORS-MIB::lmMiscSensorsValue.14 = Gauge32: 82000
LM-SENSORS-MIB::lmMiscSensorsValue.15 = Gauge32: 100000
LM-SENSORS-MIB::lmMiscSensorsValue.16 = Gauge32: 0
LM-SENSORS-MIB::lmMiscSensorsValue.17 = Gauge32: 1344
LM-SENSORS-MIB::lmMiscSensorsValue.18 = Gauge32: 0
LM-SENSORS-MIB::lmMiscSensorsValue.19 = Gauge32: 4080
LM-SENSORS-MIB::lmMiscSensorsValue.20 = Gauge32: 0

UPDATE: The Ubuntu 10.04 packages 'snmp' and 'snmpd' include Net-SNMP version 5.4.2.1. According to the lm-sensors installation page, Net-SNMP 5.5 or higher is required.

Install and Configure Net-SNMP Source

An excellent tutorial for installing Net-SNMP (from source) for Ubuntu is located here: Net-Snmp on Ubuntu

Specific details needed for lm-sensors are discussed below.

Download the latest Net-SNMP source package (v 5.6.1 was used for this tutorial), and unzip it.

Install the libperl-dev and libsensors4-dev packages for Ubuntu:

>sudo apt-get install libperl-dev
>sudo apt-get install libsensors4-dev

Use the following commands to configure and install Net-SNMP.

>cd net-snmp-5.6.1/
>./configure --with-mib-modules="ucd-snmp/lmsensorsMib" --with-ldflags="-lsensors"
>make
>sudo make install

Results from configure (accepted all defaults):

---------------------------------------------------------
            Net-SNMP configuration summary:
---------------------------------------------------------

  SNMP Versions Supported:    1 2c 3
  Building for:               linux
  Net-SNMP Version:           5.6.1
  Network transport support:  Callback Unix Alias TCP UDP IPv4Base SocketBase TCPBase UDPIPv4Base UDPBase
  SNMPv3 Security Modules:     usm
  Agent MIB code:             ucd-snmp/lmsensorsMib default_modules =>  hardware/sensors snmpv3mibs mibII ucd_snmp notification notification-log-mib target agent_mibs agentx disman/event disman/schedule utilities host
  MYSQL Trap Logging:         unavailable
  Embedded Perl support:      enabled
  SNMP Perl modules:          building -- embeddable
  SNMP Python modules:        disabled
  Crypto support from:        internal
  Authentication support:     MD5 SHA1
  Encryption support:         DES AES

---------------------------------------------------------