Skip to content

Instantly share code, notes, and snippets.

@kashyapp
Created August 30, 2014 03:52
Show Gist options
  • Save kashyapp/f4282165c3709dcdcc0c to your computer and use it in GitHub Desktop.
Save kashyapp/f4282165c3709dcdcc0c to your computer and use it in GitHub Desktop.
matrix that shows partition distribution for a topic across brokers
#!/bin/bash -e
/usr/share/fk-3p-kafka/bin/kafka-topics.sh $ZOOKEEPER --describe --topic $1 \
| grep Leader \
| awk '{print $4,$8}' | sed 's/,/ /' \
| awk '{
for(i=1;i<7;++i){a[i]=0};
sum[$2]++; sum[$3]++;
a[$2]=1; a[$3]=1;
printf "%3d ",$1;
for (i=1;i<7;++i) {printf "%3d ",a[i]}; printf "\n";
} END {
printf "sum ";
for (i=1;i<7;++i) {printf "%3d ",sum[i]}; printf "\n";
}
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment