Page 1 of 1

External command failed -> CHANGE_SVC_CHECK_COMMAND

Posted: Tue Aug 20, 2019 9:48 pm
by nalloy
I have a service where the warning/critical values need to be modified two times per day, because the monitored application dynamically adjusts the associated parameter (e.g. the number of warm servers is 30 at 6 am, but there are 5 warm servers at 5 pm).

Here is my original service command definition:
check_tc_jmx!8088!"Administer PoolA manager :id=PoolA" "Number of Warm Servers" Warm_Servers 28 26!!!!!!

At 5 pm, I would like to change this to:
check_tc_jmx!8088!"Administer PoolA manager :id=PoolA" "Number of Warm Servers" Warm_Servers 3 1!!!!!!

At 6 am, I would like to return the command to the original definition.

I am running Nagios Core 5.6.5 and using external commands for the first time. I created the following shell script:

Code: Select all

#!/bin/sh

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

poolahost='plm-biz01-001'
poolaservice='Pool A - Warm Servers'
poolacommand='check_tc_jmx!8088!"Administer PoolA manager :id=PoolA" "Number of Warm Servers" Warm_Servers 3 1!!!!!!'

/bin/printf "[%lu] CHANGE_SVC_CHECK_COMMAND;$poolahost;$poolaservice;$poolacommand\n" $now > $commandfile

When I execute this shell script, I get the following error in /usr/local/nagios/var/nagios.log:
[1566353759] External command error: Command failed
[1566354055] Error: External command failed -> CHANGE_SVC_CHECK_COMMAND;plm-biz01-001;Pool A - Warm Servers;check_tc_jmx!8088!"Administer PoolA manager :id=PoolA" "Number of Warm Servers" Warm_Servers 3 1!!!!!!
[1566354055] External command error: Command failed

In /usr/local/nagios/etc/nagios.cfg I have check_external_commands=1 set. There is a newline character at the end of my shell script and the file has nagios:nagios permissions set.

Any ideas what could be causing this error?

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Posted: Wed Aug 21, 2019 4:00 pm
by mbellerue
Just for funsies, try changing your shebang to #!/bin/bash and see if that gets you any further.

Cancel that. Looks like this was disabled as part of a security patch.

Also, are you using Nagios Core or Nagios XI?

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Posted: Wed Aug 21, 2019 7:56 pm
by nalloy
We are using Nagios XI 5.6.5. I didn't realize these were not the same thing - sorry for the confusion!

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Posted: Thu Aug 22, 2019 9:34 am
by mbellerue
It is all good. I was asking because I thought you might be able to do this through the API if you're using Nagios XI. But as it turns out, that functionality is disabled there as well.