Net-SNMP and lm-sensors on Ubuntu 10.04
Contents
- 1 Notes
- 2 Source Download
- 3 Configure lm-sensors
- 4 Install and Configure Net-SNMP Packages
- 5 Install and Configure Net-SNMP Source
- 6 Additional SNMP Commands
Notes
This is a Wiki tutorial for using Net-SNMP and lm-sensors on Ubuntu 10.04.
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 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 ...
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. All sensors appear within the "MiscSensors" category.
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 ---------------------------------------------------------
Results from make:
... make[2]: Leaving directory `/home/admin/net-snmp-5.6.1/perl/TrapReceiver' make[1]: Leaving directory `/home/admin/net-snmp-5.6.1/perl'
Results from make install:
... Installing /usr/local/man/man3/SNMP.3 Appending installation info to /usr/local/lib/perl/5.10.1/perllocal.pod make[1]: Leaving directory `/home/admin/net-snmp-5.6.1/perl'
The following Ubuntu packages need to be removed to avoid conflicts:
>sudo apt-get remove snmp >sudo apt-get remove snmpd >sudo apt-get remove libsnmp15 >sudo apt-get remove libsnmp-base
Configure the new SNMP daemon:
> sudo snmpconf -i -g basic_setup
Start the SNMP daemon:
> sudo snmpd -f -Le NET-SNMP version 5.6.1
In a new terminal window, run an snmpwalk on the lm-sensors MIB. Example output is provided:
>snmpwalk -v 2c -c public localhost lmSensors LM-SENSORS-MIB::lmTempSensorsIndex.1 = INTEGER: 1 LM-SENSORS-MIB::lmTempSensorsIndex.2 = INTEGER: 2 LM-SENSORS-MIB::lmTempSensorsIndex.3 = INTEGER: 3 LM-SENSORS-MIB::lmTempSensorsIndex.4 = INTEGER: 4 LM-SENSORS-MIB::lmTempSensorsIndex.18 = INTEGER: 18 LM-SENSORS-MIB::lmTempSensorsIndex.19 = INTEGER: 19 LM-SENSORS-MIB::lmTempSensorsIndex.20 = INTEGER: 20 LM-SENSORS-MIB::lmTempSensorsDevice.1 = STRING: Core 0 LM-SENSORS-MIB::lmTempSensorsDevice.2 = STRING: Core 1 LM-SENSORS-MIB::lmTempSensorsDevice.3 = STRING: Core 3 LM-SENSORS-MIB::lmTempSensorsDevice.4 = STRING: Core 2 LM-SENSORS-MIB::lmTempSensorsDevice.18 = STRING: temp1 LM-SENSORS-MIB::lmTempSensorsDevice.19 = STRING: temp2 LM-SENSORS-MIB::lmTempSensorsDevice.20 = STRING: temp3 LM-SENSORS-MIB::lmTempSensorsValue.1 = Gauge32: 37000 LM-SENSORS-MIB::lmTempSensorsValue.2 = Gauge32: 38000 LM-SENSORS-MIB::lmTempSensorsValue.3 = Gauge32: 35000 LM-SENSORS-MIB::lmTempSensorsValue.4 = Gauge32: 32000 LM-SENSORS-MIB::lmTempSensorsValue.18 = Gauge32: 37000 LM-SENSORS-MIB::lmTempSensorsValue.19 = Gauge32: 26000 LM-SENSORS-MIB::lmTempSensorsValue.20 = Gauge32: 4294965296 LM-SENSORS-MIB::lmFanSensorsIndex.14 = INTEGER: 14 LM-SENSORS-MIB::lmFanSensorsIndex.15 = INTEGER: 15 LM-SENSORS-MIB::lmFanSensorsIndex.16 = INTEGER: 16 LM-SENSORS-MIB::lmFanSensorsIndex.17 = INTEGER: 17 LM-SENSORS-MIB::lmFanSensorsDevice.14 = STRING: fan1 LM-SENSORS-MIB::lmFanSensorsDevice.15 = STRING: fan2 LM-SENSORS-MIB::lmFanSensorsDevice.16 = STRING: fan3 LM-SENSORS-MIB::lmFanSensorsDevice.17 = STRING: fan4 LM-SENSORS-MIB::lmFanSensorsValue.14 = Gauge32: 0 LM-SENSORS-MIB::lmFanSensorsValue.15 = Gauge32: 0 LM-SENSORS-MIB::lmFanSensorsValue.16 = Gauge32: 0 LM-SENSORS-MIB::lmFanSensorsValue.17 = Gauge32: 1834 LM-SENSORS-MIB::lmVoltSensorsIndex.5 = INTEGER: 5 LM-SENSORS-MIB::lmVoltSensorsIndex.6 = INTEGER: 6 LM-SENSORS-MIB::lmVoltSensorsIndex.7 = INTEGER: 7 LM-SENSORS-MIB::lmVoltSensorsIndex.8 = INTEGER: 8 LM-SENSORS-MIB::lmVoltSensorsIndex.9 = INTEGER: 9 LM-SENSORS-MIB::lmVoltSensorsIndex.10 = INTEGER: 10 LM-SENSORS-MIB::lmVoltSensorsIndex.11 = INTEGER: 11 LM-SENSORS-MIB::lmVoltSensorsIndex.12 = INTEGER: 12 LM-SENSORS-MIB::lmVoltSensorsIndex.13 = INTEGER: 13 LM-SENSORS-MIB::lmVoltSensorsIndex.21 = INTEGER: 21 LM-SENSORS-MIB::lmVoltSensorsDevice.5 = STRING: in0 LM-SENSORS-MIB::lmVoltSensorsDevice.6 = STRING: in1 LM-SENSORS-MIB::lmVoltSensorsDevice.7 = STRING: in2 LM-SENSORS-MIB::lmVoltSensorsDevice.8 = STRING: in3 LM-SENSORS-MIB::lmVoltSensorsDevice.9 = STRING: in4 LM-SENSORS-MIB::lmVoltSensorsDevice.10 = STRING: in5 LM-SENSORS-MIB::lmVoltSensorsDevice.11 = STRING: in6 LM-SENSORS-MIB::lmVoltSensorsDevice.12 = STRING: in7 LM-SENSORS-MIB::lmVoltSensorsDevice.13 = STRING: Vbat LM-SENSORS-MIB::lmVoltSensorsDevice.21 = STRING: cpu0_vid LM-SENSORS-MIB::lmVoltSensorsValue.5 = Gauge32: 1327 LM-SENSORS-MIB::lmVoltSensorsValue.6 = Gauge32: 1983 LM-SENSORS-MIB::lmVoltSensorsValue.7 = Gauge32: 3296 LM-SENSORS-MIB::lmVoltSensorsValue.8 = Gauge32: 2911 LM-SENSORS-MIB::lmVoltSensorsValue.9 = Gauge32: 800 LM-SENSORS-MIB::lmVoltSensorsValue.10 = Gauge32: 208 LM-SENSORS-MIB::lmVoltSensorsValue.11 = Gauge32: 96 LM-SENSORS-MIB::lmVoltSensorsValue.12 = Gauge32: 3072 LM-SENSORS-MIB::lmVoltSensorsValue.13 = Gauge32: 3232 LM-SENSORS-MIB::lmVoltSensorsValue.21 = Gauge32: 1218
Additional SNMP Commands
Data within the lm-sensors MIB is presented in tables. The snmptable command can be used to show the data in a table format:
>snmptable -v 2c -c public localhost lmTempSensorsTable SNMP table: LM-SENSORS-MIB::lmTempSensorsTable lmTempSensorsIndex lmTempSensorsDevice lmTempSensorsValue 1 Core 0 37000 2 Core 1 36000 3 Core 3 36000 4 Core 2 37000 18 temp1 38000 19 temp2 27000 20 temp3 4294965296
>snmptable -v 2c -c public localhost lmFanSensorsTable SNMP table: LM-SENSORS-MIB::lmFanSensorsTable lmFanSensorsIndex lmFanSensorsDevice lmFanSensorsValue 14 fan1 0 15 fan2 0 16 fan3 0 17 fan4 1839
>snmptable -v 2c -c public localhost lmVoltSensorsTable SNMP table: LM-SENSORS-MIB::lmVoltSensorsTable lmVoltSensorsIndex lmVoltSensorsDevice lmVoltSensorsValue 5 in0 1343 6 in1 1983 7 in2 3296 8 in3 2927 9 in4 800 10 in5 208 11 in6 96 12 in7 3072 13 Vbat 3232 21 cpu0_vid 1218
>snmptable -v 2c -c public localhost lmMiscSensorsTable LM-SENSORS-MIB::lmMiscSensorsTable: No entries
The snmptranslate command can be used to draw the lm-sensors MIB tree structure:
>snmptranslate -Tp -IR lmSensors +--lmSensors(16) | +--lmSensorsMIB(1) | +--lmTempSensorsTable(2) | | | +--lmTempSensorsEntry(1) | | Index: lmTempSensorsIndex | | | +-- -R-- Integer32 lmTempSensorsIndex(1) | | Range: 0..65535 | +-- -R-- String lmTempSensorsDevice(2) | | Textual Convention: DisplayString | | Size: 0..255 | +-- -R-- Gauge lmTempSensorsValue(3) | +--lmFanSensorsTable(3) | | | +--lmFanSensorsEntry(1) | | Index: lmFanSensorsIndex | | | +-- -R-- Integer32 lmFanSensorsIndex(1) | | Range: 0..65535 | +-- -R-- String lmFanSensorsDevice(2) | | Textual Convention: DisplayString | | Size: 0..255 | +-- -R-- Gauge lmFanSensorsValue(3) | +--lmVoltSensorsTable(4) | | | +--lmVoltSensorsEntry(1) | | Index: lmVoltSensorsIndex | | | +-- -R-- Integer32 lmVoltSensorsIndex(1) | | Range: 0..65535 | +-- -R-- String lmVoltSensorsDevice(2) | | Textual Convention: DisplayString | | Size: 0..255 | +-- -R-- Gauge lmVoltSensorsValue(3) | +--lmMiscSensorsTable(5) | +--lmMiscSensorsEntry(1) | Index: lmMiscSensorsIndex | +-- -R-- Integer32 lmMiscSensorsIndex(1) | Range: 0..65535 +-- -R-- String lmMiscSensorsDevice(2) | Textual Convention: DisplayString | Size: 0..255 +-- -R-- Gauge lmMiscSensorsValue(3)