Skip to content

Instantly share code, notes, and snippets.

@tcooper
Last active August 29, 2015 14:04
Show Gist options
  • Save tcooper/5a895037ab1840b48ce2 to your computer and use it in GitHub Desktop.
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.
#!/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