I have to check if snmp v3 is available on the device being managed via snmp4j. If not, I have to use snmp v2c. But how do I check the availability via snmp4j? Is there a finished method or standard way of doing it?
I thought of something like:
private Target getTarget()
{
Address targetAddress = GenericAddress.parse(ip);
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString(community));
target.setAddress(targetAddress);
target.setRetries(2);
target.setTimeout(1000);
//Check here (with if)
if(snmpv3_is_available)
target.setVersion(SnmpConstants.version3);
else
target.setVersion(SnmpConstants.version2c);
return target;
}
Hopefully someone knows an answer!
For each known IP address, you can send the SNMP v3 discovery message (it supports GET/GET-BULK and so on),
https://docs.lextudio.com/sharpsnmplib/tutorials/device-discovery.html
SNMP v3 enabled entities must respond to that according to the standard.
So for snmp4j, you should see if there is just a method to do so.