|
Traps are unsolicited messages sent by the agent to the management stations to report the conditions of the managed node. The sendv2trap example can be used to send v2c and v3 traps. SNMP v2c/v3 traps are also called as notifications. SNMP v2 notification is different from the v1 traps with much simplification.
To send the v2c/v3 notification, you need to provide the following values.
remoteHost - the manager station to which the trap message is sent.
timeticks - the time elapsed between the last initialization of the network and the generation of the trap.
trapOID - the trap OID.
MIB file, OID, and value - values for building the varbinds.
Trap messages not containing any varbinds do not need OID and value. The following commands generate a simple v2c/v3 notification.
|
java sendv2trap -m ../../mibs/RFC1213-MIB remotehost 5000 1.5.0 java sendv2trap -p 8001 -m ../../mibs/RFC1213-MIB remotehost 5000 1.2.0 1.5.0 test |
The above command sends a trap to the manager station in the remotehost. A trap receiver program in the manager station can receive and display the traps. By default, the traps are sent to the port 162 of the manager station.
Source
| API Used | Available in |
|---|---|
|
High-evel API |
|
|
Low-level API |
|
|
MIB Support API |
Usage
The usage of the sendv2trap utility is provided below. The "MIB_files", "host", "TimeTicksValue", and "trapOID" arguments are mandatory and the rest are optional.
Usage: java sendv2trap [-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] ...
Usage: java snmpv2ctrap [-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] ...
java snmpv3trap [-d] [-p port] [-e engineID(0x....)] [-a auth_protocol] [-w auth_password] [-pp privProtocol(DES/AES-128/AES-192/AES-256/3DES)] [-s priv_password] [-i context_id] userName host TimeTicksvalue OIDvalue [OID {INTEGER | STRING | GAUGE | TIMETICKS | OPAQUE | IPADDRESS | COUNTER | COUNTER64 | UNSIGNED32} value] ...
Options
[-d] - Debug output. By default, off.
-p] port - Remote port number. By default, 162.
[-e] engineid - Engine ID.
[-a] authprotocol - authProtocol (MD5/SHA). Mandatory if authPassword is specified.
[-w] authpassword - The authentication password.
[-pp] privprotocol (DES/AES-128/AES-192/AES-256/3DES) Mandatory if privpassword is specified.
[-s] privpassword - The privacy protocol password. Must be accomspanied with authpassword and authprotocol fields.
[-n] contextname - The contextName to be used for the v3 PDU.
[-i] contextid - The contextID to be used for the v3 PDU.
username - The v3 principal/userName. Mandatory.
timeticks - The value of object sysUpTime when the event occurred. Mandatory.
OID-value - Object Identifier. Mandatory.
host - Remote host (agent). Mandatory.
OID - Object Identifier. Mandatory.
value - The object instance value to be set. Mandatory.
|