Skip to content

Instantly share code, notes, and snippets.

@zsol
Created September 9, 2012 06:20
Show Gist options
  • Save zsol/3682934 to your computer and use it in GitHub Desktop.
Save zsol/3682934 to your computer and use it in GitHub Desktop.
script to check for kafka consumer lag
from kazoo.client import KazooClient
config = {
'consumer_group': '<%= @consumer_group %>',
'topic': '<%= @topic %>'
}
def main():
zk = KazooClient()
zk.start()
partitions = zk.get_children('/consumers/%(consumer_group)s/offsets/%(topic)s' % config)
num_partitions = int(zk.get('/brokers/topics/%(topic)s/0' % config)[0])
if len(partitions) != num_partitions:
print "Croak! Partition fluctuation"
return
# and now go and connect to the broker and get the last offset available...
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment