Complex nagios command

nagios

I have defined the following command for one of my service checks:

define command{
        command_name    mycommand
        command_line    $USER1$/check_by_ssh -p $ARG1$ -l nagios -i /etc/nagios2/keys/key1 -H $HOSTADDRESS$ -v -C 'source $USER10$ ; command.py -a get --alert-name $ARG2$ -q'
        }

The problem is that it seems that nagios is parsing the command with the semicolon, and producing garbage which can not be executed. I have tried also putting a backslash \;, to no avail.

If I run the command directly on the shell, it works. Which means that this is not a problem with check_by_ssh, but a problem on the parsing of the nagios configuration file.

How can I debug this? Is there a way to get a listing of all the commands that nagios has parsed when reading the configuration files?

Best Answer

From comments discussion:

Nagios is apparently eating up anything after the semicolon in the "command" definition. The easiest way to manage this is to wrap up the complex command into a shell script that will be called by Nagios.

As part of debugging, the running Nagios configuration can be viewed using the CGI from the web interface, specifically the config.cgi (e.g., https://nagios.example.com/cgi-bin/nagios3/config.cgi). This will show the current set of commands, hosts, etc.