2023-05-25 16:01:04 +02:00
|
|
|
#!/usr/bin/env bash
|
2023-05-12 12:35:49 +02:00
|
|
|
|
2023-09-11 09:25:21 +02:00
|
|
|
CHECK_BIN=/usr/lib/nagios/plugins/check_nrpe
|
|
|
|
|
|
|
|
if ! test -f "${CHECK_BIN}"; then
|
|
|
|
echo "${CHECK_BIN} is missing, please install nagios-nrpe-plugin package."
|
2023-05-12 12:35:49 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-09-11 09:25:21 +02:00
|
|
|
for file in /etc/nagios/{nrpe.cfg,nrpe_local.cfg,nrpe.d/evolix.cfg}; do
|
|
|
|
if [ -r ${file} ]; then
|
|
|
|
found_command=$(grep "\[check_$1\]" "${file}" | grep -v '^[[:blank:]]*#' | tail -n1 | cut -d'=' -f2-)
|
|
|
|
fi
|
|
|
|
if [ -n "${found_command}" ]; then
|
|
|
|
command="${found_command}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "${command}" ]; then
|
|
|
|
echo "Found command in /etc/nagios (take care, in some cases, Nagios can play another command):"
|
|
|
|
echo " ${command}"
|
2023-05-25 16:01:04 +02:00
|
|
|
fi
|
2023-05-12 12:35:49 +02:00
|
|
|
|
2023-05-25 16:02:27 +02:00
|
|
|
echo "NRPE daemon output:"
|
2023-09-11 09:25:21 +02:00
|
|
|
"${CHECK_BIN}" -H 127.0.0.1 -c "check_$1"
|
2023-05-12 12:35:49 +02:00
|
|
|
|
|
|
|
|