Skip to content

Instantly share code, notes, and snippets.

@simonvc
Created April 11, 2013 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonvc/5363656 to your computer and use it in GitHub Desktop.
Save simonvc/5363656 to your computer and use it in GitHub Desktop.
quick little recipe to push riak stats to hostedgraphite.com
import json
from urllib2 import urlopen
import socket
UDP_ADDRESS = "carbon.hostedgraphite.com"
UDP_PORT = 2003
RIAK_STATS_URL='http://localhost:11098/stats'
HG_API_KEY='YOUR_API_KEY'
stats=json.load(urlopen(RIAK_STATS_URL))
nn = stats['nodename'].replace('.', '-')
for k in stats:
if type(1) == type(stats[k]):
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
message='%s.%s.%s %s' % (HG_API_KEY,nn,k,stats[k])
sock.sendto(message, (UDP_ADDRESS, UDP_PORT))
#print message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment