Store data from multiple table

Hi Frank,

Thanks for your guidence. Context works with v2 as well.

– Anirban

Hi Frank,

Reviving an old thread. I think there is a bug regarding “Context” implementation of latest 2.7.8 Snmp4j agents.

Your “3.6.x” Snmp4j agent version has following code

public Context next() {
curContext = iterator.next();
return curContext;
}
for the following class ContextInfo implements Iterator<Context>

But the latest “2.7.8” Snmp4j agent version has following code

public Object next() {
curContext = (OctetString) iterator.next();
return curContext;
}
This throws ClassCastException and makes 2.x with Java 8 unusable with the context use case.
Is it possible to fix it, otherwise I need to move my entire application to java 9+ which would be a pain.

–Anirban

Hi Anirban,

Thanks for reporting this bug. It has been fixed with the following snapshot and will be released with version 2.7.9 of SNMP4J-Agent soon:
https://snmp.app/dist/snapshot/org/snmp4j/snmp4j-agent/2.7.9-SNAPSHOT/snmp4j-agent-2.7.9-20230205.215859-2.jar

Best regards,
Frank

Thanks for Publishing 2.7.9 Agent so fast .

Hi Frank,

There is serious bug in SNMP4J Agent 2.7.9 regarding contexts.
Data from multiple contexts is over written arbitrarily.

Can you please have a look at that?

–Anirban

What do you mean by that statement? What data is overwritten when and by what other data?
Are you talking about runtime or persistent data?

Hi Frank,

I observed, in your Sample Agent, the getVariable method has the following code snippet

OctetString context = null;
        int pos = name.indexOf(':');
        if (pos >= 0) {
            context = new OctetString(name.substring(0, pos));
            oid = new OID(name.substring(pos + 1));
        } else {
            oid = new OID(name);
        }

Does this mean, for every context you need a different engine id?

–Anirban

Yes, each context need a so called contextEngineId in addition to the context name.
However, the getVariable method in the sample agent uses a simplified approach for illustration. It is not meant/usable as an API.

HI Frank,

Thanks for your reply. However I have few more questions.

  1. What is the behaviour if I dont supply contextEngineId?
  2. Is this the same engineId which is configured in SNMP managers? Is this the engine id which is returned during engind id discovery?
  3. What issue we may face if the context engine id is same for all contexts?’

–Anirban

Hi Anirban,

  1. SNMP4J will fill in the discovered authoritative engine ID into the ScopedPDU as contextEngineID before sending it.
  2. No/no. The contextEgineID is completely independent to the authoritative engine ID.
  3. If all contexts (names) live within the same contextEngineID, then there is only a single SNMP engine supporting many contexts. Otherwise, there could be several context engines supporting 1-n contexts.

Understood.

I must appreciate the way your supporting lot us. I never any question unanswered. Thanks for that.