check_by_ssh works on cmd line, fails in gui
Posted: Thu Sep 25, 2014 10:35 am
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.
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.