Page 3 of 4
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 4:12 am
by Figment
Yeah, as far as I can see all files seem to be in their right location.
Code: Select all
[root@Nagios ~]# ls -l /usr/local/nagios/libexec/auto-acknowledge.sh
-rwxr-xr-x. 1 nagios nagios 693 Jan 28 14:42 /usr/local/nagios/libexec/auto-acknowledge.sh
[root@Nagios ~]# ls -d /usr/local/nagios/libexec/
/usr/local/nagios/libexec/
[root@Nagios ~]# ls -d /usr/local/nagios/
/usr/local/nagios/
[root@Nagios ~]# ls -d /usr/local/
/usr/local/
Thanks,
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 8:20 am
by scottwilkerson
Sorry I missed the most important char in 3 of the commands
Code: Select all
ls -dl /usr/local/nagios/libexec/
ls -dl /usr/local/nagios/
ls -dl /usr/local/
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 10:29 am
by Figment
no worries, here's the results of that command.
Code: Select all
[root@Nagios ~]# ls -dl /usr/local/nagios/libexec/
drwxrwxr-x. 2 nagios nagios 4096 Jan 28 14:42 /usr/local/nagios/libexec/
[root@Nagios ~]# ls -dl /usr/local/nagios/
drwxrwxr-x. 10 root root 4096 Jan 3 14:21 /usr/local/nagios/
[root@Nagios ~]# ls -dl /usr/local/
drwxr-xr-x. 16 root root 4096 Nov 1 15:57 /usr/local/
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 10:45 am
by scottwilkerson
This all looks as expected, can you post the output of the following as I'm still not seeing what could be giving you a file not found
Code: Select all
cat /usr/local/nagios/libexec/auto-acknowledge.sh
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 11:01 am
by Figment
Certainly,
Code: Select all
[root@SU-GBCP-VTDS150 ~]# cat /usr/local/nagios/libexec/auto-acknowledge.sh
#!/bin/sh
#
# Event handler script for acknowledging non critical hosts.
#
#
# What state is the Host in?
case "$1" in
UP)
;;
UNREACHABLE)
;;
DOWN)
case "$2" in
SOFT)
case "$3" in
1)
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$4;2;1;1;Autobot;Non-critical host, outage acknowledged\n" $now > $commandfile
;;
esac
;;
HARD)
now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'
/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;$4;2;0;1;Autobot;Non-critical host, outage acknowledged\n" $now > $commandfile
;;
esac
;;
esac
Re: Event Handler Script not working.
Posted: Thu Jan 31, 2019 11:07 am
by scottwilkerson
It just hit me, you don't have quotes around the items in your command definition
lets change this
Code: Select all
define command{
command_name auto-acknowledge
command_line $USER1$/auto-acknowledge.sh $HOSTSTATE$ $HOSTSTATETYPE$ $HOSTATTEMPT$ $HOSTNAME$
}
to this
Code: Select all
define command{
command_name auto-acknowledge
command_line $USER1$/auto-acknowledge.sh '$HOSTSTATE$' '$HOSTSTATETYPE$' '$HOSTATTEMPT$' '$HOSTNAME$'
}
and then apply configuration
Re: Event Handler Script not working.
Posted: Tue Feb 05, 2019 11:57 am
by Figment
Hi Scott,
Apologies for the delayed response, I have been out of office for a few days. Even with the quotes i'm still getting a "No such file or directory" error.
Code: Select all
[1549385220] HOST EVENT HANDLER: TEST_PRINTER;DOWN;SOFT;3;auto-acknowledge
[1549385220] wproc: HOST EVENTHANDLER job 2518 from worker Core Worker 16314 is a non-check helper but exited with return code 2
[1549385220] wproc: early_timeout=0; exited_ok=1; wait_status=512; error_code=0;
[1549385220] wproc: stderr line 01: execvp(/usr/local/nagios/libexec/auto-acknowledge.sh, ...) failed. errno is 2: No such file or directory
Re: Event Handler Script not working.
Posted: Tue Feb 05, 2019 12:07 pm
by scottwilkerson
This is so bizarre, the error is like the file
/usr/local/nagios/libexec/auto-acknowledge.sh doesn't exist.
Out of curiosity, can you change the command to the following and restart nagios and see if you get the same error testing this
Code: Select all
define command{
command_name auto-acknowledge
command_line $USER1$/auto-acknowledge.sh
}
Re: Event Handler Script not working.
Posted: Tue Feb 05, 2019 1:29 pm
by Figment
scottwilkerson wrote:This is so bizarre, the error is like the file
/usr/local/nagios/libexec/auto-acknowledge.sh doesn't exist.
Out of curiosity, can you change the command to the following and restart nagios and see if you get the same error testing this
Code: Select all
define command{
command_name auto-acknowledge
command_line $USER1$/auto-acknowledge.sh
}
Yeah its not really making any sense to me either. I've tried with non of the variables passed as you suggested and still get the file not found error.
Is it worth trying to put the script in a different directory?
Re: Event Handler Script not working.
Posted: Tue Feb 05, 2019 2:38 pm
by scottwilkerson
Figment wrote:Is it worth trying to put the script in a different directory?
might as well try, I'm actually out of ideas....