This knowledge base has moved to the documentation site. Please visit the knowledge base here for the most up to date content. This site is no longer maintained.

Extending Net-SNMP

Follow

Issue

How can I extend SNMP to include sensor information from system units like power supplies, fans and temperature sensors?

Environment

  • Cumulus Linux, all versions

Overview

The Net-SNMP agent provides a method to extend SNMP in Cumulus Linux via the NET-SNMP-EXTEND-MIB. You can use this MIB to query shell scripts specified by the extend directive in /etc/snmp/snmpd.conf. The following example demonstrates how this method can be used by snmpd to extract sensor information from smonctl.

Resolution

Create a bin shell script in the directory /usr/lib/cumulus called monitor-smonctl containing the following:

#!/bin/bash
if [ -z "$1" ] ; then
echo "No sensor specified"
else
smonctl -s $1 | awk '{print $(NF)}'
fi

Execute smonctl and take note of the sensors that are to be monitored via SNMP.

cumulus@switch$ smonctl 
Fan1 : ABSENT
Fan2 : ABSENT
Fan3 : ABSENT
Fan4 : ABSENT
Fan5 : OK
Fan6 : OK
Fan7 : OK
Fan8 : OK
PSU1 : BAD
PSU2 : OK
Temp1 (Networking ASIC Die Temp Sensor ): OK
Temp2 (Right Side of Networking ASIC ): OK
Temp3 (Near CPU ): OK
Temp4 (Left Side of Networking ASIC ): OK
Temp5 (Left Corner near PHY ): OK
Temp6 (Fan Outlet sensor ): OK

Edit /etc/snmp/snmpd.conf and add a line in the EXTENDING THE AGENT section for each of the sensors to be monitored. In this example, all available sensors will be monitored.

extend PSU1 /bin/bash /usr/lib/cumulus/monitor-smonctl PSU1
extend PSU2 /bin/bash /usr/lib/cumulus/monitor-smonctl PSU2
extend Fan1 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan1
extend Fan2 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan2
extend Fan3 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan3
extend Fan4 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan4
extend Fan5 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan5
extend Fan6 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan6
extend Fan7 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan7
extend Fan8 /bin/bash /usr/lib/cumulus/monitor-smonctl Fan8
extend Temp1 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp1
extend Temp2 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp2
extend Temp3 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp3
extend Temp4 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp4
extend Temp5 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp5
extend Temp6 /bin/bash /usr/lib/cumulus/monitor-smonctl Temp6

If access control is required, add the NET-SNMP-EXTEND-MIB to the access control list in the ACCESS CONTROL section. In this example, NET-SNMP-EXTEND-MIB is added to the systemonly list.

# Net-SNMP extend
view systemonly included .1.3.6.1.4.1.8072.1.3.2.4.1.2

rocommunity public default -V systemonly

Edit /etc/default/snmpd and verify that SNMPDRUN=yes is enabled:

SNMPDRUN=yes

Restart snmpd to reload the configuration:

sudo service snmpd restart

Verify

The sensor information can be verified using the snmpwalk SNMP client application. SNMP client applications can be installed on a Debian host or a local or remote switch. In this example, the SNMP client applications are installed on the local switch.

Run apt-get update and apt-get install to install SNMP client applications.

sudo apt-get update
sudo apt-get install snmp

To enable OID to MIB translation, the MIBs need to be downloaded and installed. Add the "non-free" repo to /etc/apt/sources.list

deb http://ftp.us.debian.org/debian/ wheezy main non-free

Run apt-get update and apt-get install to install snmp-mibs-downloader.

sudo apt-get update
sudo apt-get install snmp-mibs-downloader

Remove or comment out the "non-free" repo from /etc/apt/sources.list

#deb http://ftp.us.debian.org/debian/ wheezy main non-free

Verify that the "mibs :" link is commented out in /etc/snmp/snmp.conf:

#
# As the snmp packages come without MIB files due to license reasons, loading
# of MIBs is disabled by default. If you added the MIBs you can reenable
# loading them by commenting out the following line.
#mibs :

Run snmpwalk to verify the NET-SNMP-EXTENDED-MIB is populated:

cumulus@switch$ snmpwalk -c public -v2c 127.0.0.1 NET-SNMP-EXTEND-MIB::nsExtendOutLine
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan1".1 = STRING: ABSENT
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan2".1 = STRING: ABSENT
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan3".1 = STRING: ABSENT
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan4".1 = STRING: ABSENT
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan5".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan6".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan7".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Fan8".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."PSU1".1 = STRING: BAD
NET-SNMP-EXTEND-MIB::nsExtendOutLine."PSU2".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp1".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp2".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp3".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp4".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp5".1 = STRING: OK
NET-SNMP-EXTEND-MIB::nsExtendOutLine."Temp6".1 = STRING: OK

 

Comments

This support portal has moved

Cumulus Networks is now part of the NVIDIA Networking Business Unit! The NVIDIA Cumulus Global Support Services (GSS) team has merged its operations with the NVIDIA Mellanox support services team.

You can access NVIDIA Cumulus support content from the Mellanox support portal.

You open and update new cases on the Mellanox support portal. Any previous cases that have been closed have been migrated to the Mellanox support portal.

Cases that are still open on the Cumulus portal will continue to be managed on the Cumulus portal. Once these cases close, they will be moved to the Mellanox support portal.

Powered by Zendesk