Difference between revisions of "Template:FAQ:Applications 16"

From Net-SNMP Wiki
Jump to: navigation, search
(Latest FAQ revision - preparing for 5.5 release)
(link to new tutorial)
 
Line 28: Line 28:
 
in the [[FAQ:Agent|AGENT]] and [[FAQ:Coding|CODING sections]].
 
in the [[FAQ:Agent|AGENT]] and [[FAQ:Coding|CODING sections]].
  
You should also read the snmptrap tutorial at http://www.net-snmp.org/tutorial-5/commands/snmptrap.html
+
You should also read the snmptrap tutorial at [[TUT:snmptrap]]
 
which will help you understand everything you need to know about traps.
 
which will help you understand everything you need to know about traps.

Latest revision as of 21:41, 15 February 2011

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 TUT:snmptrap which will help you understand everything you need to know about traps.