0
votes

I have written a SNMP listener in Java using the TNM4J library which uses the SNMP4J library.

The listener is able to read received traps, except for traps that appear to be indexed in a table.

The listener is listening to traps from an Ericsson object, which means I am using the ERICSSON-ALARM-MIB and the MIB imports it needs. The trap I am receiving is the eriAlarmActiveManagedObject with OID .1.3.6.1.4.1.193.183.4.1.3.5.1.5, but I also tested it locally with the other traps in the table and the same error occurs

If one looks at https://mibs.observium.org/mib/ERICSSON-ALARM-MIB/ :

enter image description here

All the traps that are from a table like this can not be read by the listener. It gives an index out of bound exception from a extractIndexes method in MibbleIndexExtractor.java in the TNM4J library.

@Override
public IndexDescriptor[] extractIndexes(String instanceOid) {
    String oid = symbol.getValue().toString();
    String suboid = instanceOid.substring(oid.length() + 1);
    int[] components = oidToArray(suboid);
    int offset = 0;
    IndexDescriptor[] descriptors = new IndexDescriptor[indexes.length];
    for (int i = 0; i < indexes.length; i++) {
        SnmpIndex index = indexes[i];
        MibValueSymbol indexSymbol = symbol.getMib().getSymbolByOid(index.getValue().toString());
        MibType indexType = ((SnmpObjectType) indexSymbol.getType()).getSyntax();
        int length = fixedLength(indexType);
        boolean implied = length != -1 || index.isImplied();
        if (length == -1) {
            length = variableLength(indexType, components, offset, index.isImplied());
        }
        int[] encoded = new int[length];
        System.arraycopy(components, offset, encoded, 0, length);

        descriptors[i] = new MibbleIndexDescriptor(indexSymbol, encoded, implied);
        offset += length;
    }
    return descriptors;
}

I have debugged it and this happens because the oid String and instanceOid String are identical which of course causes an exception where the suboid String is being created.

However on all other traps it never calls this extractIndexes method, but just works finely and prints out the trap and oid name correctly.

Any suggestion on how to fix this issue?

1
github.com/soulwing/tnm4j/issues Ask its developers for help.Lex Li

1 Answers

0
votes

After being in contact with the developer of TNM4J he made some fixes to his library.

After that the Ericsson oids was being correctly translated. There was a few missing translations from oids, which was because of the loading order of the MIBs.

Re-adjusting these made it work.

For anyone interested the troubleshooting process with the developer can view it here: https://github.com/soulwing/tnm4j/issues/9