常用命令:
/data/soft/kafka/bin/kafka-consumer-groups.sh --bootstrap-server node03:9092 --group consumer-acts --describe | grep "topic_5" | grep -v grep | awk 'BEGIN{print "消费组\t\tTopic名\t\t分区\t当前Offset\t分区Offset\t积压";sum=0} {print $1,"\t",$2,"\t",$3,"\t",$4,"\t",$5,"\t"$6; sum+=$6}END{print sum, " => 总计"}'
参数:
- --bootstrap-server
- --group
- --list
- --describe
例子
/home/kafka_2.13-2.8.0/bin/kafka-consumer-groups.sh \
--bootstrap-server 192.168.2.47:9092 \
--group saas_sync_trans_pool \
--describe | grep "match_field_notify" | grep -v grep | awk 'BEGIN{printf "\033[41;37m%-30s%-30s%-30s%-30s%-30s%-30s\n\033[0m","消费组","Topic名","分区","当前Offset","分区Offset","积压";sum=0} {printf "%-30s%-30s%-30s%-30s%-30s%-30s\n",$1,$2,$3,$4,$5,$6; sum+=$6}END{print "积压总计:", sum}'