Page 1 of 1

SNMPTT and external file

Posted: Wed Oct 19, 2011 10:26 am
by mrninni
Hi all,

My Nagios receives traps handled by SNMPTT.
I'd like to send the traps to different nagios-services based on the text of the trap.
In order to perform this feature, I manage the text of the trap using a PREEXEC command (SNMPTT) and an external script (/home/user/check_trap)

Code: Select all

PREEXEC /home/user/check_trap "trap text" # --> $p1
EXEC /usr/lib/nagios/plugins/eventhandlers/submit_check_result $r $p1 1 "error"
$r is the host and $p1 is the service name provided by the external script that contains the rules to determine the right service based on the trap text (for example containing an IP address).

There is a way to do not use an external script but simplest a SNMPTT command an a external file that will contains the same rules of the script to determine the right service?

The external file may be like this:

Code: Select all

service1 192.168.0.5
service2 192.168.0.7
service3 192.168.0.9
If the trap text contains 192.168.0.7 the destination nagios-service is service2, so the EXEC command will be

Code: Select all

EXEC /usr/lib/nagios/plugins/eventhandlers/submit_check_result host service2 1 "error"
Thanks a lot,
marco