Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Figment
Posts: 17 Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK
Post
by Figment » Thu Jan 31, 2019 4:12 am
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,
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Jan 31, 2019 8:20 am
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/
Figment
Posts: 17 Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK
Post
by Figment » Thu Jan 31, 2019 10:29 am
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/
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Jan 31, 2019 10:45 am
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
Figment
Posts: 17 Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK
Post
by Figment » Thu Jan 31, 2019 11:01 am
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
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Thu Jan 31, 2019 11:07 am
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
Figment
Posts: 17 Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK
Post
by Figment » Tue Feb 05, 2019 11:57 am
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
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Tue Feb 05, 2019 12:07 pm
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
}
Figment
Posts: 17 Joined: Mon Jan 28, 2019 5:21 am
Location: London, UK
Post
by Figment » Tue Feb 05, 2019 1:29 pm
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?
scottwilkerson
DevOps Engineer
Posts: 19396 Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:
Post
by scottwilkerson » Tue Feb 05, 2019 2:38 pm
Figment wrote: Is it worth trying to put the script in a different directory?
might as well try, I'm actually out of ideas....