Function: Listen for SNMP Device Traps

by Simon Sparks · 18 September 2021

To use this function add it to the class library file named OrchestratorService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: OrchestratorService.ts

Function SNMPSnmpResultProcess

Description: Orchestrator Function to Proccess SNMP Device Traps

public SNMPSnmpResultProcess(objSNMPSnmpResult: SNMPSnmpResult): Properties[] {
 
    let arrProperties: Properties[] = [];

    if (objSNMPSnmpResult.type == "Array") {
        let arrArrayValue: SNMPSnmpResult[] = objSNMPSnmpResult.arrayValue;

        arrArrayValue.forEach((objArrayValue: SNMPSnmpResult): void => {

            let objProperties: Properties = new Properties();
            objProperties.put("oid", objArrayValue.oid);
            objProperties.put("type", objArrayValue.type);
            objProperties.put("snmpType", objArrayValue.snmpType);
            objProperties.put("value", objArrayValue.stringValue);

            arrProperties.push(objProperties);

        });
    }
    else if (objSNMPSnmpResult.type == "String") {

        let objProperties: Properties = 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);

    }
    else if (objSNMPSnmpResult.type == "Number") {

        let objProperties: Properties = new Properties();
        objProperties.put("oid", objSNMPSnmpResult.oid);
        objProperties.put("type", objSNMPSnmpResult.type);
        objProperties.put("snmpType", objSNMPSnmpResult.snmpType);
        objProperties.put("value", objSNMPSnmpResult.numberValue);

        arrProperties.push(objProperties);

    }

    return arrProperties;
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like