This post outlines how to get SNMP traps from ESX hosts and monitor them in Opsview. The first part deals with configuring SNMP traps to get them working correctly with ESX hosts, part 2 tells you how to monitor them with Opsview.

The following steps worked on ESX 4.1. Depending on versions you may have different results. For simplicity, I used as IP for my ESX host, and for my SNMP trap handler. 1. Download and install the vSphere CLI. Keep in mind that you need an account to access it. Check BugMeNot if you’re not in the mood for registering. The vSphere CLI will give you a host of useful tools to control your ESX environment with without having to resport to SSH or console access. 2. Check if you already have an active SNMP agent on your host with the following command:

vicfg-snmp --show --server

3. If no traps are configured (why would you even be reading this if they were?). Add your SNMP target like this (By default, vicfg-snmp.pl is located in the C:\Program Files\VMware\VMware vSphere CLI\bin directory):

vicfg-snmp.pl --server --username root --password qwerty1234 -t [email protected]/communitystring

4. Enable the SNMP service:

vicfg-snmp.pl --server --username root --password qwerty1234 --enable

5. Check that you have a working configuration by using the -show command like this:

vicfg-snmp.pl --server --username root --password qwerty1234 --show

Your output should look something like this:

Current SNMP agent settings: Enabled : 1 UDP port : 162 Communities : communitystring Notification targets : [email protected]/communitystring

6. If you’d like, you can send a test trap to your target to make sure you’re on the right path. If you’re just testing, you can send them to your own client PC. I use the freeware application SNMP Trap Watcher for this. Sending the following command through the vSphere CLI will generate a Warm Start trap:

vicfg-snmp.pl --server --username root --password qwerty1234 --test

You should receive a report in your trap watcher:

If you’re not getting anything, chances are the ESX firewall isn’t allowing SNMP traffic. I had to allow this using the vSphere Client (connect to the ESX server, not a vCenter host). Click the tab “Configuration”, and select “Security Profile” in the menu on your left. Click “Properties” and enable SNMP:

The outgoing port will be the one you configured when you added a trap handler in step 4. That’s it. You have an ESX host sending SNMP traps properly. Now all you need to do is get your monitoring software to understand what it’s saying. We’ll cover that in the next post later this week.

About the Author

Marcus Vejneke holds a bachelor’s degree in computer science and engineering and has worked in IT for almost 14 years. Marcus lives in Sweden and works as Sysadmin.

Legal Disclaimer

This blog post is contributor by a member of the Opsview community. The Opsview project and Opsera Ltd. accept no responsibility for the accuracy of its content and are not liable for any direct or indirect damages caused by its use.