Search in sources :

Example 1 with Snmp4JV1TrapInformation

use of org.opennms.netmgt.snmp.snmp4j.Snmp4JTrapNotifier.Snmp4JV1TrapInformation in project opennms by OpenNMS.

the class TrapUtils method getTrapData.

/**
     * Gets the trap identity.
     *
     * @param trapNotification the trap notification
     * @return the identity
     */
public static TrapData getTrapData(TrapInformation trapNotification) {
    if (trapNotification instanceof Snmp4JV1TrapInformation) {
        Snmp4JV1TrapInformation info = (Snmp4JV1TrapInformation) trapNotification;
        TrapIdentity identity = info.getTrapIdentity();
        TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
        for (int i = 0; i < info.getPduLength(); i++) {
            VariableBinding v = info.getVarBindAt(i);
            SnmpValue value = new Snmp4JValue(v.getVariable());
            data.addParameter("." + v.getOid().toString(), value.toDisplayString());
        }
        return data;
    } else if (trapNotification instanceof Snmp4JV2TrapInformation) {
        Snmp4JV2TrapInformation info = (Snmp4JV2TrapInformation) trapNotification;
        TrapIdentity identity = info.getTrapIdentity();
        TrapData data = new TrapData(identity.getEnterpriseId(), identity.getGeneric(), identity.getSpecific());
        for (int i = 0; i < info.getPduLength(); i++) {
            VariableBinding v = info.getVarBindAt(i);
            SnmpValue value = new Snmp4JValue(v.getVariable());
            data.addParameter("." + v.getOid().toString(), value.toDisplayString());
        }
        return data;
    }
    return null;
}
Also used : Snmp4JV2TrapInformation(org.opennms.netmgt.snmp.snmp4j.Snmp4JTrapNotifier.Snmp4JV2TrapInformation) TrapIdentity(org.opennms.netmgt.snmp.TrapIdentity) SnmpValue(org.opennms.netmgt.snmp.SnmpValue) Snmp4JV1TrapInformation(org.opennms.netmgt.snmp.snmp4j.Snmp4JTrapNotifier.Snmp4JV1TrapInformation) VariableBinding(org.snmp4j.smi.VariableBinding) TrapData(org.opennms.netmgt.alarmd.northbounder.snmptrap.TrapData)

Aggregations

TrapData (org.opennms.netmgt.alarmd.northbounder.snmptrap.TrapData)1 SnmpValue (org.opennms.netmgt.snmp.SnmpValue)1 TrapIdentity (org.opennms.netmgt.snmp.TrapIdentity)1 Snmp4JV1TrapInformation (org.opennms.netmgt.snmp.snmp4j.Snmp4JTrapNotifier.Snmp4JV1TrapInformation)1 Snmp4JV2TrapInformation (org.opennms.netmgt.snmp.snmp4j.Snmp4JTrapNotifier.Snmp4JV2TrapInformation)1 VariableBinding (org.snmp4j.smi.VariableBinding)1