Page 1 of 1

check_by_ssh works on cmd line, fails in gui

Posted: Thu Sep 25, 2014 10:35 am
by ddewilde
Using NagiosXI 2014 CentOS VMware image.
Attempting to use a complex command line fails after using the gui to configure the command.
The error on use is:
(No output on stdout) stderr: /bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file

The same command works fine from the command line.
Example:
./check_by_ssh -H myHost -l myUser -C "freespace=\`df -k /home/mydisk | tail -n1 | sed -r 's/\\ +/\\ /g' | cut -d \\ -f5 | sed -r 's/%//g' \`; if [ \$freespace -lt 90 ]; then echo \"OK Free space: \$freespace%\"; exit 0; elif [ \$freespace -lt 95 ]; then echo \"Warning Free space: \$freespace%\"; exit 1 else echo \"Crititcal Free space: \$freespace%\"; exit 2; fi"

output:
OK Free space: 80%

The one-liner approach is required as I may not modify the target system.

Re: check_by_ssh works on cmd line, fails in gui

Posted: Thu Sep 25, 2014 10:45 am
by tmcdonald
How are you testing the command? Are you configuring it and letting it run? Or are you using the Test Check Command in the CCM? The Test Check Command button has some issues both with escaping and with running certain checks.

Re: check_by_ssh works on cmd line, fails in gui

Posted: Thu Sep 25, 2014 11:30 am
by ddewilde
I noticed the test command has problems with even basic check_by_ssh command requests so I was using the actual service command execution to test.

I worked around this problem by placing the complex command line in a wrapper command and then used the gui to call the simple interface. I imported my new wrapper command and used it successfully from a service within XI.

The result is a new plugin called check_disk_by_ssh which then calls check_by_ssh with the complex command.

Re: check_by_ssh works on cmd line, fails in gui

Posted: Thu Sep 25, 2014 4:03 pm
by sreinhardt
Nice job! Thanks for letting us know its working.