Event Handler to Create missing files

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Event Handler to Create missing files

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Event Handler to Create missing files

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: Event Handler to Create missing files

Post 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
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: Event Handler to Create missing files

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
ganeshanrs1983
Posts: 55
Joined: Wed Jun 18, 2014 10:16 am

Re: Event Handler to Create missing files

Post 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.
Locked