nagios-nrpe: fix redis_instances check when Redis port equal 0

This commit is contained in:
Victor LABORIE 2019-05-20 14:26:21 +02:00
parent ed5fc03305
commit 360150d57b
2 changed files with 9 additions and 2 deletions

View File

@ -25,6 +25,7 @@ The **patch** part changes incrementally at each release.
### Fixed
* rbenv: add check_mode for check rbenv and ruby versions
* nagios-nrpe: fix redis_instances check when Redis port equal 0
### Security

View File

@ -13,9 +13,15 @@ instances=$(ls /etc/redis/redis-*.conf)
for instance in ${instances}; do
name=$(basename "${instance}"| sed '{s/redis-//;s/.conf//}')
port=$(grep "port" "${instance}"|grep -oE "[0-9]*")
socket=$(grep "unixsocket " "${instance}"|awk '{ print $2 }')
if [ -h "/etc/systemd/system/multi-user.target.wants/redis-server@${name}.service" ]; then
/usr/lib/nagios/plugins/check_tcp -p "${port}" >/dev/null 2>&1
ret="${?}"
if [ "${port}" -ne 0 ]; then
/usr/lib/nagios/plugins/check_tcp -p "${port}" >/dev/null 2>&1
ret="${?}"
else
/usr/lib/nagios/plugins/check_tcp -H "${socket}" >/dev/null 2>&1
ret="${?}"
fi
if [ "${ret}" -ge 2 ]; then
nb_crit=$((nb_crit + 1))
output="${output}CRITICAL - ${name} (${port})\n"