1848a6162a
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend
|:-:|:-:|:-:|:-:|:-:
|2646|4|2642|4|:-1:
Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/350//ansiblelint">Evolix » ansible-roles » unstable #350</a>
gitea/ansible-roles/pipeline/head This commit looks good
37 lines
1,019 B
Bash
Executable file
37 lines
1,019 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
CHECK_BIN=/usr/lib/nagios/plugins/check_nrpe
|
|
|
|
server_address="127.0.0.1"
|
|
|
|
if ! test -f "${CHECK_BIN}"; then
|
|
echo "${CHECK_BIN} is missing, please install nagios-nrpe-plugin package."
|
|
exit 1
|
|
fi
|
|
|
|
for file in /etc/nagios/{nrpe.cfg,nrpe_local.cfg,nrpe.d/evolix.cfg}; do
|
|
if [ -r ${file} ]; then
|
|
command_search=$(grep "\[check_$1\]" "${file}" | grep -v '^[[:blank:]]*#' | tail -n1 | cut -d'=' -f2-)
|
|
fi
|
|
if [ -n "${command_search}" ]; then
|
|
command="${command_search}"
|
|
fi
|
|
|
|
if [ -r ${file} ]; then
|
|
server_address_search=$(grep "server_address" "${file}" | grep -v '^[[:blank:]]*#' | cut -d'=' -f2)
|
|
fi
|
|
if [ -n "${server_address_search}" ]; then
|
|
server_address="${server_address_search}"
|
|
fi
|
|
done
|
|
|
|
if [ -n "${command}" ]; then
|
|
echo "Found command in /etc/nagios (take care, in some cases, Nagios can play another command):"
|
|
echo " ${command}"
|
|
fi
|
|
|
|
echo "NRPE daemon output:"
|
|
"${CHECK_BIN}" -H "${server_address}" -c "check_$1"
|
|
|
|
|