Why do snmp gettable return an empty result?

I can search the result using snmpwalk in NET-SNMP, but when I search the oids using snmp4j,it return []. What’s wrong with it? How to fix it?
The oid is like these,and I’m sure that these oid are in one table.

1 Like

These OID do not belong to existing instances of a standard conforming SNMP agent. They refer to OBJECT-TYPE definitions without instance sub-identifier. Thus, if you do a GET command on these OIDs you will get an exception (v2c,v3) or an error status (v1) with any standard conforming API (like SNMP4J).

A “walk” is typically executed as a series of GETNEXT operations which will “find” instances in the specified OBJECT-TYPE’s OID sub-tree.

So without providing us any background information on how you do your request in detail, we cannot help how to fix that. SNMP4J, is not causing this, that is pretty sure :innocent:

result is null:[{“columns”:[],“error”:true,“errorMessage”:“Request timed out.”,“exception”:null,“index”:null,“reportPDU”:null,“status”:-1,“userObject”:null}]
What’s the meaning of RetrievalEvent.STATUS_WRONG_ORDER?

How can I judge whether these OID belong to existing instances of a standard conforming SNMP agent or not ,please?

I do not get exception but get nothing.
DefaultPDUFactory defaultPDUFactory = defaultPDUFactory = new DefaultPDUFactory(PDU.GETBULK);
if (target instanceof UserTarget) {
OctetString contextEngineId = new OctetString("");
OctetString contextName = new OctetString("");
tableUtils = new TableUtils(snmp, defaultPDUFactory);

The serach code is : List<VariableBinding[]> returnList = new ArrayList<VariableBinding[]>(); OID[] columns = new OID[oids.size()]; for (int i = 0; i < oids.size(); i++) { columns[i] = new OID(oids.get(i)); } List<TableEvent> events = events = tableUtils.getTable(target, columns, null, null); log.info("The event is:"+JSON.toJSONString(events)); //The result is: []

Again, many details are missing from the provided code that might cause the issue:

  • Max repetitions and non-repeaters are not set
  • Port and taget address not given
  • We do not see how the columns are being initialised, i.e. with which values exactly.

The RetrievalEvent.STATUS_WRONG_ORDER means that the agent returns the instances out-of-lexicographic-order. Which means, doing a walk or table retrieval would end in an endless-loop. To avoid that, if a loop is detected, it is stopped with this error.
In this case, the agent is buggy and need to be fixed.

How to set Max repetitions and non-repeaters please ?

From your code initial code snippet I did not recognize that you are using TableUtils. TableUtils is using reasonable defaults for both values: