Skip to content

Instantly share code, notes, and snippets.

@killerwhile
Last active June 13, 2016 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save killerwhile/46ac7165ce556102a32f761dce6da58f to your computer and use it in GitHub Desktop.
Save killerwhile/46ac7165ce556102a32f761dce6da58f to your computer and use it in GitHub Desktop.
Cmd line checking out of synch paritions

This is a "one liner" shell command to list all partitions with not in-synch replicas (i.e. with a list of in-synch replicas not matching the list of replicas).

Please set ZK variable accordingly.

/usr/hdp/current/kafka-broker/bin/kafka-topics.sh --zookeeper $ZK --describe | grep "Isr: " | while read line; 
do 
    replicas=$(echo $line | sed -e "s/.*Replicas: \([^ ]*\).*/\1/" -e "s/,/\n/g" | sort -n | paste -sd ",");
    isr=$(echo $line | sed -e "s/.*Isr: \([^ ]*\).*/\1/" -e "s/,/\n/g" | sort -n | paste -sd ","); 
    echo "$isr" | grep "^$replicas$" > /dev/null || echo $line;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment