查看各个patition消息的最大位移
sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -1 --broker-list host1:9092,host2:9092,host3:9092
查看各个partition消息的最小位移
sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -2 --broker-list host1:9092,host2:9092,host3:9092
计算可消费的消息个数
a=`sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -1 --broker-list host1:9092,host2:9092,host3:9092|awk -F':' '{print $3}'| awk ' { SUM += $1 } END { print SUM }'`
b=`sh kafka-run-class.sh kafka.tools.GetOffsetShell --topic mytopic --time -2 --broker-list host1:9092,host2:9092,host3:9092|awk -F':' '{print $3}'| awk ' { SUM += $1 } END { print SUM }'`
echo $(($a-$b))