vCO Workflow Policy to Listen for SNMP Device Traps

The following is the vCO Workflow Policy to Listen for SNMP Device Traps

 

var strKey;
	strKey = event.getValue("key");

var objSNMPSnmpResult;
	objSNMPSnmpResult = SnmpService.retrievePolicyData(strKey);

var arrProperties;
	arrProperties = new Array();

if ( objSNMPSnmpResult.type == "Array" )
{
	var arrSNMPSnmpResult;
		arrSNMPSnmpResult = objSNMPSnmpResult.arrayValue;


	for (var i = 0; i < arrSNMPSnmpResult.length; i++)
	{
		var objSNMPSnmpResultLOOP;
			objSNMPSnmpResultLOOP = arrSNMPSnmpResult[i]

		var objProperties;
			objProperties = new Properties();
			objProperties.put("oid", objSNMPSnmpResultLOOP.oid);
			objProperties.put("type", objSNMPSnmpResultLOOP.type);
			objProperties.put("snmpType", objSNMPSnmpResultLOOP.snmpType);
			objProperties.put("value", objSNMPSnmpResultLOOP.stringValue);

		arrProperties.push(objProperties);
	}
}
else
{
	var objProperties;
		objProperties = new Properties();
		objProperties.put("oid", objSNMPSnmpResult.oid);
		objProperties.put("type", objSNMPSnmpResult.type);
		objProperties.put("snmpType", objSNMPSnmpResult.snmpType);
		objProperties.put("value", objSNMPSnmpResult.stringValue);

   arrProperties.push(objProperties);
}

var strWorkflowID;
	strWorkflowID = "aed3c231-5ba8-43d8-a1a2-03cbc98608eb";

var objWorkflow;
	objWorkflow = Server.getWorkflowWithId(strWorkflowID);

var objWorkflowProperties;
	objWorkflowProperties = new Properties();
	objWorkflowProperties.put("arrProperties", arrProperties);

var objWorkflowToken;
	objWorkflowToken = objWorkflow.execute(objWorkflowProperties);

Leave a Reply