nagios-nrpe: fix bug in monitoringctl check when an empty string is present in the NRPE command
This commit is contained in:
parent
21b2fcb16c
commit
ce35527c32
|
@ -58,7 +58,7 @@ function main() {
|
||||||
timeout_command="timeout 8"
|
timeout_command="timeout 8"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_stdout="$(${timeout_command} ${check_command})"
|
check_stdout="$(eval "${timeout_command} ${check_command}")"
|
||||||
check_rc=$?
|
check_rc=$?
|
||||||
|
|
||||||
if [ "${is_disabled}" = "True" ] && [ "${check_rc}" -eq 124 ] && [ -z "${check_stdout}" ]; then
|
if [ "${is_disabled}" = "True" ] && [ "${check_rc}" -eq 124 ] && [ -z "${check_stdout}" ]; then
|
||||||
|
@ -141,16 +141,23 @@ if [[ "${1}" =~ -.* ]]; then
|
||||||
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
# The rest is the command
|
|
||||||
check_command="$*"
|
|
||||||
else
|
else
|
||||||
# no option is passed (backward compatibility with previous version)
|
# no option is passed (backward compatibility with previous version)
|
||||||
# treat the first argument as wrapper_name and the rest as the command
|
# treat the first argument as wrapper_name and the rest as the command
|
||||||
wrapper_name="${1}"
|
wrapper_name="${1}"
|
||||||
shift
|
shift
|
||||||
check_command="$*"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The rest is the command
|
||||||
|
while [ "$#" -ne 0 ]; do
|
||||||
|
if [ -n "${1}" ]; then
|
||||||
|
check_command="${check_command} ${1}"
|
||||||
|
else
|
||||||
|
check_command="${check_command} ''"
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
if [ -z "${wrapper_name}" ]; then
|
if [ -z "${wrapper_name}" ]; then
|
||||||
printf 'ERROR: You must specify a wrapper name, with --names.\n' >&2
|
printf 'ERROR: You must specify a wrapper name, with --names.\n' >&2
|
||||||
exit 2
|
exit 2
|
||||||
|
|
Loading…
Reference in a new issue