First login to your VMa!
To add a SNMP target to your ESX host you can use the following command:
ESXhost: Fill in your ESX hostname or IP
ROOT: fill in the root user, or user with enough permissions to set the SNMP traps
ROOT_PASS: password of the user
snmptarget1: the first snmp target you want to send the SNMP traps too
162: port number to traps
community: the community
I divided the commands in two parts, so the first command line sets the targets on the ESX hosts and the 2nd command line enables and sends a test trap.
You can put the -E and -T option behind the first line, but I noticed it isn’t always working flawless.
#Add SNMP target
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS</b> -t <b>snmptarget1</b>@<b>162</b>/<b>community</b>,<b>snmptarget2</b>@<b>162</b>/<b>community</b> -c <b>community</b>
#Enable SNMP TEST
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS </b>-E -T
#Show SNMP settings
vicfg-snmp --server <b>ESXHOST </b>--username <b>ROOT </b>--password <b>ROOT_PASS </b>--show
To set the traps and enable this it’s not needed to put a host in maintenance mode.
Aferwards, check on your target if the SNMP traps are received. Make sure that your SNMP target is reachable from the ESX hosts.
Because I didn’t want to do this for each server I made a little .SH script which sets this for all servers found in VIFP LISTSERVERS
See example:
vifp listservers|while read a b c; do /usr/bin/vicfg-snmp --server $a -username <b>root </b>--password <b>ROOT_PASS </b>-t snmptarget@162/patrol
vifp listservers|while read a b c;do /usr/bin/vicfg-snmp --server $a -username <b>root </b>--password <b>ROOT_PASS </b> -E -T;done
So now it’s only needed to start the script to set the SNMP traps on all your servers. It’s also possible trough powerCLI but I tought this was easier.
Also added the SNMP trap settings to our kickstart script. So I’m always sure the SNMP traps are set as soon as a (new) server is installed.