-
-
Save DeathBorn/f0b76aeb737d1fc8ea1bbf91c4bfbcc4 to your computer and use it in GitHub Desktop.
Get a healthcheck on zookeeper. must be a version that responds to ruok.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOST=$1 | |
PORT=$2 | |
TIMEOUT=5 | |
if [ ! -x /usr/bin/nc ] ; then | |
echo "/usr/bin/nc is missing; required for $0 to run" | |
exit 3 | |
fi | |
if [ -z "$HOST" ] ; then | |
echo "Specify a host to check" | |
exit 3 | |
fi | |
if [ -z "$PORT" ] ; then | |
echo "Specify a zookeeper port to check" | |
exit 3 | |
fi | |
RUOK=`echo ruok | /usr/bin/nc -w $TIMEOUT $HOST $PORT` | |
if [ $? == 1 ] ; then | |
echo "CRITICAL: Zookeeper on $HOST:$PORT is down" | |
exit 2 | |
fi | |
if [ "$RUOK" != "imok" ] ; then | |
echo "CRITICAL: Zookeeper on $HOST:$PORT is not ok" | |
exit 2 | |
else | |
echo "OK: Zookeeper on $HOST:$PORT is responding" | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment