Created
April 11, 2013 14:07
-
-
Save simonvc/5363656 to your computer and use it in GitHub Desktop.
quick little recipe to push riak stats to hostedgraphite.com
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
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