Learn how to configure vSphere Web Client, ESXi, and vCenter Server to enable receiving info about events as SNMP traps
Enable SNMP on ESXi
-
Enable SSH on ESXi
- Open vSphere Web Client
- Open
Configure -> System -> Security Profile -> Configure, then clickEditbutton - Select
SSHand clickStartbutton
-
Configure SNMP on ESXi
- Open SSH client
- Login into VMware (use root credentials)
-
Set community:
esxcli system snmp set --communities `<COMMUNITY_STRING>` -
Enable SNMP service:
esxcli system snmp set --enable true
-
Set firewall rules on ESXi
-
we need to allow traffic from the NetCrunch Server host
esxcli network firewall ruleset set --ruleset-id snmp --allowed-all false esxcli network firewall ruleset allowedip add --ruleset-id snmp --ip-address `<NETCRUNCH_SERVER_IP>`/`<MASK>` (eg. 192.168.0.1/24) esxcli network firewall ruleset set --ruleset-id snmp --enabled true
-
we need to allow traffic from the NetCrunch Server host
-
Restart SNMP Service
/etc/init.d/snmpd restart - Disable SSH on VMware host
Configure vCenter Server SNMP agents and ESXi SNMP agents
-
Configure SNMP Community
- Open appliance shell
- Log in as an administrator or super administrator user
-
Configure SNMP community. To do this run the following command:
snmp.set --communities `<COMMUNITIES>`
-
Configure SNMP Agent
- Open appliance shell
- Log in as an administrator or super administrator user
-
Run the following command:
snmp.set --targets `<NETCRUNCH_SERVER_IP>`@`<PORT>`/`<COMMUNITY>`
Configure traps to be sent as an Alarm Action
Traps can be configured for many different types of events. For hosts, virtual machines, etc. For the purposes of this article, we will create a trap that will be sent when the VM is powered on.
- Open Homepage in VMware Client
- Select
VMs and Templatesview - Select Virtual Machine
- In the right panel, select the
Configuretab - Go to
Alarm Definitions - Click the
Addbutton - In new WIndow provide Alarm Name and select Target type:
Virtual Machines -
In Alarm Rule 1 set condition:
IF VM powered on Send SNMP traps - Go to the last tab and click the
CREATEbutton
Configure NetCrunch
When you configure everything correctly in VMware, the traps will start displaying in NetCruch, in the External Events tab. To set up alerts, please do as follows:
- Go to the
External Eventstab - Open the
SNMP Trapstab - Localize interesting trap
- Click on the
Set Alertbutton on the left side of the trap - All settings should be set in the
New Alert Rule...window, so just click theOKbutton to save alert - Select Alerting Script from the list or create a new one
- Click the
OKbutton
From now, when the virtual machine migrates, you will be informed about it in the way you selected in step 6 above.