The commands vicfg-snmp.pl (esxcfg-snmp.pl) allow you to enable, configure and disable the SNMP agent that comes with ESXi. Given the architecture of ESXi, it is not possible to add 3rd party SNMP agents to ESXi and given the diverse nature of SNMP management applications, ESXi only support SNMP traps and not gets. The SNMP agent is disabled by default. To setup the SNMP agent it is necessary to enable the agent, specify at least on community and then configure a trap destination. The configuration options (add community, set trap destination and set the port) will overwrite existing values.
To enable the SNMP agent use this command.
vicfg-snmp.pl –server <server_name> -E or vicfg-snmp.pl –server <server_name> –enable
To set the community for the SNMP agent use this command. Seperate multiple community names with a comma. There should be no place between the community names and the commas seperating them.
vicfg-snmp.pl –server <server_name> -c <community_name1>[,<community_name2>, …] orvicfg-snmp.pl –server <server_name> –communities <community_name1>[,<community_name2>, …]
To set the trap destination for the SNMP agent use this command. The port setting is optional. There should be no place between the target names and the commas seperating them.
vicfg-snmp.pl –server <server_name> -t <hostname1>[@port]>/<community_name1>[,<hostname2>[@port]>/<community_name2>, …] or vicfg-snmp.pl –server <server_name>–targets <hostname1>[@port]>/<community_name1>[,<hostname2>[@port]>/<community_name2>, …]
To test the settings for the SNMP agent use this command.
vicfg-snmp.pl –server <server_name> -T or vicfg-snmp.pl –server <server_name> –test
To display the settings for the SNMP agent use this command.
vicfg-snmp.pl –server <server_name> -s or vicfg-snmp.pl –server <server_name> –show
To reset the settings for the SNMP agent use this command.
vicfg-snmp.pl –server <server_name> -r or vicfg-snmp.pl –server <server_name> –reset
To disable the SNMP agent use this command.
vicfg-snmp.pl –server <server_name> -D or vicfg-snmp.pl –server <server_name> –disable
To set the port for the SNMP agent use this command. The default port is 162
vicfg-snmp.pl –server <server_name> -p <port number> or vicfg-snmp.pl –server <server_name>–port <port number>
Sample session
vicfg-snmp.pl –server 192.168.1.20 -s
Current SNMP agent settings:
Enabled : 0
UDP port : 161
Communities :
Notification targets :
vicfg-snmp.pl –server 192.168.1.20 -c public1,private1 -t 192.168.1.5/public1,192.168.1.6@163/private1 -p 163
Changing udp port to 163…
Complete.
Changing community list to: public1,private1…
Complete.
Changing notification(trap) targets list to: 192.168.1.5/public1,192.168.1.6@163
/private1…
Complete.
vicfg-snmp.pl –server 192.168.1.20 -E -T
Enabling agent…
Complete.
ending test nofication(trap) to all configured targets…
Complete. Check with each target to see if trap was received.
vicfg-snmp.pl –server 192.168.1.20 -s
Current SNMP agent settings:
Enabled : 1
UDP port : 163
Communities :
public1
private1
Notification targets :
192.168.1.6@41728/private1
192.168.1.5@41472/public1