SNMP can be used to automatically retrieve status information from vSphere and ESXi hosts and provide the ability to push this information into a monitoring and management system.
You can configure a maximum of four SNMP receivers can be configured per vCenter to send SNMP traps to management systems.
To configure SNMP receivers, using the vSphere Web Client, select the vCenter server instance and browse to Manage > General > Edit > SNMP receivers.
You may also configure SNMP on a vCenter server using PowerCLI by invoking the ‘Get-AdvancedSetting’ and ‘Set-AdvancedSetting’ cmdlets, to which the Entity parameter is the vCenter server.
In order to retrieve the configuration for each SNMP receiver and to display the configuration parameter and value, we can invoke the following:
Get-AdvancedSetting -Entity deanvc1.dean.local -Name snmp.receiver.* | fl Description, Value, Description
If you required to target a specific SNMP receiver we can filter the name further, in the below example retrieving the configuration for SNMP receiver 2.
Get-AdvancedSetting -Entity deanvc1.dean.local -Name snmp.receiver.2* | fl Description, Value, Description
For a particular configuration parameter we can filer by the exact match of the name, where the below retrieves the community name for the primary SNMP receiver.
Get-AdvancedSetting -Entity deanvc1.dean.local -Name snmp.receiver.1.community | fl Description, Value, Description
To configure the SNMP receiver using PowerCLI, we first need to retrieve the setting we require to modify and then pass this to the ‘Set-AdvancedSetting’ cmdlet to set the value, in this instance invoke the cmdlet without asking for user confirmation. In this example, we will configured the primary SNMP receiver with the community name ‘vmware’.
Get-AdvancedSetting -Entity deanvc1.dean.local -Name snmp.receiver.1.community | Set-AdvancedSetting -Value vmware -Confirm:$False
A single SNMP receiver can also be configured on each ESXi host using ‘esxcfgcli system snmp’ from the command line interface. If we wish to retrieve the current configuration we can invoke:
esxcli system snmp get
The set of commands also allow for the SNMP receiver to be enabled, set a community name and specify a target, as below:
esxcli system snmp set -enable true esxcli system snmp set -communities vmware esxcli system snmp set -targets deanesxi1.dean.local@161/vmware