From 18ac1e72798fd44cc7b9056d9dc1c322b45cbf9f Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 1 Dec 2020 19:02:35 +0100 Subject: [PATCH] redis: check maxmemory in NRPE check If "maxmemory" is set and "maxmemory-policy" is missing or set to "noeviction" then we enforce the "maxmemory" limit --- CHANGELOG.md | 1 + redis/files/check_redis_instances.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb0b5a7c..4c06e5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ The **patch** part changes incrementally at each release. * mysql: install save_mysql_processlist script * nextcloud: New role to setup a nextcloud instance * redis: variable to force use of port 6379 in instances mode +* redis: check maxmemory in NRPE check * lxc-php: Allow php containers to contact local MySQL with localhost ### Changed diff --git a/redis/files/check_redis_instances.sh b/redis/files/check_redis_instances.sh index 7821aeb0..a7dead82 100644 --- a/redis/files/check_redis_instances.sh +++ b/redis/files/check_redis_instances.sh @@ -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