To configure Zenoss to monitor a device using SNMP, it is necessary to understand a bit about SNMP and the specific capabilities of your device. This section will walk you through using Net-SNMP, smidump, and snmpsim to learn about SNMP and your device.
In the SNMP world the client is referred to as a manager and the
server is referred to as the agent. Net-SNMP is software that provides
both an agent that’s used in all sorts of devices, and many command
line tools that act as manager. We’re only going to need the command
line tools, so we’ll be installing the
You can install Net-SNMP’s command line tools by running the following command as root.
yum -y install net-snmp-utils
smidump is a useful command line tool for converting MIBs to other
formats. We’ll be using it later in this tutorial to research what a MIB
smidump by installing the
libsmi package with the following
yum -y install libsmi
Installing the SNMP Simulator
When developing a ZenPack to monitor an SNMP-enabled device it can often be useful to simulate the device’s SNMP agent. There are many tools available to do this. For this guide we will be using the free snmpsim because it’s easy to install on our Zenoss host.
Run the following commands as root to install
yum -y groupinstall "Development Tools" yum -y install python-devel easy_install snmpsim mkdir -p /usr/share/snmpsim/data mkdir -p /var/run/snmpsim useradd -U snmpsim chown snmpsim:snmpsim /var/run/snmpsim
Run the following command as root to install a NetBotz recording.
wget https://goo.gl/OJe2vL -O /usr/share/snmpsim/data/public.snmprec
Run the following command as root to run snmpsim.
snmpsimd.py \ --process-user=snmpsim \ --process-group=snmpsim \ --agent-udpv4-endpoint=172.17.0.1:161 \ --daemonize
Test the simulator with the following
snmpwalk -v2c -c public 172.17.0.1 sysDescr
You should see the following output.
SNMPv2-MIB::sysDescr.0 = STRING: Linux Netbotz01 2.4.26 #1 Wed Oct 31 18:09:53 CDT 2007 ppc
The tool you’ll be using most often is called
snmpwalk. All SNMP
values are arranged on a tree, and snmpwalk allows you to query for all
data under a given branch of that tree. See the following example that
walks all values under the
Run the snmpwalk command.
snmpwalk -v2c -c public 172.17.0.1 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux Netbotz01 2.4.26 #1 Wed Oct 31 18:09:53 CDT 2007 ppc SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.55220.127.116.11.2006 DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (7275488) 20:12:34.88 SNMPv2-MIB::sysContact.0 = STRING: unknown SNMPv2-MIB::sysName.0 = STRING: Netbotz01 SNMPv2-MIB::sysLocation.0 = STRING: Z1 Rack02 NetBotz01
We can see that this NetBotz device seems to be based on Linux and that we have some more-or-less useful information about the device’s name, location and administrative contact.
The second line with the
sysObjectID has an unusual value. It’s a
partially decoded OID. It isn’t decoded enough for us to know what it
means. SNMP tools including Net-SNMP use MIB files to decode these OIDs
into human readable values. In fact, we’re only able to read most of the
output above because Net-SNMP has a set of standard MIBs enabled by default.
Let’s run that command again, but use the
-On flag to tell snmpwalk
not to decode OIDs.
snmpwalk -v2c -c public -On 172.17.0.1 system
.18.104.22.168.22.214.171.124.0 = STRING: Linux Netbotz01 2.4.26 #1 Wed Oct 31 18:09:53 CDT 2007 ppc .126.96.36.199.188.8.131.52.0 = OID: .184.108.40.206.4.1.55220.127.116.11.2006 .18.104.22.168.22.214.171.124.0 = Timeticks: (7275488) 20:12:34.88 .126.96.36.199.188.8.131.52.0 = STRING: unknown .184.108.40.206.220.127.116.11.0 = STRING: Netbotz01 .18.104.22.168.22.214.171.124.0 = STRING: Z1 Rack02 NetBotz01
While this data is mostly less valuable than the decoded version above,
it’s more useful for a single reason. We can take
.126.96.36.199.4.1.55188.8.131.52.2006 value and search the Internet
for it. It’s best to remove the leading
. and search
184.108.40.206.4.1.55220.127.116.11.2006 instead. This should lead you to
NETBOTZV2-MIB which will contain the decoding information we need
to learn more about this device.
Run the following command to download
wget https://goo.gl/0v4Kti -O /usr/share/snmp/mibs/NETBOTZV2-MIB.mib
Now we can run the original
snmpwalk command again with the addition of
-m all option. This option tells Net-SNMP tools to use all MIBs.
snmpwalk -v2c -c public -m all 172.17.0.1 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux Netbotz01 2.4.26 #1 Wed Oct 31 18:09:53 CDT 2007 ppc SNMPv2-MIB::sysObjectID.0 = OID: NETBOTZV2-MIB::netBotz420ERack DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (7275488) 20:12:34.88 SNMPv2-MIB::sysContact.0 = STRING: unknown SNMPv2-MIB::sysName.0 = STRING: Netbotz01 SNMPv2-MIB::sysLocation.0 = STRING: Z1 Rack02 NetBotz01
Now we can see that the
This gives us a better idea of exactly what kind of device it is. We’ll
see that as we look deeper into this device that the
prove more useful.
Default Net-SNMP options
snmpwalk usage showed three primary command line options that we
tend to use most of the time. Net-SNMP allows you to specify these in a
configuration file so you don’t have to type them every time. I
recommend doing this.
/etc/snmp/snmp.conf and add the following lines.
defVersion v2c defCommunity public mibs ALL
These lines add the following equivalent command line options respectively:
So now we can run this command.
snmpwalk 172.17.0.1 sysObjectID
And get the same results as if we ran.
snmpwalk -v2c -c public -m all 172.17.0.1 sysObjectID
This will save you time while developing this ZenPack, and others in the future.
Decoding and Encoding OIDs
Often it can be useful to turn numeric OIDs into their human-readable
equivalent, or vice-versa. The
snmptranslate command can be used for
this. See the following examples.
OID to name:
Name to OID:
snmptranslate -On NETBOTZV2-MIB::netBotz420ERack