README

AdventNet SNMP API 4

<AdventNet/SNMPAPI/examples/applications>

Release 4.0.5

This directory contains examples of using the new high-level Adventnet SNMP APIs. The new APIs simplify the programmers' job, in addition to supporting the JDK 1.1 event model and Java beans. See the setenv.bat file for help on setting up your environment to run the examples. Command line examples are given below. For using v3 features, the values for the command-line params are as follows.
-u : The principal or user name on whose behalf the request is to be sent. 
-a : This is the authentication method to be used. The values are MD5 for the HMAC-MD5 authentication SHA for the HMAC-SHA authentication 
-pp : privProtocol(DES/AES-128/AES-192/AES-256/3DES)
-w
: The password used for authentication. This is the non-localized password. 
-s : The password used for encryption or privacy. This is the again the non-localized password. 
-i : The context Name to be used for the pdu. 

Please note that the requests could fail, if sent with any other security parameters apart from the ones configured on the agent. Moreover, the authentication scheme (-a) must be provided when the auth password(-w) is specified. All the v3 examples provided below use the case of a user initial, using MD5 authentication and authentication passphrase of initialPass. 

Bundled Examples
1. snmpget.java - Get one or more SNMP variables.

Usage
java snmpget [-v version(v1,v2)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d] host OID [OID] ... 
Example
java snmpget -m "../../mibs/RFC1213-mib" 10.3.2.120 ifType.2 ifDescr.2 
java snmpget -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 ifType.2 ifDescr.2 

2. snmpgetnext.java - Perform a getnext on one or more SNMP variables.

Usage
java snmpgetnext [-v version(v1,v2)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d] host OID [OID] ... 
Example
java snmpgetnext -m "../../mibs/RFC1213-mib" 10.3.2.120 ipRouteDest ipRouteNextHop 
java snmpgetnext -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 ipRouteDest ipRouteNextHop 

3. snmpgetbulk.java - Get SNMP variables in bulk.

Usage
java snmpgetbulk [-v version(v2,v3)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-nr non-repeaters] [-mr max-repetitions] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d] host OID [OID] ... 
Example
java snmpgetbulk -m "../../mibs/RFC1213-mib" -nr 0 -mr 50 10.3.2.120 ifType.2 ifDescr.2 
java snmpgetbulk -v v3 -nr 0 -mr 50 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" localhost 10.3.2.120 ifType.2 ifDescr.2 

4. snmpset.java - Perform an SNMP set on one or more SNMP variables.

Usage
java snmpset [-c community] [-p port] [-t timeout] [-r retries] [-v version(v1,v2,v3)] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] -m MIB_files host [OID value] ... 
Example
java snmpset -m "../../mibs/RFC1213-mib" 10.3.2.120 sysLocation.0 paradise sysName.0 whatever 
java snmpset -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 sysLocation.0 paradise sysName.0 whatever 

5. snmpset_without_mib.java - Perform an SNMP set on one or more SNMP variables without the loading of MIBs.

Usage
java snmpset_without_mib [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d debug] host OID {INTEGER | STRING | GAUGE | TIMETICKS | OPAQUE | IPADDRESS | COUNTER | OID } value [OID type value] 
Example
java snmpset_without_mib -v v2 10.3.2.120 1.5.0 STRING whatever 1.6.0 STRING here 
java snmpset -v v3 -u initial -w initialPass -a MD5 10.3.2.120 1.6.0 paradise 1.5.0 whatever 

6. snmpwalk.java - Perform an SNMP walk with one or more OIDs.

Usage
java snmpwalk [-v version(v1,v2,v3)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] host OID [OID] ... 
Example
java snmpwalk -m "../../mibs/RFC1213-mib" 10.3.2.120 interfaces 
java snmpwalk -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 interfaces 

7. sendtrap.java - Send SNMP v1 traps using the high-level APIs.

