Created
December 12, 2013 20:21
-
-
Save queertypes/7934752 to your computer and use it in GitHub Desktop.
Simple UDP server to capture statsd repeater-counter events.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import socket | |
# Handles only counter events | |
stats_capture = re.compile(r'^(.*):(\d+)\|c$') | |
s = socket.socket(socket.AF_INET, | |
socket.SOCK_DGRAM) | |
s.bind(('127.0.0.1', 8001)) | |
while True: | |
data, addr = s.recvfrom(1024) | |
try: | |
bucket, count = stats_capture.match(data).groups() | |
print('Incrementing bucket {0} by {1}'.format(bucket, count)) | |
except AttributeError: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment