Template:FAQ:Applications 16
Traps and notifications can be sent using the command 'snmptrap'
.
The following examples generate the generic trap 'coldStart'
and a
(dummy) enterprise specific trap '99' respectively:
snmptrap -v 1 -c public localhost "" "" 0 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).
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 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.