Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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