public class SNMPConnector extends java.lang.Object implements Connector
Modifier and Type | Field and Description |
---|---|
static char |
ADDRESS |
protected java.net.InetAddress |
agentAddress |
protected java.lang.String |
agentName |
static char |
BITSTRING |
protected java.lang.String |
community |
protected org.snmp4j.CommunityTarget |
comTarget |
static char |
COUNTER32 |
static char |
DECIMALSTRING |
protected org.snmp4j.smi.OID |
enterpriseOID |
static char |
HEXSTRING |
protected java.lang.String |
hostIP |
protected java.lang.String |
hostname |
static char |
INTEGER32 |
static char |
NULL |
static char |
OIDSTRING |
protected java.lang.String |
operation |
protected int |
port |
protected int |
retry |
protected org.snmp4j.Snmp |
snmp |
protected long |
startTime |
static char |
STRING |
protected int |
timeout |
static char |
TIMETICKS |
protected org.snmp4j.TransportMapping |
transport |
static char |
UNSIGN32 |
protected java.lang.String |
uri |
Constructor and Description |
---|
SNMPConnector(java.util.Map props)
creates new SNMPConnector
|
Modifier and Type | Method and Description |
---|---|
void |
close()
closes all transports and resources
|
int |
getDefaultVersion() |
org.snmp4j.CommunityTarget |
getTarget(int version,
int retry,
int timeout,
java.lang.String community,
java.lang.String address) |
java.lang.String |
getURI() |
boolean |
isConnected()
returns true since it is connectionless
|
boolean |
isListening() |
static void |
main(java.lang.String[] args) |
java.lang.String[] |
receive() |
java.lang.String[] |
receive(java.net.DatagramPacket p)
receives an SNMP packet and returns the content in array of strings
|
java.lang.String |
reconnect()
reinitializes session
|
void |
sendTrap(org.snmp4j.CommunityTarget target,
java.lang.String ip,
int generic,
int specific,
java.lang.String[][] data)
sends out a trap for multiple oids
|
java.lang.String |
snmpGet(org.snmp4j.CommunityTarget target,
java.lang.String oid)
returns a string of "oid = value" or an error message for failure
|
java.lang.String |
snmpInquire(int version,
java.lang.String community,
java.lang.String address,
java.lang.String oid)
returns a string of "oid = value" for the community and the address
|
void |
snmpNotify(org.snmp4j.CommunityTarget target,
java.lang.String[][] data)
sends a notification for multiple oids
|
void |
snmpNotify(int version,
java.lang.String community,
java.lang.String address,
java.lang.String[][] data)
sends a notification of multiple oids to the address
|
java.lang.String |
snmpSet(org.snmp4j.CommunityTarget target,
java.lang.String[] data)
It sets a value on oid and returns a string of null upon success or
an error message for failure.
|
java.lang.String |
snmpSet(int version,
java.lang.String community,
java.lang.String address,
java.lang.String[] data)
It sets a value on oid and returns a string of null upon success or
an error message for failure.
|
java.lang.String |
snmpSet(java.lang.String oid,
int value) |
void |
snmpTrap(int version,
java.lang.String community,
java.lang.String address,
java.lang.String ip,
int generic,
int specific,
java.lang.String[][] data)
sends out a trap of multiple oids to the address
|
protected java.lang.String hostname
protected java.lang.String hostIP
protected java.net.InetAddress agentAddress
protected java.lang.String community
protected java.lang.String agentName
protected java.lang.String uri
protected java.lang.String operation
protected int port
protected int timeout
protected int retry
protected long startTime
protected org.snmp4j.Snmp snmp
protected org.snmp4j.TransportMapping transport
protected org.snmp4j.CommunityTarget comTarget
protected org.snmp4j.smi.OID enterpriseOID
public static final char INTEGER32
public static final char UNSIGN32
public static final char COUNTER32
public static final char STRING
public static final char HEXSTRING
public static final char DECIMALSTRING
public static final char NULL
public static final char TIMETICKS
public static final char ADDRESS
public static final char BITSTRING
public static final char OIDSTRING
public SNMPConnector(java.util.Map props)
public org.snmp4j.CommunityTarget getTarget(int version, int retry, int timeout, java.lang.String community, java.lang.String address)
public java.lang.String snmpInquire(int version, java.lang.String community, java.lang.String address, java.lang.String oid) throws java.io.IOException
java.io.IOException
public java.lang.String snmpGet(org.snmp4j.CommunityTarget target, java.lang.String oid) throws java.io.IOException
java.io.IOException
public java.lang.String snmpSet(java.lang.String oid, int value) throws java.io.IOException
java.io.IOException
public java.lang.String snmpSet(int version, java.lang.String community, java.lang.String address, java.lang.String[] data) throws java.io.IOException
java.io.IOException
public java.lang.String snmpSet(org.snmp4j.CommunityTarget target, java.lang.String[] data) throws java.io.IOException
java.io.IOException
public void snmpTrap(int version, java.lang.String community, java.lang.String address, java.lang.String ip, int generic, int specific, java.lang.String[][] data) throws java.io.IOException
java.io.IOException
public void sendTrap(org.snmp4j.CommunityTarget target, java.lang.String ip, int generic, int specific, java.lang.String[][] data) throws java.io.IOException
java.io.IOException
public void snmpNotify(int version, java.lang.String community, java.lang.String address, java.lang.String[][] data) throws java.io.IOException
java.io.IOException
public void snmpNotify(org.snmp4j.CommunityTarget target, java.lang.String[][] data) throws java.io.IOException
java.io.IOException
public java.lang.String[] receive() throws java.io.IOException
java.io.IOException
public java.lang.String[] receive(java.net.DatagramPacket p) throws java.io.IOException
java.io.IOException
public int getDefaultVersion()
public boolean isListening()
public boolean isConnected()
isConnected
in interface Connector
public java.lang.String reconnect()
public void close()
public static void main(java.lang.String[] args)