Skip to content

Instantly share code, notes, and snippets.

@tovbinm
Last active August 29, 2015 13:59
Show Gist options
  • Save tovbinm/10520426 to your computer and use it in GitHub Desktop.
Save tovbinm/10520426 to your computer and use it in GitHub Desktop.
A handy Statsd trap that outputs all the incoming traffic to console
import socket, select
s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s1.bind(('localhost', 8125))
s2 = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP)
s2.bind(('localhost', 8125))
while True:
r, w, x = select.select([s1, s2], [], [])
for i in r:
print i, i.recvfrom(131072)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment