Touching on ESXi SNMP

Simple Network Management Protocol (SNMP) is a well known protocol for monitoring, configuring, and collecting information from network devices. As the wikipedia definition aptly puts it “SNMP exposes management data in the form of variables on the managed systems organised in a management information base (MIB) which describe the system status and configuration. These variables can then be remotely queried (and, in some circumstances, manipulated) by managing applications.” Within each MIB, which is usually a text file, resides object identifiers (OIDs) data which is used to translate between the numeric OID information and what you and I can understand.

Getting into this all came about after a customer had expressed interest in building their own internal SNMP server and was inquiring about some sample data from a host. I went ahead and tossed ESXi6.5d on a Mac mini and then enabled SNMP. To get some sample data the easiest thing seemed to be a quick snmpwalk against the host, which will query the ESXi snmp agent.

Fastest  way to do this would be from your flavor of Linux distro, in my case I used CentOS-7 and then installed the snmp pacakge:

#yum install net-snmp-utils.x86_64

Next you want to transfer the VMware MIB Bundle to the test server. Go ahead unzip the newly downloaded file, and copy the contents to to /usr/share/snmp/mibs on your demo server.

With the aforementioned installed you can now do a walk through the tree with the “snmpwalk” command which allows you to display variables from the MIB that are available on the snmp device which will be monitored.

[root@localhost mibs]# snmpwalk -m ALL -c public -v 2c 10.25.0.11
SNMPv2-MIB::sysDescr.0 = STRING: VMware ESXi 6.5.0 build-5310538 VMware, Inc. x86_64
SNMPv2-MIB::sysObjectID.0 = OID: VMWARE-PRODUCTS-MIB::vmwESX

NOTE:> There is quite a bit more output here, but this gives a sample idea of what is the result.

Screenshot_1

As an example I had seen, which was also spot on for the use case I had been looking for, we can look closer at the network link status by appending “IF-MIB::ifDescr” to search against the “IF-MIB.mib” tree.

[root@localhost mibs]# snmpwalk -m ALL -c public -v 2c 10.25.0.11 IF-MIB::ifDescr
IF-MIB::ifDescr.1 = STRING: Device vmnic0 at 02:00.0 tg3
IF-MIB::ifDescr.2 = STRING: Distributed Virtual VMware switch: DvsPortset-0
IF-MIB::ifDescr.3 = STRING: Virtual interface: vmk0 on port 33554436 DVS 50 23 f2 8b 7f d9 a9 78-65 2e 69 f0 dc 8e 1b 73

Running snampwalk with the -O fn parameters you can then see the same information as above with the actual OID presented.

[root@localhost mibs]# snmpwalk -O fn -m ALL -c public -v 2c 10.25.0.11 IF-MIB::ifDescr
.1.3.6.1.2.1.2.2.1.2.1 = STRING: Device vmnic0 at 02:00.0 tg3
.1.3.6.1.2.1.2.2.1.2.2 = STRING: Distributed Virtual VMware switch: DvsPortset-0
.1.3.6.1.2.1.2.2.1.2.3 = STRING: Virtual interface: vmk0 on port 33554436 DVS 50 23 f2 8b 7f d9 a9 78-65 2e 69 f0 dc 8e 1b 73

As a tip, you can use snmptranslate to go back and forth between human-readable and the OID number, which can come in handy while perusing the large MIB. (Example using the OID for the vmnic0 of the mac mini ESXi sample host)

snmptranslate -O fn IF-MIB::ifDescr.1
.1.3.6.1.2.1.2.2.1.2.1
or

[root@localhost mibs]# snmptranslate .1.3.6.1.2.1.2.2.1.2.1
IF-MIB::ifDescr.1

Opening the IF-MIB.mib in a text editor you can see the “ifOperStatus” parameter to check the status of the interface. (This was the exact OID I was looking for)

[root@localhost mibs]# snmpwalk -O fn -m ALL -c public -v 2c 10.25.0.11 IF-MIB::ifOperStatus
.1.3.6.1.2.1.2.2.1.8.1 = INTEGER: up(1)
.1.3.6.1.2.1.2.2.1.8.2 = INTEGER: up(1)
.1.3.6.1.2.1.2.2.1.8.3 = INTEGER: up(1)

Another example is from the SNMPv2-MIB.mib which garnered the name of the host information SNMPv2-MIB::sysName.0 = STRING: MiniESXi-1

There are 56 MIBs in the bundle that I downloaded from VMware and it is just a matter of sifting through for what you are looking for. For sure some resources that assisted me were the VMTN forums, other community sites and the net-snmp tutorial.

Scroll to Top