Depending on your version of ESXi, the setup steps will change. For my sanity, I am only going to list ESXi 5.0, 5.1+. Prior to 5.0 the steps were significantly different.
ESXi 5.0: VMware documentation
ESXi 5.1+: VMware documentation The commands below will setup SNMP and allow SNMP through the firewall. If you prefer, you can setup the firewall rules using the vSphere Client GUI under Configuration > Security Profile. Replace ‘YOUR_STRING’ with your community string
esxcli system snmp set --communities YOUR_STRING esxcli system snmp set --enable true esxcli network firewall ruleset set --ruleset-id snmp --allowed-all true esxcli network firewall ruleset set --ruleset-id snmp --enabled true /etc/init.d/snmpd restart