Skip to content

Instantly share code, notes, and snippets.

@vjanelle
Created April 29, 2015 23:49
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 vjanelle/3b9b199b03c629bd012e to your computer and use it in GitHub Desktop.
Save vjanelle/3b9b199b03c629bd012e to your computer and use it in GitHub Desktop.
kafka broker id from host ip address
#!/usr/bin/python
import socket
# The general premise behind this is that kafka needs a unique broker id, and well, the ip address
# of the system has to be unique. They're both 32bit numbers, so why not?
broker_id = int(socket.inet_aton(socket.gethostbyname(socket.gethostname())).encode('hex'),16)
print "kafka_brokerid=%s" % str(broker_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment