Page 1 of 1

Trap Integration not working

Posted: Mon Apr 25, 2016 9:47 am
by Iskon
Hi,

i've followed this tutorial

https://assets.nagios.com/downloads/nag ... ios_XI.pdf

I've managed to recieve traps and they are logged in

Code: Select all

/var/log/snmptt/snmptt.log
Mon Apr 25 16:30:22 2016 .1.3.6.1.6.3.1.1.5.3 Critical "Status Events" ncdev - Link down on interface eth2.  Admin state: $2.  Operational state: $3
But nagios critical state is not triggered and notifications aren't sent.

And service on that host in in state:

Code: Select all

SNMP TrapsPassive Only Check	Pending	N/A	1/1	N/A	No check results for service yet...
Part of config for that trap is:

Code: Select all

/etc/snmp/snmptt.conf
#
#
#
EVENT linkDown .1.3.6.1.6.3.1.1.5.3 "Status Events" Critical
FORMAT Link down on interface $1.  Admin state: $2.  Operational state: $3
#EXEC qpage -f TRAP notifygroup1  "Link down on interface $1.  Admin state: $2.  Operational state: $3"
SDESC
A linkDown trap signifies that the SNMP entity, acting in
an agent role, has detected that the ifOperStatus object for
one of its communication links is about to enter the down
state from some other state (but not from the notPresent
state).  This other state is indicated by the included value
of ifOperStatus.
EDESC
#
#
#
I'm sending traps from ncdev (another server) to nagios xi server with cmd:

Code: Select all

snmptrap -v 2c -c public <nagioserverip> '' .1.3.6.1.6.3.1.1.5.3 .1.3.6.1.6.3.1.1.5.3 s "eth2"
Please let me know if additional info is needed.

Re: Trap Integration not working

Posted: Mon Apr 25, 2016 10:48 am
by gormank
Make sure traps are arriving.
tcpdump -i eth2 -s 0 port 162
Make sure you're listening.
netstat -an | grep ":162 "
ps -ef | grep -e snmptrapd -e snmptt | grep -v grep
Check the syslog to see if traps are processed by snmptrapd.
Check the snmptt.log to see if snmptt is getting traps from snmptrapd.
Check if iptables is running and blocking traps. Easiest is to just stop it...

Re: Trap Integration not working

Posted: Mon Apr 25, 2016 3:39 pm
by tgriep
In your example, you are missing the EXEC line for that OID and that is why it is not getting in to the XI interface.
When the snmptt daemon matches the OID of a received trap, it will execute the EXEC line which puts it in to XI.
Try adding the following line to that OID and see if it works for you.

Code: Select all

EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "Link down on interface $1.  Admin state: $2.  Operational state: $3"
You may need to adjust the options for your needs.

Re: Trap Integration not working

Posted: Tue Apr 26, 2016 1:00 am
by Iskon
ah...:(
from docs:

Code: Select all

EXEC:

[EXEC command_string]
There can be multiple EXEC lines per EVENT.

Optional string containing a command to execute when trap is received and arguments to pass to the program.  The EXEC lines are executed in the order that they appear.
So it didn't occur to me that EXEC must be defined.

Thx tgriep, it works now.

Re: Trap Integration not working

Posted: Tue Apr 26, 2016 9:39 am
by tgriep
Your Welcome.
FYI, if you use the addmib application or in the XI GUI, you upload the MIB file with the Process Trap box checked, it will automatically add the EXEC line in the config file for you.

Re: Trap Integration not working

Posted: Wed Apr 27, 2016 4:58 am
by Iskon
Thx, for the info.