Skip to content

Instantly share code, notes, and snippets.

@acompa
Created July 24, 2012 20:28
Show Gist options
  • Save acompa/3172434 to your computer and use it in GitHub Desktop.
Save acompa/3172434 to your computer and use it in GitHub Desktop.
Graphite tester
#!/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