Page 1 of 1

Event Handler to Create missing files

Posted: Wed Sep 24, 2014 6:12 am
by ganeshanrs1983
Team,

From Nagios server using check_nrpe we are checking the script testing.sh on remote server tmp folder. If the file is not there using event handler it has to call the second script (testing2.sh) to create the files on tmp folder. I have attached the two script ( testing.sh and testing2.sh ) and event handler configuration.

We have added the entry on remote server in etc/nrpe.cfg
command[check_testing]=/tmp/testing.sh
command[check_testing2]=/tmp/testing2.sh

Issue : Nagios is not calling the event handler even though we enabled in main configuration and for particular service. In event log also we not seeing any logs related to event_file_creation.sh

The script is working fine manually /usr/local/nagios/libexec/event_file_creation.sh
Output of event_file_creation.sh

#!/bin/bash
# Event Handler for creating missing files
case "$1" in
OK)
;;
WARNING)
/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c check_testing2 -n
;;
UNKNOWN)
;;
CRITICAL)
echo "Files has not been created"
;;
esac
exit 0

Could you please suggest some solution.

Re: Event Handler to Create missing files

Posted: Wed Sep 24, 2014 10:42 am
by Box293
Please post your service definition that shows the event handler command that is assigned.

Also post your command definition that defines the event handler command.

Re: Event Handler to Create missing files

Posted: Wed Sep 24, 2014 1:09 pm
by ganeshanrs1983
Service definition :

define service {
host_name remote server
service_description testing script
display_name remote server
check_command check_nrpe1!check_testing!!!!!!!
max_check_attempts 3
check_interval 3
retry_interval 1
check_period 24x7
event_handler event_file_creation
event_handler_enabled 1
notification_interval 5
first_notification_delay 0
notification_period 24x7
notification_options w,c,u,r,
notifications_enabled 1
contacts ganesh
register 1
}

command definition :

define command {
command_name event_file_creation
command_line $USER1$/event_file_creation.sh $SERVICESTATE$ $HOSTADDRESS$
}

Output of event_file_creation.sh :

#!/bin/bash
# Event Handler for creating missing files
case "$1" in
OK)
;;
WARNING)
usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c check_testing2 -n
;;
UNKNOWN)
;;
CRITICAL)
echo "Files has not been created"
;;
esac

exit 0

Re: Event Handler to Create missing files

Posted: Wed Sep 24, 2014 1:44 pm
by Box293
I'm thinking your problem might be in the script:

Code: Select all

usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c check_testing2 -n
I think it needs to start with a forward slash

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H "$2" -p 5666 -c check_testing2 -n

Re: Event Handler to Create missing files

Posted: Thu Sep 25, 2014 9:13 am
by ganeshanrs1983
This issue is resolved. Thanks a lot for your support and time.

The problem is i didn't mention the macro properly in the event handler script.