SNMP trap provides a very useful way to monitor vSphere. You can use either GUI or vSphere API to configure up to 4 trap receivers. With that I can use alarm to monitor events or state changes.
If you use vSphere API to add SNMP receivers, you will need the OptionManager managed object. The related options you want to set are: snmp.receiver.1.name, snmp.receiver.1.port, snmp.receiver.1.community, snmp.receiver.1.enabled. There are 3 more sets with similar names but different numbers (2, 3, 4).
Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.
If you prefer the GUI, just go to the Home and click on “vCenter Server Settings.” In the dialog box, pick the SNMP from left side list and then enter the IP address of your receiver in the URL under the primary receiver, which is also the first there. Keep the rest as they are and then click OK to save it.
Everything works perfect until I checked my trap receiver after setting up an alarm to monitor virtual machine power off events. Not really true as I did get into another issue with firewall on my Windows 7. But that’s not vSphere issue. Turning off the firewall worked. It may not be a good idea but not a bad hack if you want a quick result.
For my test purpose, I used a free GUI tool called Trap Receiver (http://www.trapreceiver.com/). From the GUI, I could see the IP address of sender column is “127.0.0.1”. Because I ran vCenter and Trap Receiver on two different machines, I know it’s not right. The vCenter appliance had its own static IP address.
This issue turned out to be only with the virtual appliance which is based Linux. On Windows OS, there was no such issue.
To fix the problem, I tried to change the vCenter name and managed IP address within the vCenter Server Settings” dialog box. It’s interesting that the vCenter server name is categorized in “Runtime Settings.” I think it should be either “General” or simply “Name Settings” because the vCenter name does not seem to me as something runtime per se.
After that, the IP in the SNMP remained to be 127.0.0.1. Inspired by a friend, I started to look at the /etc/hosts file. Even after I change the vCenter name from localhost to “vCSA,” the files remains to look like this:
127.0.0.1 vCSA localhost
To try it out, I add one more entry on top
After that things started to work and I could see the send IP address become 192.168.0.128. The problem solved.
It’s not clear to me whether the issue is there if the vCenter server appliance has joined a domain by Active Directory. For lab, you probably don’t need to. In case you ran into this issue, just try this walk around.