Last active
December 28, 2016 15:44
-
-
Save padilo/345d03dbf65a38d8e96ef4eb46422b5e to your computer and use it in GitHub Desktop.
Check zookeeper's IP registered on a hostname and returns its mode
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
#!/usr/bin/env bash | |
if [ $# -ne 1 ]; then | |
echo "usage: $0 <hostname>" | |
echo "It show the mode the zookeepers are running" | |
exit 1 | |
fi | |
hosts=$(dig $1 +short | sort) | |
for host in $hosts; do | |
echo -n "${host} -> "; echo stat | nc -w2 $host 2181 | grep Mode | |
if [ $? -ne 0 ]; then | |
echo KO | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment