Skip to content

Instantly share code, notes, and snippets.

@jhaubrich
Last active December 14, 2015 05:08
Show Gist options
  • Save jhaubrich/5032764 to your computer and use it in GitHub Desktop.
Save jhaubrich/5032764 to your computer and use it in GitHub Desktop.
Example API call for graphite
# connecting and writting to round robin database today
from socket import socket
CARBON_SERVER = 'modok'
CARBON_PORT = 2003
sock = socket()
try:
sock.connect( (CARBON_SERVER,CARBON_PORT) )
except:
print "Couldn't connect to %(server)s on port %(port)d, is carbon-agent.py running?" % { 'server':CARBON_SERVER, 'port':CARBON_PORT }
sys.exit(1)
sock.sendall("chi2.1.148 0.9 1361820900")
# ===================================================
# waas abstracted api example
from waas import rrd
with rrd.connect(debug=True) as r:
r.write("chi2.1.148 0.9 1361820900")
# or #
r = rrd.connect(debug=False)
r.write("chi2.1.148 0.9 1361820900")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment