nagios-nrpe: add check_redis_instances

This commit is contained in:
Victor LABORIE 2018-09-20 10:21:49 +02:00
parent 8546f0f34f
commit 5f4601f611
3 changed files with 51 additions and 0 deletions

View file

@ -18,6 +18,7 @@ The **patch** part changes incrementally at each release.
* networkd-to-ifconfig: add a role to switch from networkd to ifconfig
* webapps/evoadmin-web: add users to /etc/aliases
* redis: add support for multi instances
* nagios-nrpe: add check_redis_instances
### Changed
* dovecot: stronger TLS configuration

View file

@ -0,0 +1,49 @@
#!/bin/sh
set -u
return=0
nb_crit=0
nb_warn=0
nb_ok=0
nb_unchk=0
output=""
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]*")
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 [ "${ret}" -ge 2 ]; then
nb_crit=$((nb_crit + 1))
output="${output}CRITICAL - ${name} (${port})\n"
[ "${return}" -le 2 ] && return=2
elif [ "${ret}" -ge 1 ]; then
nb_warn=$((nb_warn + 1))
output="${output}WARNING - ${name} (${port})\n"
[ "${return}" -le 1 ] && return=1
else
nb_ok=$((nb_ok + 1))
output="${output}OK - ${name} (${port})\n"
[ "${return}" -le 0 ] && return=0
fi
else
nb_unchk=$((nb_unchk + 1))
output="${output}UNCHK - ${name} (${port})\n"
fi
done
[ "${return}" -ge 0 ] && header="OK"
[ "${return}" -ge 1 ] && header="WARNING"
[ "${return}" -ge 2 ] && header="CRITICAL"
printf "%s - %s UNCHK / %s CRIT / %s WARN / %s OK\n\n" "${header}" "${nb_unchk}" "${nb_crit}" "${nb_warn}" "${nb_ok}"
printf "${output}" | grep -E "^CRITICAL"
printf "${output}" | grep -E "^WARNING"
printf "${output}" | grep -E "^OK"
printf "${output}" | grep -E "^UNCHK"
exit "${return}"

View file

@ -68,6 +68,7 @@ command[check_supervisord_status]={{ nagios_plugins_directory }}/check_superviso
command[check_varnish]={{ nagios_plugins_directory }}/check_varnish_health -i 127.0.0.1 -p 6082 -s /etc/varnish/secret -w 2 -c 4
command[check_haproxy]={{ nagios_plugins_directory }}/check_haproxy_stats -s /var/run/haproxy.sock -w 80 -c 90
command[check_minifirewall]=sudo {{ nagios_plugins_directory }}/check_minifirewall
command[check_redis_instances]={{ nagios_plugins_directory }}/check_redis_instances
# Check HTTP "many". Use this to check many websites (http, https, ports, sockets and SSL certificates).
# Beware! All checks must not take more than 10s!