Package org.opennms.netmgt.snmp.snmp4j
Class Snmp4JStrategy
- java.lang.Object
-
- org.opennms.netmgt.snmp.snmp4j.Snmp4JStrategy
-
- All Implemented Interfaces:
SnmpStrategy
public class Snmp4JStrategy extends Object implements SnmpStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSnmp4JStrategy.RegistrationInfo
-
Constructor Summary
Constructors Constructor Description Snmp4JStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SnmpAgentConfigbuildAgentConfig(String address, int port, int timeout, int retries, int securityLevel, String securityName, String authPassPhrase, String authProtocol, String privPassPhrase, String privProtocol, org.snmp4j.PDU pdu)protected SnmpAgentConfigbuildAgentConfig(String address, int port, int timeout, int retries, String community, org.snmp4j.PDU pdu)protected SnmpAgentConfigbuildAgentConfig(String address, int port, int securityLevel, String securityName, String authPassPhrase, String authProtocol, String privPassPhrase, String privProtocol, org.snmp4j.PDU pdu)protected SnmpAgentConfigbuildAgentConfig(String address, int port, String community, org.snmp4j.PDU pdu)protected static org.snmp4j.PDUbuildPdu(Snmp4JAgentConfig agentConfig, int pduType, SnmpObjId[] oids, SnmpValue[] values)voidclearUsers()static org.snmp4j.smi.OctetStringcreateLocalEngineId()static org.snmp4j.smi.OctetStringcreatePersistentInstanceId()SnmpWalkercreateWalker(SnmpAgentConfig snmpAgentConfig, String name, CollectionTracker tracker)SNMP4J createWalker implementation.SnmpValueget(SnmpAgentConfig agentConfig, SnmpObjId oid)SNMP4J get helper that takes a single SnmpObjId and calls get with an array.lenght =1 and returns the first element of the returned array of SnmpValue.SnmpValue[]get(SnmpAgentConfig agentConfig, SnmpObjId[] oids)SnmpGet implementation.CompletableFuture<SnmpValue[]>getAsync(SnmpAgentConfig agentConfig, SnmpObjId[] oids)SnmpValue[]getBulk(SnmpAgentConfig agentConfig, SnmpObjId[] oid)Not yet implemented.byte[]getLocalEngineID()SnmpValuegetNext(SnmpAgentConfig agentConfig, SnmpObjId oid)SNMP4J getNext implementationSnmpValue[]getNext(SnmpAgentConfig agentConfig, SnmpObjId[] oids)SNMP GetNext implementation.SnmpV1TrapBuildergetV1TrapBuilder()SnmpV2TrapBuildergetV2InformBuilder()SnmpTrapBuildergetV2TrapBuilder()SnmpV3TrapBuildergetV3InformBuilder()SnmpV3TrapBuildergetV3TrapBuilder()SnmpValueFactorygetValueFactory()static voidreapSession(org.snmp4j.Snmp session)voidregisterForTraps(TrapNotificationListener listener, int snmpTrapPort)voidregisterForTraps(TrapNotificationListener listener, InetAddress address, int snmpTrapPort)voidregisterForTraps(TrapNotificationListener listener, InetAddress address, int snmpTrapPort, List<SnmpV3User> snmpUsers)protected SnmpValue[]send(Snmp4JAgentConfig agentConfig, org.snmp4j.PDU pdu, boolean expectResponse)Sends and SNMP4J request PDU.voidsendTest(String agentAddress, int port, String community, org.snmp4j.PDU pdu)SnmpValue[]set(SnmpAgentConfig agentConfig, SnmpObjId[] oids, SnmpValue[] values)SnmpValueset(SnmpAgentConfig agentConfig, SnmpObjId oid, SnmpValue value)static voidtrackSession(org.snmp4j.Snmp session)voidunregisterForTraps(TrapNotificationListener listener)
-
-
-
Method Detail
-
clearUsers
public void clearUsers()
-
createWalker
public SnmpWalker createWalker(SnmpAgentConfig snmpAgentConfig, String name, CollectionTracker tracker)
SNMP4J createWalker implementation.- Specified by:
createWalkerin interfaceSnmpStrategy- Parameters:
snmpAgentConfig-name-tracker-
-
getBulk
public SnmpValue[] getBulk(SnmpAgentConfig agentConfig, SnmpObjId[] oid)
Not yet implemented. Use a walker.- Specified by:
getBulkin interfaceSnmpStrategy
-
set
public SnmpValue set(SnmpAgentConfig agentConfig, SnmpObjId oid, SnmpValue value)
- Specified by:
setin interfaceSnmpStrategy
-
set
public SnmpValue[] set(SnmpAgentConfig agentConfig, SnmpObjId[] oids, SnmpValue[] values)
- Specified by:
setin interfaceSnmpStrategy
-
get
public SnmpValue get(SnmpAgentConfig agentConfig, SnmpObjId oid)
SNMP4J get helper that takes a single SnmpObjId and calls get with an array.lenght =1 and returns the first element of the returned array of SnmpValue.- Specified by:
getin interfaceSnmpStrategy- Parameters:
agentConfig-oid-
-
get
public SnmpValue[] get(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SnmpGet implementation.- Specified by:
getin interfaceSnmpStrategy- Parameters:
agentConfig-oids-- Returns:
- Returns an array of Snmp4JValues. If the get was unsuccessful, then the first elment of the array will be null and lenth of 1.
-
getAsync
public CompletableFuture<SnmpValue[]> getAsync(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
- Specified by:
getAsyncin interfaceSnmpStrategy
-
getNext
public SnmpValue getNext(SnmpAgentConfig agentConfig, SnmpObjId oid)
SNMP4J getNext implementation- Specified by:
getNextin interfaceSnmpStrategy- Parameters:
agentConfig-oid-
-
getNext
public SnmpValue[] getNext(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SNMP GetNext implementation.- Specified by:
getNextin interfaceSnmpStrategy- Parameters:
agentConfig-oids-- Returns:
- Returns an array of Snmp4JValues. If the getNext was unsuccessful, then the first element of the array will be null and length of 1.
-
send
protected SnmpValue[] send(Snmp4JAgentConfig agentConfig, org.snmp4j.PDU pdu, boolean expectResponse)
Sends and SNMP4J request PDU. The attributes in SnmpAgentConfig should have been adapted from default SnmpAgentConfig values to those compatible with the SNMP4J library.
-
buildPdu
protected static org.snmp4j.PDU buildPdu(Snmp4JAgentConfig agentConfig, int pduType, SnmpObjId[] oids, SnmpValue[] values)
-
getValueFactory
public SnmpValueFactory getValueFactory()
- Specified by:
getValueFactoryin interfaceSnmpStrategy
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, InetAddress address, int snmpTrapPort, List<SnmpV3User> snmpUsers) throws IOException
- Specified by:
registerForTrapsin interfaceSnmpStrategy- Throws:
IOException
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, InetAddress address, int snmpTrapPort) throws IOException
- Specified by:
registerForTrapsin interfaceSnmpStrategy- Throws:
IOException
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, int snmpTrapPort) throws IOException
- Specified by:
registerForTrapsin interfaceSnmpStrategy- Throws:
IOException
-
unregisterForTraps
public void unregisterForTraps(TrapNotificationListener listener) throws IOException
- Specified by:
unregisterForTrapsin interfaceSnmpStrategy- Throws:
IOException
-
getV1TrapBuilder
public SnmpV1TrapBuilder getV1TrapBuilder()
- Specified by:
getV1TrapBuilderin interfaceSnmpStrategy
-
getV2TrapBuilder
public SnmpTrapBuilder getV2TrapBuilder()
- Specified by:
getV2TrapBuilderin interfaceSnmpStrategy
-
getV3TrapBuilder
public SnmpV3TrapBuilder getV3TrapBuilder()
- Specified by:
getV3TrapBuilderin interfaceSnmpStrategy
-
getV2InformBuilder
public SnmpV2TrapBuilder getV2InformBuilder()
- Specified by:
getV2InformBuilderin interfaceSnmpStrategy
-
getV3InformBuilder
public SnmpV3TrapBuilder getV3InformBuilder()
- Specified by:
getV3InformBuilderin interfaceSnmpStrategy
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(String address, int port, String community, org.snmp4j.PDU pdu) throws UnknownHostException
- Throws:
UnknownHostException
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(String address, int port, int timeout, int retries, String community, org.snmp4j.PDU pdu) throws UnknownHostException
- Throws:
UnknownHostException
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(String address, int port, int securityLevel, String securityName, String authPassPhrase, String authProtocol, String privPassPhrase, String privProtocol, org.snmp4j.PDU pdu) throws UnknownHostException, Exception
- Throws:
UnknownHostExceptionException
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(String address, int port, int timeout, int retries, int securityLevel, String securityName, String authPassPhrase, String authProtocol, String privPassPhrase, String privProtocol, org.snmp4j.PDU pdu) throws UnknownHostException, Exception
- Throws:
UnknownHostExceptionException
-
createPersistentInstanceId
public static org.snmp4j.smi.OctetString createPersistentInstanceId()
-
createLocalEngineId
public static org.snmp4j.smi.OctetString createLocalEngineId()
-
getLocalEngineID
public byte[] getLocalEngineID()
- Specified by:
getLocalEngineIDin interfaceSnmpStrategy
-
trackSession
public static void trackSession(org.snmp4j.Snmp session)
-
reapSession
public static void reapSession(org.snmp4j.Snmp session)
-
-