Usage
java sendtrap [-c community] [-m MIB_files] [-p port] \nhost enterprise agent-addr generic-trap specific-trap timeticks \n[OID value] ... 
Example
java sendtrap -m "../../mibs/RFC1213-mib" 10.3.2.121 snmp 10.2.2.120 3 0 1001 ifIndex.2 2

8. sendv2trap.java - Send SNMP v2c and v3 traps using the high-level APIs.

Usage
java sendv2trap [-d Debug] [-v version(v2,v3)] [-c community] [-p port] [-e engineID(0x...)] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-i contextName] -m MIB_file host timeticksvalue trapOID [ OID value ] ... 
Example
java sendv2trap -m "../../mibs/RFC1213-MIB" -v v3 -p 2000 -e 0x12345 -u testuser -a MD5 -w pass localhost 10000 .1.3.6.1.2.4.1.11 1.5.0 snmp 

9. sendinform.java - Send SNMP inform messages using the high-level APIs.

Usage
java sendinform [-d Debug] [-v version(v2,v3)] [-c community] [-p port] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-i contextName] -m MIB_file host timeticksvalue trapOID [ OID value ] ... 
Example
java sendinform -m "../../mibs/RFC1213-MIB" -v v3 -p 2000 -a MD5 -w pass localhost 10000 .1.3.6.1.4.1.11 1.5.0 snmp 

10. trapreceiver.java - Receive and print SNMP traps.

Usage
java trapreceiver [-v version(v1,v2)] [-m MIB_files] [-c community] [-p port] 
Example
java trapreceiver -m "../../mibs/RFC1213-mib" -p 162 

11. snmpinformreq_receiver.java - Receive and print SNMP INFORM requests.

Usage
java snmpinformreq_receiver [-m MIB_files] [-c community] [-p port] [-u user] [-e engineID] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] 
Example
java snmpinformreq_receiver -m "../../mibs/RFC1213-MIB" -p 2000 

12. getSnmpTable.java - Get an SNMP table row by row using the API's SnmpTable class.

Usage
java getSnmpTable [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextname] [-i contextID] [-d debug] host tableOID MIB_files 
Example
java getSnmpTable -v v2 -m "../../mibs/RFC1213-mib" 10.3.2.120 ipRouteTable 
java getSnmpTable -v v3 -u initial -w initialPass -a MD5 10.3.2.120 ipRouteTable ../../mibs/RFC1213-MIB

13. gettable.java - Get and print an SNMP table.

Usage
java gettable [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextName] [-i contextID] [-d debug] host tableOID MIB_files 
Example
java gettable -m "../../mibs/RFC1213-mib" 10.3.2.120 ifTable 
java gettable -v v3 -u initial -w initialPass -a MD5 10.3.2.120 ifTable ../../mibs/RFC1213-MIB 

14.  walk_indexes.java - Get one or more SNMP variables.

Usage
java walk_indexes [-v version(v1,v2,v3)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d] host OID 
Example
java walk_indexes -v v2 -m "../../mibs/RFC1213-mib" 10.3.2.120 tcpConnLocalAddress 
java walk_indexes -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 tcpConnLocalPort 

15. snmpget_by_index.java - Get one or more SNMP variables.

Usage
java snmpget_by_index [-v version(v1,v2,v3)] [-m MIB_files] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d] host OID index [index] ... 
Example
java snmpget_by_index -v v2 -m "../../mibs/RFC1213-mib" 10.3.2.120 atIfIndex 2 128.253.154.1 
java snmpget_by_index -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 atPhysAddrress 2 128.253.154.1 
java snmpget_by_index -v v3 -u initial -w initialPass -a MD5 -m "../../mibs/RFC1213-mib" 10.3.2.120 ifDescr 2 

16. snmpaddrow.java - Add a row to the table.

Usage
java snmpaddrow [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d debug] host MIB_files OID value [OID value] ... 
Example
java snmpaddrow localhost "../../mibs/agent-sample-mib.txt" managerHost.5 local managerPort.5 2000 rowStatus.5 4-p 8001 

17. snmpdelrow.java - Delete a row to the table.

