Search in sources :

Example 11 with Varbindsdecode

use of org.opennms.netmgt.xml.eventconf.Varbindsdecode in project opennms by OpenNMS.

the class Mib2Events method getTrapVarbindsDecode.

private static List<Varbindsdecode> getTrapVarbindsDecode(MibValueSymbol trapValueSymbol) {
    Map<String, Varbindsdecode> decode = new LinkedHashMap<String, Varbindsdecode>();
    int vbNum = 1;
    for (MibValue vb : getTrapVars(trapValueSymbol)) {
        String parmName = "parm[#" + vbNum + "]";
        SnmpObjectType snmpObjectType = ((SnmpObjectType) ((ObjectIdentifierValue) vb).getSymbol().getType());
        if (snmpObjectType.getSyntax().getClass().equals(IntegerType.class)) {
            IntegerType integerType = (IntegerType) snmpObjectType.getSyntax();
            if (integerType.getAllSymbols().length > 0) {
                SortedMap<Integer, String> map = new TreeMap<Integer, String>();
                for (MibValueSymbol sym : integerType.getAllSymbols()) {
                    map.put(new Integer(sym.getValue().toString()), sym.getName());
                }
                for (Entry<Integer, String> entry : map.entrySet()) {
                    if (!decode.containsKey(parmName)) {
                        Varbindsdecode newVarbind = new Varbindsdecode();
                        newVarbind.setParmid(parmName);
                        decode.put(newVarbind.getParmid(), newVarbind);
                    }
                    Decode d = new Decode();
                    d.setVarbinddecodedstring(entry.getValue());
                    d.setVarbindvalue(entry.getKey().toString());
                    decode.get(parmName).addDecode(d);
                }
            }
        }
        vbNum++;
    }
    return new ArrayList<Varbindsdecode>(decode.values());
}
Also used : Varbindsdecode(org.opennms.netmgt.xml.eventconf.Varbindsdecode) MibValue(net.percederberg.mibble.MibValue) ArrayList(java.util.ArrayList) Decode(org.opennms.netmgt.xml.eventconf.Decode) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) IntegerType(net.percederberg.mibble.type.IntegerType) SnmpObjectType(net.percederberg.mibble.snmp.SnmpObjectType) MibValueSymbol(net.percederberg.mibble.MibValueSymbol)

Aggregations

Varbindsdecode (org.opennms.netmgt.xml.eventconf.Varbindsdecode)11 ArrayList (java.util.ArrayList)4 Decode (org.opennms.netmgt.xml.eventconf.Decode)4 Event (org.opennms.netmgt.xml.eventconf.Event)4 Test (org.junit.Test)3 File (java.io.File)2 LinkedHashMap (java.util.LinkedHashMap)2 TreeMap (java.util.TreeMap)2 Events (org.opennms.netmgt.xml.eventconf.Events)2 Mask (org.opennms.netmgt.xml.eventconf.Mask)2 Maskelement (org.opennms.netmgt.xml.eventconf.Maskelement)2 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 MibValue (net.percederberg.mibble.MibValue)1 MibValueSymbol (net.percederberg.mibble.MibValueSymbol)1 SnmpObjectType (net.percederberg.mibble.snmp.SnmpObjectType)1 IntegerType (net.percederberg.mibble.type.IntegerType)1