You can use ESXCLI to configure a trap destination and send traps.

Specify one of the options listed in Connection Options for vCLI Host Management Commands in place of <conn_options>.

Procedure

  1. Make sure a community is set up.
    esxcli system snmp get <conn_options>
    
    Current SNMP agent settings:
    Enabled: 1
    UDP port: 161
    Communities: public
    Notification targets:
  2. Set the target address, port number, and community.
    esxcli <conn_options> system snmp set -t target.example.com@163/public

    Each time you specify a target with this command, the settings you specify overwrite all previously specified settings. To specify multiple targets, separate them with a comma.

    You can change the port that the SNMP agent sends data to on the target using the --targets option. That port is UDP 162 by default.

  3. (Optional) Enable the SNMP agent if it is not yet running.
    esxcli <conn_options> system snmp set --enable=yes
  4. (Optional) Send a test trap to verify that the agent is configured correctly.
    esxcli <conn_options> system snmp test
    The agent sends a warmStart trap to the configured target.