How to configure SNMP traps for ESXi/ESX 3.5, 4.x, and ESXi 5.x hosts

Monitoring the health of older ESX/ESXi systems can be implemented by enabling SNMP and setting up SNMP traps to track performance events. Learn how to set it up.

Note: This article assumes, that you have access to Remote CLI or vSphere CLI. Also, the SNMP firewall port 161 is open on ESX 5.0 by default, and earlier versions did not include the firewall.

  1. Run Remote CLI for ESXi 3.5 or vSphere CLI for ESXi 4.x+ and navigate to the directory where vicfg-snmp.pl is stored. By default it's located in: C:\Program Files\VMware\VMware vSphere CLI\bin

  2. Run the following command:

    vicfg-snmp.pl --server <HOSTNAME> --username <USERNAME> --password <PASSWORD> --show
    

    Side-note: You can always use vicfg-snmp.pl --help command for the full list of options.

  3. Specify the SNMP communities and SNMP Trap targets:

    vicfg-snmp.pl --server <HOSTNAME> --username <USERNAME> --password <PASSWORD> -t <HOSTNAME@PORT> -c <COMMUNITY>
    

    Side-note: for ESXi 3.5 you may need to use a little bit different syntax:

    vicfg-snmp.pl --server <HOSTNAME> --username <USERNAME> --password <PASSWORD> -t <HOSTNAME@PORT/COMMUNITY>
    

    Example: Let's say we are trying to send SNMP traps from the host host.example.com to port 162 on target.example.com, using the public community. In such a case, the command should look as below:

    vicfg-snmp.pl --server host.example.com --username root --password password -t target.example.com@162 -c public
    

    or like this:

    vicfg-snmp.pl --server host.example.com --username root --password password -t target.example.com@162/public
    

    depending on the ESX/ESXi version you have configured on your host.

  4. Now, to enable SNMP service use this command:

    vicfg-snmp.pl --server <HOSTNAME> --username <USERNAME> --password <PASSWORD> --enable
    
  5. Finally, send a test warmStart trap to ensure that everything works correctly:

    vicfg-snmp.pl --server <HOSTNAME> --username <USERNAME> --password <PASSWORD> --test
    

It is worth noting that all changes to the SNMP configuration are stored on the ESXi/ESX host in /etc/vmware/snmp.xml, and the ESX/ESXi SNMP agent log messages are saved in /var/log/syslog.log.

Remember that you can always remove --password <PASSWORD> element from the commands shown above, to prevent displaying user passwords in plain text. You will be prompted to enter the password instead, and the entry will remain hidden. Safety first!

esxsnmptrapsvirtualizationvmware

NetCrunch Network Monitoring

Network Maps, Dashboards, and Alerts.
Monitor anything. Network, cloud, config.