External command failed -> CHANGE_SVC_CHECK_COMMAND

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.
Locked
nalloy
Posts: 2
Joined: Sun Aug 04, 2019 4:41 pm

External command failed -> CHANGE_SVC_CHECK_COMMAND

Post 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?
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
nalloy
Posts: 2
Joined: Sun Aug 04, 2019 4:41 pm

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Post by nalloy »

We are using Nagios XI 5.6.5. I didn't realize these were not the same thing - sorry for the confusion!
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: External command failed -> CHANGE_SVC_CHECK_COMMAND

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked