Configure SNMP trap destination using ESXCLI tool

Prerequisites

To configure the SNMP trap destination using remote ESXCLI tool, perform the following steps:

Steps

  1. To download the ESXCLI installer, do the following:
    1. Open VMware home.
    2. Click the Resources tab.
    3. In the Developer Tools section, click Standalone ESXCLI and download the required version of the ESXCLI.
  2. Install the Standalone ESXCLI tool on a server with supported Microsoft Windows or Linux operating systems installed.
  3. Open the Standalone ESXCLI tool which is available at the following directories:
    • Linux—/opt/vmware/esxcli
    • Microsoft Windows—C:\Program Files (x86)\VMware\esxcli
  4. To set a community name, run the following command:
    esxcli --server <ESXi_host_ip> --username <user> --password <password> system snmp set --communities <community_name>
  5. To set the SNMP trap destination, run the following command:
    esxcli --server <ESXi_host_ip> --username <user> --password <password> system snmp set --targets=<trap_destination_ip>@162/public
  6. To enable the SNMP trap, run the following command:
    esxcli --server <ESXi_host_ip> --username <user> --password <password> system snmp set --enable true

    If the firewall blocks the SNMP traffic, run the following commands to change the firewall configuration:

    1. To enable SNMP traffic, run the following command:
      esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true
    2. To enable ruleset, run the following command:
      esxcli network firewall ruleset set --ruleset-id snmp --enabled true
    NOTE:  When you identify certificate-related issues in the remote ESXCLI tool, you must either configure the following:
    • A valid certificate
    • Pass a thumbprint value for a trusted connection with the VMware ESXi host.

    For more information about the ESXCLI tool, seeESXCLI 7.0 .

    NOTE:  The SNMP trap configuration is effective immediately and does not require any Server Administrator services.