Skip to content

Commit

Permalink
Merge pull request #865 from kmuto/return-critical-on-reachable
Browse files Browse the repository at this point in the history
return CRITICAL instead of UNKNOWN when check-redis reachable is failed
  • Loading branch information
kmuto authored Jun 10, 2024
2 parents 4b4c73c + 0b65677 commit 9867ab1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion check-redis/lib/check-redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func checkReachable(args []string) *checkers.Checker {

c, info, err := connectRedisGetInfo(opts)
if err != nil {
return checkers.Unknown(err.Error())
return checkers.Critical(err.Error())
}
defer c.Close()

Expand Down
8 changes: 8 additions & 0 deletions check-redis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ password=passpass
port=16379
image=redis:5

RET=$($plugin reachable --port $port --password $password)
# check-redis should return CRITICAL (exit code 2) when the server is unreachable
if [ $? -ne 2 ]; then
echo "$prog: $plugin returned $? (2 is expected)" >&2
exit 2
fi
echo "$RET"

docker run --name "test-$plugin" -p "$port:6379" -d "$image" --requirepass "$password"
trap 'docker stop test-$plugin; docker rm test-$plugin; exit' EXIT
sleep 10
Expand Down

0 comments on commit 9867ab1

Please sign in to comment.