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 java.lang.Object implements SnmpStrategy
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Snmp4JStrategy.RegistrationInfo
-
Constructor Summary
Constructors Constructor Description Snmp4JStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SnmpAgentConfig
buildAgentConfig(java.lang.String address, int port, int timeout, int retries, int securityLevel, java.lang.String securityName, java.lang.String authPassPhrase, java.lang.String authProtocol, java.lang.String privPassPhrase, java.lang.String privProtocol, org.snmp4j.PDU pdu)
protected SnmpAgentConfig
buildAgentConfig(java.lang.String address, int port, int timeout, int retries, java.lang.String community, org.snmp4j.PDU pdu)
protected SnmpAgentConfig
buildAgentConfig(java.lang.String address, int port, int securityLevel, java.lang.String securityName, java.lang.String authPassPhrase, java.lang.String authProtocol, java.lang.String privPassPhrase, java.lang.String privProtocol, org.snmp4j.PDU pdu)
protected SnmpAgentConfig
buildAgentConfig(java.lang.String address, int port, java.lang.String community, org.snmp4j.PDU pdu)
protected static org.snmp4j.PDU
buildPdu(Snmp4JAgentConfig agentConfig, int pduType, SnmpObjId[] oids, SnmpValue[] values)
void
clearUsers()
static org.snmp4j.smi.OctetString
createLocalEngineId()
static org.snmp4j.smi.OctetString
createPersistentInstanceId()
SnmpWalker
createWalker(SnmpAgentConfig snmpAgentConfig, java.lang.String name, CollectionTracker tracker)
SNMP4J createWalker implementation.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.SnmpValue[]
get(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SnmpGet implementation.java.util.concurrent.CompletableFuture<SnmpValue[]>
getAsync(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SnmpValue[]
getBulk(SnmpAgentConfig agentConfig, SnmpObjId[] oid)
Not yet implemented.byte[]
getLocalEngineID()
SnmpValue
getNext(SnmpAgentConfig agentConfig, SnmpObjId oid)
SNMP4J getNext implementationSnmpValue[]
getNext(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SNMP GetNext implementation.SnmpV1TrapBuilder
getV1TrapBuilder()
SnmpV2TrapBuilder
getV2InformBuilder()
SnmpTrapBuilder
getV2TrapBuilder()
SnmpV3TrapBuilder
getV3InformBuilder()
SnmpV3TrapBuilder
getV3TrapBuilder()
SnmpValueFactory
getValueFactory()
static void
reapSession(org.snmp4j.Snmp session)
void
registerForTraps(TrapNotificationListener listener, int snmpTrapPort)
void
registerForTraps(TrapNotificationListener listener, java.net.InetAddress address, int snmpTrapPort)
void
registerForTraps(TrapNotificationListener listener, java.net.InetAddress address, int snmpTrapPort, java.util.List<SnmpV3User> snmpUsers)
protected SnmpValue[]
send(Snmp4JAgentConfig agentConfig, org.snmp4j.PDU pdu, boolean expectResponse)
Sends and SNMP4J request PDU.void
sendTest(java.lang.String agentAddress, int port, java.lang.String community, org.snmp4j.PDU pdu)
SnmpValue[]
set(SnmpAgentConfig agentConfig, SnmpObjId[] oids, SnmpValue[] values)
SnmpValue
set(SnmpAgentConfig agentConfig, SnmpObjId oid, SnmpValue value)
static void
trackSession(org.snmp4j.Snmp session)
void
unregisterForTraps(TrapNotificationListener listener)
-
-
-
Method Detail
-
clearUsers
public void clearUsers()
-
createWalker
public SnmpWalker createWalker(SnmpAgentConfig snmpAgentConfig, java.lang.String name, CollectionTracker tracker)
SNMP4J createWalker implementation.- Specified by:
createWalker
in interfaceSnmpStrategy
- Parameters:
snmpAgentConfig
-name
-tracker
-
-
getBulk
public SnmpValue[] getBulk(SnmpAgentConfig agentConfig, SnmpObjId[] oid)
Not yet implemented. Use a walker.- Specified by:
getBulk
in interfaceSnmpStrategy
-
set
public SnmpValue set(SnmpAgentConfig agentConfig, SnmpObjId oid, SnmpValue value)
- Specified by:
set
in interfaceSnmpStrategy
-
set
public SnmpValue[] set(SnmpAgentConfig agentConfig, SnmpObjId[] oids, SnmpValue[] values)
- Specified by:
set
in 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:
get
in interfaceSnmpStrategy
- Parameters:
agentConfig
-oid
-
-
get
public SnmpValue[] get(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SnmpGet implementation.- Specified by:
get
in 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 java.util.concurrent.CompletableFuture<SnmpValue[]> getAsync(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
- Specified by:
getAsync
in interfaceSnmpStrategy
-
getNext
public SnmpValue getNext(SnmpAgentConfig agentConfig, SnmpObjId oid)
SNMP4J getNext implementation- Specified by:
getNext
in interfaceSnmpStrategy
- Parameters:
agentConfig
-oid
-
-
getNext
public SnmpValue[] getNext(SnmpAgentConfig agentConfig, SnmpObjId[] oids)
SNMP GetNext implementation.- Specified by:
getNext
in 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:
getValueFactory
in interfaceSnmpStrategy
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, java.net.InetAddress address, int snmpTrapPort, java.util.List<SnmpV3User> snmpUsers) throws java.io.IOException
- Specified by:
registerForTraps
in interfaceSnmpStrategy
- Throws:
java.io.IOException
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, java.net.InetAddress address, int snmpTrapPort) throws java.io.IOException
- Specified by:
registerForTraps
in interfaceSnmpStrategy
- Throws:
java.io.IOException
-
registerForTraps
public void registerForTraps(TrapNotificationListener listener, int snmpTrapPort) throws java.io.IOException
- Specified by:
registerForTraps
in interfaceSnmpStrategy
- Throws:
java.io.IOException
-
unregisterForTraps
public void unregisterForTraps(TrapNotificationListener listener) throws java.io.IOException
- Specified by:
unregisterForTraps
in interfaceSnmpStrategy
- Throws:
java.io.IOException
-
getV1TrapBuilder
public SnmpV1TrapBuilder getV1TrapBuilder()
- Specified by:
getV1TrapBuilder
in interfaceSnmpStrategy
-
getV2TrapBuilder
public SnmpTrapBuilder getV2TrapBuilder()
- Specified by:
getV2TrapBuilder
in interfaceSnmpStrategy
-
getV3TrapBuilder
public SnmpV3TrapBuilder getV3TrapBuilder()
- Specified by:
getV3TrapBuilder
in interfaceSnmpStrategy
-
getV2InformBuilder
public SnmpV2TrapBuilder getV2InformBuilder()
- Specified by:
getV2InformBuilder
in interfaceSnmpStrategy
-
getV3InformBuilder
public SnmpV3TrapBuilder getV3InformBuilder()
- Specified by:
getV3InformBuilder
in interfaceSnmpStrategy
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(java.lang.String address, int port, java.lang.String community, org.snmp4j.PDU pdu) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(java.lang.String address, int port, int timeout, int retries, java.lang.String community, org.snmp4j.PDU pdu) throws java.net.UnknownHostException
- Throws:
java.net.UnknownHostException
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(java.lang.String address, int port, int securityLevel, java.lang.String securityName, java.lang.String authPassPhrase, java.lang.String authProtocol, java.lang.String privPassPhrase, java.lang.String privProtocol, org.snmp4j.PDU pdu) throws java.net.UnknownHostException, java.lang.Exception
- Throws:
java.net.UnknownHostException
java.lang.Exception
-
buildAgentConfig
protected SnmpAgentConfig buildAgentConfig(java.lang.String address, int port, int timeout, int retries, int securityLevel, java.lang.String securityName, java.lang.String authPassPhrase, java.lang.String authProtocol, java.lang.String privPassPhrase, java.lang.String privProtocol, org.snmp4j.PDU pdu) throws java.net.UnknownHostException, java.lang.Exception
- Throws:
java.net.UnknownHostException
java.lang.Exception
-
sendTest
public void sendTest(java.lang.String agentAddress, int port, java.lang.String community, org.snmp4j.PDU pdu)
-
createPersistentInstanceId
public static org.snmp4j.smi.OctetString createPersistentInstanceId()
-
createLocalEngineId
public static org.snmp4j.smi.OctetString createLocalEngineId()
-
getLocalEngineID
public byte[] getLocalEngineID()
- Specified by:
getLocalEngineID
in interfaceSnmpStrategy
-
trackSession
public static void trackSession(org.snmp4j.Snmp session)
-
reapSession
public static void reapSession(org.snmp4j.Snmp session)
-
-