nagios-nrpe: sync Redis check from redis roles
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2632|6|2626|5|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/365//ansiblelint">Evolix » ansible-roles » unstable #365</a>
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Jérémy Lecour 2023-09-26 10:40:06 +02:00 committed by Jérémy Lecour
parent fef86b0a3f
commit 9cd0426d2b
Signed by: jlecour
SSH key fingerprint: SHA256:h+5LgHRKwN9lS0SsdVR5yZPeFlJE4Mt+8UtL4CcP8dY
2 changed files with 15 additions and 4 deletions

View file

@ -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
* 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: sync Redis check from redis roles
* nginx: set default server directive in default vhost
* opendkim: update apt cache before install
* packweb-apache,nagios-nrpe: add missing task and config for PHP 8.2 container

View file

@ -30,11 +30,21 @@ check_server() {
host=$(config_var "bind" "${conf_file}")
port=$(config_var "port" "${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}"
# If "requirepass" is set we add the password to the check
if [ -n "${pass}" ]; then
cmd="${cmd} -x ${pass}"
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)
ret="${?}"
if [ "${ret}" -ge 2 ]; then
@ -54,7 +64,7 @@ check_server() {
config_var() {
variable=$1
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
@ -63,11 +73,11 @@ if systemctl is-enabled -q redis-server; then
fi
# 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
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
check_server $name $conf_file
check_server "${name}" "${conf_file}"
else
nb_unchk=$((nb_unchk + 1))
output="${output}UNCHK - ${name} (unit is disabled or missing)\n"