Enable and configure SNMP on VMware ESXi 5

       362 words, 2 minutes

Here we are, VMware ESXi 5 is installed on the Z68 motherboard. One of the first thing to do is enable SNMP to be able to actually get remote information on what happens to the beast :) Later on, we’ll be able to get pretty graphs to show how the virtual infrastructure lives.

Here’s how I did enable and configure SNMP on my ESXi. This is the free instance, without any vCenter.

First thing to do is install the VMware vSphere CLI ; I installed mine in some Windows virtual instance (VMware-vSphere-CLI-5.0.0-422456.exe). Once installed, start a VMware vSphere CLI and issue the following commands:

  C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>vicfg-snmp.pl \
     --server esxi -c C0MMUN1TY
  Enter username: root
  Enter password: xxxx
  Changing community list to: C0MMUN1TY...
  Complete.
  
  C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>vicfg-snmp.pl \
     --server esxi --enable
  Enter username: root
  Enter password: xxxx
  Enabling agent...
  Complete.
  
  C:\Program Files (x86)\VMware\VMware vSphere CLI\bin>

You may want to pass the credentials on the command line. I just forgot to do so :)

Now, the system can be queried from your LAN:

  # snmpwalk -v 2c -c C0MMUN1TY esxi system
  SNMPv2-MIB::sysDescr.0 = STRING: VMware ESX 5.0.0 build-469512 VMware, Inc. x86_64
  SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.6876.4.1
  SNMPv2-MIB::sysUpTime.0 = Timeticks: (6874825) 19:05:48.25
  SNMPv2-MIB::sysContact.0 = STRING: not set
  SNMPv2-MIB::sysName.0 = STRING: esxi.tumfatig.net
  SNMPv2-MIB::sysLocation.0 = STRING: not set
  SNMPv2-MIB::sysServices.0 = INTEGER: 72
  SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
  (...)

But there is more! Try the following command:

  # snmpwalk -v 2c -c C0MMUN1TY -On esxi .1.3.6.1.4.1.6876.2.1.1.8
  .1.3.6.1.4.1.6876.2.1.1.8.1 = STRING: "running"
  .1.3.6.1.4.1.6876.2.1.1.8.2 = STRING: "notRunning"
  .1.3.6.1.4.1.6876.2.1.1.8.3 = STRING: "notRunning"
  .1.3.6.1.4.1.6876.2.1.1.8.4 = STRING: "notRunning"

Now, grab the VMware vSphere SNMP MIB Modules (VMware-esx-mibs-1.0.1-368563.zip) and install it. Then run the following command:

  # snmpwalk -v 2c -c C0MMUN1TY -M +. -m ALL esxi .1.3.6.1.4.1.6876.2.1.1.8
  VMWARE-VMINFO-MIB::vmwVmGuestState.1 = STRING: running
  VMWARE-VMINFO-MIB::vmwVmGuestState.2 = STRING: notRunning
  VMWARE-VMINFO-MIB::vmwVmGuestState.3 = STRING: notRunning
  VMWARE-VMINFO-MIB::vmwVmGuestState.4 = STRING: notRunning

Tada! This is quite simple. But there is more to get using the Perl SDK ; and maybe the vCenter… Got to figure this out… later on ;-)

BTW, it is also possible to enable SNMP from the ESXi shell. It just needs a bit of editing and services restart:

  # vi /etc/vmware/snmp.xml
  <config><snmpSettings><enable><b><i>true</i></b></enable><communities><b><i>C0MMUN1TY</i></b></communities><targets></targets></snmpSettings></config>
  # services.sh restart