Skip to content

Instantly share code, notes, and snippets.

@padilo
Last active December 28, 2016 15:44
Show Gist options
  • Save padilo/345d03dbf65a38d8e96ef4eb46422b5e to your computer and use it in GitHub Desktop.
Save padilo/345d03dbf65a38d8e96ef4eb46422b5e to your computer and use it in GitHub Desktop.
Check zookeeper's IP registered on a hostname and returns its mode
#!/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