Usage
java snmpdelrow [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-d debug] host MIB_files rowStatusOID.index 
Example
java snmpdelrow localhost -p 8001 "../../mibs/agent-sample-mib.txt" rowStatus.5 

18. setTableValue.java - Set the value of a particular cell of the table.

Usage
java setTableValue [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextname] [-i contextID] [-d debug] host MIB_files tableOID value rowIndex columnIndex 
Example
java setTableValue localhost ../../mibs/agent-sample-mib.txt forwardingTable value 0 1 -p 8001 

19. encodeTableIndex.java - Get all the column oids of the table with appended index (instance) values with it. This example will encode the index if it is in type like octetstring . 

Usage
java encodeTableIndex tableOID MIB-File index [indices..] 
Example
java encodeTableIndex atTable ../../mibs/RFC1213-MIB 1 192.168.1.45 

20. getColumn.java - Get a column from the table.

Usage
java getColumn [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextname] [-i contextID] [-d debug] host MIB_files columnName 
Example
java getColumn localhost ../../mibs/RFC1213-MIB ifType 

21. getRow.java - Get a row from the table.

Usage
java getRow [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol(MD5/SHA)] [-w auth_password] 
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextname] [-i contextID] [-d debug] host tableOID MIB_files rowIndex 
Example
java getRow localhost ifTable ../../mibs/RFC1213-MIB 1 

22. getTableInfo.java - Get the information about the table.

Usage
java getTableInfo ColumnOID MIB_FILE 
Example
java getTableInfo ifType ../../mibs/RFC1213-MIB

23. requestServerDemo.java - Perform asynchronous requests by using SnmpRequestServer. Edit the requestServerDemo.html file to put in the correct host and community.

Usage
appletviewer requestServerDemo.html 
Note
For jdk1.2 the classpath should be specified in the command line as follows. 
appletviewer -J-Xbootclasspath:applications.jar;.\..\jars\AdventNetLogging.jar;..\..\jars\AdventNetSnmp.jar;<JDK_HOME>\jre\lib\rt.jar requestServerDemo.html 
In addition, the HTML file should also be customized. Refer Help documentation for details. 

24. snmpPollerDemo.java - Perform automatic polling of SNMP variables by using SnmpPoller. Edit the snmpPollerDemo.html file to put in the correct host and community.

Usage
appletviewer snmpPollerDemo.html 
Note
For jdk1.2 the classpath should be specified in the command line as follows:
appletviewer -J-Xbootclasspath:applications.jar;.\..\jars\AdventNetLogging.jar;..\..\jars\AdventNetSnmp.jar;<JDK_HOME>\jre\lib\rt.jar snmpPollerDemo.html 
In addition, the html file should also be customized. Refer Help documentation for details. 

25. getSnmpAugmentTable.java - Get an SNMP Augment table row by row using the API's SnmpAugmentTable class.

Usage
java getSnmpAugmentTable [-v version(v1,v2,v3)] [-c community] [-p port] [-t timeout] [-r retries] [-u user] [-a auth_protocol] [-w auth_password]
[-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-n contextname] [-i contextID] [-d debug] host tableOID MIB_files 
Example
java getSnmpAugmentTable -v v2 -m "../../mibs/IF-MIB" 10.3.2.120 ifXTable 
java getSnmpAugmentTable -v v3 -u initial -w initialPass -a MD5 10.3.2.120 ifXTable ../../mibs/IF-MIB

Support

Feedback

For those with support contracts, AdventNet provides priority support through email with a reply usually provided within 24 hours.

While sending your support questions or bug report, please specify the SNMP package release version, the JDK version , the platform, and the browser you use .

Send your support queries to: snmp-support@adventnet.com

We welcome your feedback that will help us improve the APIs and provide future enhancements.

Send in your feedback to: snmp-support@adventnet.com

 

Copyright and License

Please refer COPYRIGHT and LICENSE before using the package.

AdventNet, Inc.
Web : http://www.adventnet.com
Email: info@adventnet.com