FAQ:Applications 18

From Net-SNMP Wiki
Jump to: navigation, search

How do I send traps and notifications?

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.

   FAQ:Applications
   
  1. How do I add a MIB?
  2. How do I add a MIB to the tools?
  3. Why can't I see anything from the agent?
  4. Why doesn't the agent respond?
  5. I can see the system group, but nothing else. Why?
  6. Why can't I see values in the <ENTERPRISE> tree?
  7. The agent worked for a while, then stopped responding. Why?
  8. Requesting an object fails with "Unknown Object Identifier" Why?
  9. Why do I get "noSuchName" when asking for "sysUpTime" (or similar)?
  10. Why do I sometimes get "End of MIB" when walking a tree, and sometimes not?
  11. How do I use SNMPv3?
  12. Why can't I set any variables in the MIB?
  13. Variables seem to disappear when I try to set them. Why?
  14. Why can't I change sysLocation (or sysContact)?
  15. I get an error when trying to set a negative value - why?
  16. I get an error when trying to query a string-indexed table value - why?
  17. How should I specify string-index table values?
  18. How do I send traps and notifications?
  19. How do I receive traps and notifications?
  20. How do I receive SNNMPv1 traps?
  21. Why don't I receive incoming traps?
  22. My traphandler script doesn't work when run like this - why not?
  23. How can the agent receive traps and notifications?
  24. How big can an SNMP request (or reply) be?
  25. How can I monitor my systems (disk, memory, etc)?
  26. Applications complain about entries in your example 'snmp.conf' file. Why?
  27. OK, what should I put in snmp.conf?
  28. How do I specify IPv6 addresses in tools command line arguments?