Template:FAQ:Applications 16

From Net-SNMP Wiki
Revision as of 10:08, 28 May 2009 by Dts12 (Talk | contribs) (Latest FAQ revision - preparing for 5.5 release)

Jump to: navigation, search

Traps and notifications can be sent using the command 'snmptrap'. The following examples generate the generic trap 'warmStart(1)' and a (dummy) enterprise specific trap '99' respectively:

       snmptrap -v 1 -c public localhost "" "" 1 0  ""
       snmptrap -v 1 -c public localhost "" "" 6 99 ""

The empty parameters "" will use suitable defaults for the relevant values (enterprise OID, address of sender and current sysUptime).

An SNMPv2 or SNMPv3 notification (either trap or inform) takes the OID of the trap to send:

       snmptrap -v 2c -c public localhost "" UCD-SNMP-MIB::ucdStart
       snmptrap -v 2c -c public localhost "" .1.3.6.1.4.1.2021.251.1

(These two are equivalent ways of specifying the same trap). Again, the empty parameter "" will use a suitable default for the relevant value (sysUptime).


Any of these commands can be followed by one or more varbinds, using the same (OID/type/value) syntax as for 'snmpset':

       snmptrap -v 2c -c public localhost "" ucdStart sysContact.0 s "Dave"

Generating traps from within the agent, or other applications, is covered in the AGENT and CODING sections.

You should also read the snmptrap tutorial at http://www.net-snmp.org/tutorial-5/commands/snmptrap.html which will help you understand everything you need to know about traps.