Created
July 24, 2012 20:28
-
-
Save acompa/3172434 to your computer and use it in GitHub Desktop.
Graphite tester
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
#!/usr/bin/python | |
""" Script for submitting data to Graphite. """ | |
import socket | |
import time | |
import sys | |
import random | |
import string | |
CARBON_SERVER = 'prodstats-collector.utility.knewton.net' | |
CARBON_PORT = 2004 | |
# Create random namespace | |
character_pool = string.ascii_lowercase | |
val = int(sys.argv[1]) | |
sock = socket.socket() | |
for _ in xrange(50): | |
namespace = ''.join([random.choice(character_pool) for __ in range(2)]) | |
message = ('Tensile.Load.LoadTest.%s.count %i %d\n' % | |
(namespace, val, int(time.time()))) | |
sock.connect((CARBON_SERVER, CARBON_PORT)) | |
sock.sendall(message) | |
sock.close() | |
time.sleep(0.01) | |
print "Messages complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment