Last active
August 29, 2015 14:04
-
-
Save tcooper/5a895037ab1840b48ce2 to your computer and use it in GitHub Desktop.
Used to send diamond archives to graphite to fill in gaps when server was down.
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/env python | |
# Replace locahost with the hostname of your graphite server | |
import os | |
import socket | |
import sys | |
CARBON_SERVER = 'localhost' | |
CARBON_PORT = 2003 | |
sock = socket.socket() | |
try: | |
sock.connect( (CARBON_SERVER,CARBON_PORT) ) | |
except: | |
print "Connection to %(server)s on port %(port)d failed." % { 'server':CARBON_SERVER, 'port':CARBON_PORT } | |
sys.exit(1) | |
for filename in sys.argv[1:]: | |
try: | |
fp = open(filename, "r") | |
except IOError as e: | |
sys.stderr.write('Cannot access ' + filename + '\n') | |
else: | |
for line in fp: | |
sock.sendall(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment