Suppose you get a definition file like:
TRAP-TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS ucdExperimental FROM UCD-SNMP-MIB;
demotraps OBJECT IDENTIFIER ::= { ucdExperimental 990 }
demo-trap1 TRAP-TYPE
STATUS current
ENTERPRISE demotraps
VARIABLES { interfaceName }
DESCRIPTION "Interface Down."
--#TYPE "Interface Status Change"
--#SUMMARY "Interface %s is down"
--#ARGUMENTS {0}
--#SEVERITY CRITICAL
--#STATE NONOPERATIONAL
::= 17
demo-trap2 TRAP-TYPE
STATUS current
ENTERPRISE demotraps
VARIABLES { interfaceName }
DESCRIPTION "Interface Up."
--#TYPE "Interface Status Change"
--#SUMMARY "Interface %s is Up"
--#ARGUMENTS {0}
--#SEVERITY INFORMATIONAL
--#STATE OPERATIONAL
::= 18
END
Go to Configuration→Services→Manufacturer,
create a vendor / manufacturer, like Example in this example.
Go to Configuration→Services→MIBs,
import these traps from the file:
Edit the trap definition to your needs:
Go to confgiration→Nagios→SNMP traps,
check Generate configuration files for SNMP Traps,
click Generate.
A file /etc/snmp/centreon_traps/snmptt-Example.conf will be created:
EVENT demo-trap1 .1.3.6.1.4.1.2021.13.990.0.17 "Status Event" 2 FORMAT Interface Status Change: Interface $1 is down EXEC /usr/local/centreon/bin/centTrapHandler-2.x $aA $A $o "Interface Status Change: Interface $1 is down" SDESC Interface Down. Variables: 1: interfaceName EDESC EVENT demo-trap2 .1.3.6.1.4.1.2021.13.990.0.18 "Status Event" 0 FORMAT Interface Status Change: Interface $1 is Up EXEC /usr/local/centreon/bin/centTrapHandler-2.x $aA $A $o "Interface Status Change: Interface $1 is Up" SDESC Interface Up. Variables: 1: interfaceName EDESC
Use this to match one trap to different status, using the message content.
Test send some traps:
# eth1 Link Down: snmptrap -v 2c -c public localhost \ "" .1.3.6.1.4.1.2021.13.990.0.17 .1.3.6.1.4.1.2021.13.990.0.17 s eth1 # wait a minute # eth1 Link Up: snmptrap -v 2c -c public localhost \ "" .1.3.6.1.4.1.2021.13.990.0.18 .1.3.6.1.4.1.2021.13.990.0.18 s eth1
Log:
http://www.net-snmp.org/wiki/index.php/TUT:snmptrap
Some sample MIBs with trap definition :
Some MIB files repository:
SNMPTT format strings: