How to list all available Kafka brokers in a cluster?

后端 未结 9 1177
甜味超标
甜味超标 2020-12-22 23:50

I am writing a shell script to monitor kafka brokers.

I have gone through some links and found that if ZooKeeper contains a list of brokers, and if, in this list, th

9条回答
  •  自闭症患者
    2020-12-23 00:07

    I did it like this

    #!/bin/bash
    
    ZK_HOST="localhost"
    ZK_PORT=2181
    
    
    for i in `echo dump | nc $ZK_HOST $ZK_PORT | grep brokers`
    do
        echo $i
        DETAIL=`zkCli -server "$ZK_HOST:$ZK_PORT" get $i 2>/dev/null | tail -n 1`
        echo $DETAIL
    done
    

提交回复
热议问题