Use shell script to view zookeeper cluster status
Zooper cluster structure:
Hostname role
Node1 follower
Node2 leader
Node3 follower
Master observer
Content of the script:
#! / bin/bash
Function getstatus () {
# define a function
Exec 9/dev/tcp/$1/2181 2 > / dev/null
# Open the port read / write socket connection of host, and connect with the file descriptor 9
Echo stat > & 9
# send "stat" to socket connection
MODE=$ (cat