SNMP Ping to Device

Hello,

I want to check if Device is available for SNMP v2/v3 communication. I devised such flow based on some valid generic oid under SNMP GET request.

Device is considered unavailable if no result is returned:

  • not reachable for SNMP call in timeout period (network issue or even device is not pingable);
  • SNMP communication is turned off on the device;
  • using SNMP port is not correct;
  • using SNMP credentials are not correct;

Device is considered available if any SNMP result is returned:

  • real value for provided oid;
  • info that current oid is missed on the device (always returns “noSuchObject” or similar as value for provided oid);

Does SNMP4J has any equivalent of mine SNMP ping above from the box?

Regards.

For SNMPv3 you could use [Snmp.discoverEngineID](https://agentpp.com/doc/snmp4j/org.snmp4j/org/snmp4j/Snmp.html#discoverAuthoritativeEngineID(A,long)).
Instead of a GET request where exceptions like noSuchObject can occur with SNMPv2c and v3, you can use GETNEXT which must not return such an error in any case. Of course such a GETNEXT, causes higher CPU load on the target.