From 3bc264de2d103e6fc25849165503c1f31b356434 Mon Sep 17 00:00:00 2001 From: Fyodor Yarochkin Date: Mon, 16 Jan 2012 16:50:22 +0800 Subject: [PATCH] Riak memory monitoring --- plugins/other/riak_memory | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 plugins/other/riak_memory diff --git a/plugins/other/riak_memory b/plugins/other/riak_memory new file mode 100755 index 00000000..72007c29 --- /dev/null +++ b/plugins/other/riak_memory @@ -0,0 +1,47 @@ +#!/usr/bin/python + + +import urllib2 +import sys + +try: + import json +except ImportError: + import simplejson as json + + +names = ["memory_total","memory_processes","memory_processes_used","memory_system","memory_atom","memory_atom_used","memory_binary","memory_code","memory_ets"] + +def getServerStatus(): + raw = urllib2.urlopen( "http://127.0.0.1:8091/stats" ).read() + return json.loads( raw ) + + + +def doData(): + for name in names: + print name + ".value " + str( getServerStatus()[name] ) + +def doConfig(): + + print "graph_title Riak memory" + print "graph_args --base 1000 -l 0" + print "graph_vlabel memory" + print "graph_category Riak" + + for name in names: + print name + ".label " + name + print name + ".min 0" + print name + ".type GAUGE" + print name + ".max 500000" + print name + "draw LINE1" + + + +if __name__ == "__main__": + if len(sys.argv) > 1 and sys.argv[1] == "config": + doConfig() + else: + doData() + +