forked from evolix/ansible-roles
nagios-nrpe: sync Redis check from redis roles
This commit is contained in:
parent
fef86b0a3f
commit
9cd0426d2b
|
@ -75,6 +75,7 @@ The **patch** part changes is incremented if multiple releases happen the same m
|
||||||
* lxc-php: fix APT keyring path inside containers
|
* lxc-php: fix APT keyring path inside containers
|
||||||
* nagios-nrpe: `check_ssl_local` now has an output that nrpe can understand when it isn't OK
|
* nagios-nrpe: `check_ssl_local` now has an output that nrpe can understand when it isn't OK
|
||||||
* nagios-nrpe: remount `/usr` **after** installing the packages
|
* nagios-nrpe: remount `/usr` **after** installing the packages
|
||||||
|
* nagios-nrpe: sync Redis check from redis roles
|
||||||
* nginx: set default server directive in default vhost
|
* nginx: set default server directive in default vhost
|
||||||
* opendkim: update apt cache before install
|
* opendkim: update apt cache before install
|
||||||
* packweb-apache,nagios-nrpe: add missing task and config for PHP 8.2 container
|
* packweb-apache,nagios-nrpe: add missing task and config for PHP 8.2 container
|
||||||
|
|
|
@ -30,11 +30,21 @@ check_server() {
|
||||||
host=$(config_var "bind" "${conf_file}")
|
host=$(config_var "bind" "${conf_file}")
|
||||||
port=$(config_var "port" "${conf_file}")
|
port=$(config_var "port" "${conf_file}")
|
||||||
pass=$(config_var "requirepass" "${conf_file}")
|
pass=$(config_var "requirepass" "${conf_file}")
|
||||||
|
maxmemory=$(config_var "maxmemory" "${conf_file}")
|
||||||
|
maxmemory_policy=$(config_var "maxmemory-policy" "${conf_file}")
|
||||||
|
|
||||||
cmd="${check_bin} -H ${host} -p ${port}"
|
cmd="${check_bin} -H ${host} -p ${port}"
|
||||||
|
# If "requirepass" is set we add the password to the check
|
||||||
if [ -n "${pass}" ]; then
|
if [ -n "${pass}" ]; then
|
||||||
cmd="${cmd} -x ${pass}"
|
cmd="${cmd} -x ${pass}"
|
||||||
fi
|
fi
|
||||||
|
# If "maxmemory" is set and "maxmemory-policy" is missing or set to "noeviction"
|
||||||
|
# then we enforce the "maxmemory" limit
|
||||||
|
if [ -n "${maxmemory}" ]; then
|
||||||
|
if [ -z "${maxmemory_policy}" ] || [ "${maxmemory_policy}" = "noeviction" ]; then
|
||||||
|
cmd="${cmd} --total_memory ${maxmemory} --memory_utilization 80,90"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
result=$($cmd)
|
result=$($cmd)
|
||||||
ret="${?}"
|
ret="${?}"
|
||||||
if [ "${ret}" -ge 2 ]; then
|
if [ "${ret}" -ge 2 ]; then
|
||||||
|
@ -54,7 +64,7 @@ check_server() {
|
||||||
config_var() {
|
config_var() {
|
||||||
variable=$1
|
variable=$1
|
||||||
file=$2
|
file=$2
|
||||||
test -f $file && grep -E "^${variable}\s+.+$" $file | awk '{ print $2 }'
|
test -f "${file}" && grep -E "^${variable}\s+.+$" "${file}" | awk '{ print $2 }' | sed -e "s/^[\"']//" -e "s/[\"']$//"
|
||||||
}
|
}
|
||||||
|
|
||||||
# default instance
|
# default instance
|
||||||
|
@ -63,11 +73,11 @@ if systemctl is-enabled -q redis-server; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# additional instances
|
# additional instances
|
||||||
conf_files=$(ls -1 /etc/redis-*/redis.conf)
|
conf_files=$(ls -1 /etc/redis-*/redis.conf 2> /dev/null)
|
||||||
for conf_file in ${conf_files}; do
|
for conf_file in ${conf_files}; do
|
||||||
name=$(dirname ${conf_file} | sed '{s|/etc/redis-||}')
|
name=$(dirname "${conf_file}" | sed '{s|/etc/redis-||}')
|
||||||
if systemctl is-enabled -q "redis-server@${name}.service"; then
|
if systemctl is-enabled -q "redis-server@${name}.service"; then
|
||||||
check_server $name $conf_file
|
check_server "${name}" "${conf_file}"
|
||||||
else
|
else
|
||||||
nb_unchk=$((nb_unchk + 1))
|
nb_unchk=$((nb_unchk + 1))
|
||||||
output="${output}UNCHK - ${name} (unit is disabled or missing)\n"
|
output="${output}UNCHK - ${name} (unit is disabled or missing)\n"
|
||||||
|
|
Loading…
Reference in a new issue