2012-01-16 09:41:14 +01:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2012-01-16 16:47:19 +01:00
|
|
|
# This is monitoring plugin for riak Developer's website: http://wiki.basho.com/Riak.html
|
|
|
|
# sample config in /etc/munin/plugin-conf.d/riak
|
|
|
|
#
|
|
|
|
# [riak_*]
|
2012-01-16 16:53:32 +01:00
|
|
|
# env.RIAK_URL http://127.0.0.1:8091/stats
|
2012-01-16 16:47:19 +01:00
|
|
|
# any questions to fygrave at o0o dot nu
|
|
|
|
#
|
|
|
|
# This plugin monitors put/get rate at each node.
|
|
|
|
#
|
|
|
|
|
2012-01-16 09:41:14 +01:00
|
|
|
|
|
|
|
import urllib2
|
|
|
|
import sys
|
2012-01-16 16:47:19 +01:00
|
|
|
import os
|
2012-01-16 09:41:14 +01:00
|
|
|
|
|
|
|
try:
|
|
|
|
import json
|
|
|
|
except ImportError:
|
|
|
|
import simplejson as json
|
|
|
|
|
|
|
|
|
|
|
|
names = ["node_gets_total", "node_puts_total"]
|
|
|
|
|
|
|
|
def getServerStatus():
|
2012-01-16 16:47:19 +01:00
|
|
|
raw = urllib2.urlopen( os.environ.get('RIAK_URL', "http://127.0.0.1:8097/stats") ).read()
|
2012-01-16 09:41:14 +01:00
|
|
|
return json.loads( raw )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def doData():
|
|
|
|
for name in names:
|
|
|
|
print name + ".value " + str( getServerStatus()[name] )
|
|
|
|
|
|
|
|
def doConfig():
|
|
|
|
|
|
|
|
print "graph_title Riak puts and gets"
|
|
|
|
print "graph_args --base 1000 -l 0"
|
|
|
|
print "graph_vlabel puts/gets"
|
2017-02-23 23:12:19 +01:00
|
|
|
print "graph_category other"
|
2012-01-16 09:41:14 +01:00
|
|
|
|
|
|
|
for name in names:
|
|
|
|
print name + ".label " + name
|
|
|
|
print name + ".min 0"
|
|
|
|
print name + ".type COUNTER"
|
|
|
|
print name + ".max 500000"
|
|
|
|
print name + "draw LINE1"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if len(sys.argv) > 1 and sys.argv[1] == "config":
|
|
|
|
doConfig()
|
|
|
|
else:
|
|
|
|
doData()
|
|
|
|
|
|
|
|
|