|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opennms.test.snmpwalk
This class is designed to provide an example of how to use the JoeSNMP libraries from OpenNMS. This example illustrates the code required to walk an SNMP tree of an individual agent on a remote host.
The class will walk the entire agent tree, or a subsection, as defined by the command line arguments. Through the command line options it is possible to set the community string, timeouts, retries, and other options used by the JoeSNMP library.
Usage: java org.opennms.test.snmpwalk [options] remote-host [object-id]
The command line options are as follows:
-v | 1 || 2 || 2c | Sets the SNMP protocol version. 2 & 2c are identical and stand for SNMPv2 community string based. |
-c | community | Sets the community string used to authenticate |
-r | retries | Sets the number of time the SNMP message is retransmitted before the communication times out. |
-t | timeout (seconds) | Sets the timeout value. Fraction of a second is acceptable, but a millisecond resolution is the smallest supported. For example: .8 is equalivant to 800 milliseconds. |
-p | port | The remote port to communicate with the remote agent on. |
Field Summary | |
(package private) String |
m_community
The community string used to "authenticate" the request. |
(package private) String |
m_host
The remote agent to communicate with. |
(package private) int |
m_port
The port where request are sent & received from. |
(package private) int |
m_retries
The number of retries to use. |
(package private) String |
m_startOid
The default location to start querying the table. |
(package private) SnmpObjectId |
m_stopAt
The object identifier where the walk of the tree should stop. |
(package private) int |
m_timeout
The time period to wait before considering the last transmission a failure. |
(package private) int |
m_version
The version of the SNMP protocol used to communicate |
Constructor Summary | |
snmpwalk()
|
Method Summary | |
static void |
main(String[] args)
The main routine. |
(package private) void |
parseOptions(String[] args)
Parse the command line options. |
void |
snmpInternalError(SnmpSession session,
int err,
SnmpSyntax pdu)
Defined by the SnmpHandler interface. |
void |
snmpReceivedPdu(SnmpSession session,
int cmd,
SnmpPduPacket pdu)
This method is defined by the SnmpHandler interface and invoked when the agent responds to the management application. |
void |
snmpTimeoutError(SnmpSession session,
SnmpSyntax pdu)
This method is define by the SnmpHandler interface and invoked if an agent fails to respond. |
Methods inherited from class java.lang.Object |
|
Field Detail |
int m_version
String m_community
int m_retries
int m_timeout
int m_port
String m_host
String m_startOid
SnmpObjectId m_stopAt
Constructor Detail |
public snmpwalk()
Method Detail |
void parseOptions(String[] args) throws IllegalArgumentException
Parse the command line options. If there is an illegal option then an exception is thrown.
The command line options are as follows:
-v | 1 || 2 || 2c | Sets the SNMP protocol version. 2 & 2c are identical and stand for SNMPv2 community string based. |
-c | community | Sets the community string used to authenticate |
-r | retries | Sets the number of time the SNMP message is retransmitted before the communication times out. |
-t | timeout (seconds) | Sets the timeout value. Fraction of a second is acceptable, but a millisecond resolution is the smallest supported. For example: .8 is equalivant to 800 milliseconds. |
-p | port | The remote port to communicate with the remote agent on. |
public void snmpInternalError(SnmpSession session, int err, SnmpSyntax pdu)
snmpInternalError
in interface SnmpHandler
session
- The SNMP session in error.err
- The Error conditionpdu
- The pdu associated with this error conditionpublic void snmpTimeoutError(SnmpSession session, SnmpSyntax pdu)
snmpTimeoutError
in interface SnmpHandler
session
- The SNMP session in error.pdu
- The PDU that timedout.public void snmpReceivedPdu(SnmpSession session, int cmd, SnmpPduPacket pdu)
snmpReceivedPdu
in interface SnmpHandler
session
- The session receiving the pdu.cmd
- The command from the pdu.pdu
- The received pdu.SnmpPduPacket.getCommand()
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |