From 9b66edd33d265dfa00db4a6aeb33fca3b027b0d2 Mon Sep 17 00:00:00 2001 From: Stefan Mayr Date: Sun, 12 Oct 2025 16:00:28 +0200 Subject: [PATCH 1/3] Detect valkey-server --- agents/plugins/mk_redis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/plugins/mk_redis b/agents/plugins/mk_redis index 0c325b2267f..15370ac348f 100755 --- a/agents/plugins/mk_redis +++ b/agents/plugins/mk_redis @@ -76,7 +76,7 @@ main() { if [ ${#REDIS_INSTANCES[@]} -eq 0 ]; then IS_DETECTED=true # find instances and remove entries like "*:6879", possible with docker container - DETECTED=$(pgrep -xa "redis-server" 2>/dev/null | awk '/:[0-9]+/ && !/\*/ || /unixsocket:.*/ { print $3 }') + DETECTED=$(pgrep -xa "(redis|valkey)-server" 2>/dev/null | awk '/:[0-9]+/ && !/\*/ || /unixsocket:.*/ { print $3 }') # add found redis instances for REDIS_INSTANCE in $DETECTED; do From dcc48e86248162fb2b85ffefb93e8b3c6f3a2bef Mon Sep 17 00:00:00 2001 From: Stefan Mayr Date: Sun, 12 Oct 2025 16:42:54 +0200 Subject: [PATCH 2/3] Detect redis cli per instance --- agents/plugins/mk_redis | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/agents/plugins/mk_redis b/agents/plugins/mk_redis index 15370ac348f..a1cbd364759 100755 --- a/agents/plugins/mk_redis +++ b/agents/plugins/mk_redis @@ -14,6 +14,7 @@ CMK_VERSION="2.5.0b1" # sample output of pgrep command # 1051 /usr/bin/redis-server 127.0.0.1:6380 # 1324 /usr/bin/redis-server 127.0.0.1:6379 +# 1612 /usr/bin/valkey-server 127.0.0.1:6379 # example cfg file /etc/check_mk/mk_redis.cfg # @@ -55,13 +56,26 @@ redis_args() { REDIS_ARGS=("-h" "${!HOST}" "-p" "${!PORT}") fi - if [[ "${!PASSWORD}" ]] && [[ "${!PASSWORD}" != "None" ]]; then - REDIS_CLI_COMMAND="REDISCLI_AUTH='${!PASSWORD}' redis-cli" - else + REDIS_ARGS+=("info") + + # detect usable redis-cli + if [[ "${!HOST}" == /omd/sites/* ]]; then + # use site redis-cli for redis instances in site + IFS="/" read -ra ADDR <<<"${!HOST}" + REDIS_CLI_COMMAND="/omd/sites/${ADDR[3]}/bin/redis-cli" + elif type redis-cli &>/dev/null; then REDIS_CLI_COMMAND="redis-cli" + elif type valkey-cli &>/dev/null; then + REDIS_CLI_COMMAND="valkey-cli" + else + REDIS_CLI_COMMAND="echo 'error: no cli found'" + REDIS_ARGS=() + return fi - REDIS_ARGS+=("info") + if [[ "${!PASSWORD}" ]] && [[ "${!PASSWORD}" != "None" ]]; then + REDIS_CLI_COMMAND="REDISCLI_AUTH='${!PASSWORD}' ${REDIS_CLI_COMMAND}" + fi } main() { @@ -112,13 +126,7 @@ main() { # print server section echo "[[[$INSTANCE|${!HOST}|${!PORT}]]]" - if [[ "${!HOST}" == /omd/sites/* ]]; then - # use site redis-cli for redis instances in site - IFS="/" read -ra ADDR <<<"${!HOST}" - output=$(waitmax 3 bash -c "/omd/sites/${ADDR[3]}/bin/redis-cli ${REDIS_ARGS[*]}" 2>&1 || true) - else - output=$(waitmax 3 bash -c "${REDIS_CLI_COMMAND} ${REDIS_ARGS[*]}" 2>&1 || true) - fi + output=$(waitmax 3 bash -c "${REDIS_CLI_COMMAND} ${REDIS_ARGS[*]}" 2>&1 || true) if [[ "$output" == *"Could not connect to Redis at ${!HOST}: Permission denied"* ]]; then # mark error explicitly for easier parsing From be5b68fd02b887c66ff0014622d1797f831e1145 Mon Sep 17 00:00:00 2001 From: Stefan Mayr Date: Tue, 18 Nov 2025 20:30:49 +0100 Subject: [PATCH 3/3] Fix indention --- agents/plugins/mk_redis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/plugins/mk_redis b/agents/plugins/mk_redis index a1cbd364759..36cca2f3b60 100755 --- a/agents/plugins/mk_redis +++ b/agents/plugins/mk_redis @@ -90,7 +90,7 @@ main() { if [ ${#REDIS_INSTANCES[@]} -eq 0 ]; then IS_DETECTED=true # find instances and remove entries like "*:6879", possible with docker container - DETECTED=$(pgrep -xa "(redis|valkey)-server" 2>/dev/null | awk '/:[0-9]+/ && !/\*/ || /unixsocket:.*/ { print $3 }') + DETECTED=$(pgrep -xa "(redis|valkey)-server" 2>/dev/null | awk '/:[0-9]+/ && !/\*/ || /unixsocket:.*/ { print $3 }') # add found redis instances for REDIS_INSTANCE in $DETECTED; do