Page 1 of 1

External command error: Command failed

Posted: Mon Oct 29, 2018 10:58 am
by hbouma
I am attempting to remove some acknowledgements from the command line. The host and service both exist, but the command fails each time. I wrote a script that takes in a variable of the HOST and Service. The script is running as root, so permissions should not be an issue.

Code: Select all

#!/bin/sh
# This is a sample shell script showing how you can submit the REMOVE_SVC_ACKNOWLEDGEMENT command
# to Nagios. Adjust variables to fit your environment as necessary.

now=`date +%s`
commandfile='/usr/local/nagios/var/rw/nagios.cmd'

/bin/printf "[%lu] REMOVE_SVC_ACKNOWLEDGEMENT;$1;$2\n" $now > $commandfile
I then call /usr/local/nagiosxi/scripts/removeAck.sh "SOMEHOST" "Disk Usage on D:/"

The acknowledgement is not removed and I see the following in /usr/local/nagios/var/nagios.log

Code: Select all

[1540828100] Error: External command failed -> REMOVE_SVC_ACKNOWLEDGEMENT;SOMEHOST;Disk Usage on D:/\n 1540828100
[1540828100] External command error: Command failed
My permissions appear correct in /usr/local/nagios/var/rw

Code: Select all

ll /usr/local/nagios/var/rw
total 8.0K
drwxrws---. 2 nagios nagcmd 4.0K Oct 29 11:48 .
drwxr-xr-x. 6 nagios nagios 4.0K Oct 29 11:53 ..
prw-rw----  1 nagios nagcmd    0 Oct 29 11:49 nagios.cmd
srw-rw----  1 nagios nagcmd    0 Oct 29 11:48 nagios.qh
I am running Nagios 5.5.4 on Red Hat 7 64bit VM's. Any help with this issue would be appreciated.

Re: External command error: Command failed

Posted: Mon Oct 29, 2018 12:02 pm
by npolovenko
Hello, @hbouma. What version of XI are you using? Have you always had problems with external commands on this server or just recently?

Please open the /usr/local/nagios/etc/nagios.cfg file and make sure that:
check_external_commands=1
Then restart the nagios service:
service nagios restart
I ran your script and it worked just fine for me. Can you try removing acknowledgment for some service on the localhost? And let me know if it works.

Re: External command error: Command failed

Posted: Mon Oct 29, 2018 12:09 pm
by hbouma
check_external_commands=1 was already in the file.

I restarted the nagios service and now it works. Thanks!

Re: External command error: Command failed

Posted: Mon Oct 29, 2018 12:12 pm
by npolovenko
@hbouma, You're welcome. I will be closing this ticket as resolved.