In this post we will show how you can use the SNMP plug-in to receive various vCenter Server alarms in vCO and include these events as part of more complex orchestration logic.
vCenter Server configuration
First, you must register the vCO server in the list of SNMP trap receivers in vCenter Server. This list is accessible in the vSphere client, in vCenter Server Settings, which is accessible from the Administration menu.
You can have up to four different receivers, one of which must link to the address of your vCO server and the port defined in the Trap Host node in the SNMP inventory in vCO.
After you have registered the vCO server, vCenter Server can send SNMP traps to it. Some traps will start to be sent immediately. Many alarms in vCenter Server are configured to send traps by default.
Some default alarms are defined on the root of the vCenter Server inventory (1), from where they propagate to all child objects. If you go to the Alarm management tab (2), you can check the definitions (3) of the default alarms. Selecting a specific alarm (4), you can check on its Actions tab (5) if sending SNMP traps is active for this specific alarm (6).
These settings can be changed on the object where the alarm is defined. If the fields are not editable, then this is an inherited alarm, and you need to find the parent object that defines the alarm to change the settings.
Create custom alarms
Sometimes you may need to monitor something specific that is not part of the default alarms, or you only want to monitor it for a certain host, virtual machine or other object. Then you need to add a custom alarm to the object (a datastore in this example).
Then, you need to add some triggers which define under what conditions this alarm should be triggered.
Finally, you need to add an action that will send a trap. Note that you may need to add handlers to state changes. For example, the green to yellow state change does not send a trap, as by default only the yellow to red state change is defined to send a trap.
After this, the vCenter Server instance is ready and is sending traps to vCO.
Configure vCO to receive traps
On the receiving end, you first need to add the vCenter Server instance to your inventory with the “Register an SNMP device” workflow.
Then you can either apply a policy, which will be receiving all kinds of traps and running scripts on each of them, or start a workflow, which will be waiting for a specific trap.
The policy is applied from the Policy Template “SNMP Trap”, and takes as a parameter the SNMP device that you just registered.
This exact policy is only printing the trap data to the system log, but it could do other tasks, such as, call actions or workflows that should handle the received traps.
You must start the policy after it is created, or set it to auto-start if you need it to work after server restart.
You can leave this policy to be listening for traps for the moment, and check the other possibility to receive traps – the “Wait for a trap on an SNMP device” workflow.
After you enter the device and OID parameters and run the workflow it reaches a trigger where it suspends and starts waiting. It can be resumed only by the specified SNMP trap.
If the OID field from the workflow presentation was left empty, then the workflow will be resumed by any trap, just like the the policy. Any trap filtering on the policy must be done programatically, after the trap is received. Listening to all incoming traps can help you easily get the correct OID that will be sent from vCenter Server for a specific alarm. These OIDs are also listed in the MIBs that are described in vSphere Datacenter Administration Guide, in the “Monitoring Your Virtual Infrastructure” section, chapter “SNMP and vSphere”.
If everything is configured correctly, vCO should start receiving SNMP traps and trap data will be logged from the policy, like in this example, which is monitoring datastore space usage.
The SNMP plug-in is not limited only to use with vCenter Server. It can be used with any SNMP-enabled system or device. This is just one scenario that shows how the SNMP plug-in, together with the workflow library from the vCenter Server plug-in, can be used as the basis for the automation of various datacenter administration tasks.