Forked from kuenishi/riak_stats_growthforecast.py
Last active
August 29, 2015 14:08
-
-
Save binarytemple/94bd247605780acef54f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 urllib | |
| import httplib | |
| import json | |
| import sys | |
| def get_stats(ip, port=80): | |
| url = 'http://%s:%s/stats' % (ip, port) | |
| sock = urllib.urlopen(url) | |
| jsons = sock.read() | |
| obj = json.loads(jsons) | |
| return obj | |
| if __name__ == '__main__': | |
| stat = get_stats(sys.argv[1], 8098) | |
| keys = [ | |
| "converge_delay_last", | |
| "converge_delay_max", | |
| "converge_delay_mean", | |
| "converge_delay_min", | |
| "coord_redirs_total", | |
| "cpu_avg1", | |
| "cpu_avg15", | |
| "cpu_avg5", | |
| "cpu_nprocs", | |
| "executing_mappers", | |
| "gossip_received", | |
| "handoff_timeouts", | |
| "ignored_gossip_total", | |
| "index_fsm_active", | |
| "index_fsm_create", | |
| "index_fsm_create_error", | |
| #"leveldb_read_block_error": "undefined", | |
| "list_fsm_active", | |
| "list_fsm_create", | |
| "list_fsm_create_error", | |
| "mem_allocated", | |
| "mem_total", | |
| "memory_atom", | |
| "memory_atom_used", | |
| "memory_binary", | |
| "memory_code", | |
| "memory_ets", | |
| "memory_processes", | |
| "memory_processes_used", | |
| "memory_system", | |
| "memory_total", | |
| "node_get_fsm_objsize_100", | |
| "node_get_fsm_objsize_95", | |
| "node_get_fsm_objsize_99", | |
| "node_get_fsm_objsize_mean", | |
| "node_get_fsm_objsize_median", | |
| "node_get_fsm_siblings_100", | |
| "node_get_fsm_siblings_95", | |
| "node_get_fsm_siblings_99", | |
| "node_get_fsm_siblings_mean", | |
| "node_get_fsm_siblings_median", | |
| "node_get_fsm_time_100", | |
| "node_get_fsm_time_95", | |
| "node_get_fsm_time_99", | |
| "node_get_fsm_time_mean", | |
| "node_get_fsm_time_median", | |
| "node_gets", | |
| "node_gets_total", | |
| "node_put_fsm_time_100", | |
| "node_put_fsm_time_95", | |
| "node_put_fsm_time_99", | |
| "node_put_fsm_time_mean", | |
| "node_put_fsm_time_median", | |
| "node_puts", | |
| "node_puts_total", | |
| "pbc_active", | |
| "pbc_connects", | |
| "pbc_connects_total", | |
| "pipeline_active", | |
| "pipeline_create_count", | |
| "pipeline_create_error_count", | |
| "pipeline_create_error_one", | |
| "pipeline_create_one", | |
| "postcommit_fail", | |
| "precommit_fail", | |
| "read_repairs", | |
| "read_repairs_total", | |
| "rebalance_delay_last", | |
| "rebalance_delay_max", | |
| "rebalance_delay_mean", | |
| "rebalance_delay_min", | |
| "rejected_handoffs", | |
| "riak_core_stat_ts", | |
| "riak_kv_stat_ts", | |
| "riak_kv_vnodeq_max", | |
| "riak_kv_vnodeq_mean", | |
| "riak_kv_vnodeq_median", | |
| "riak_kv_vnodeq_min", | |
| "riak_kv_vnodeq_total", | |
| "riak_kv_vnodes_running", | |
| "riak_pipe_stat_ts", | |
| "riak_pipe_vnodeq_max", | |
| "riak_pipe_vnodeq_mean", | |
| "riak_pipe_vnodeq_median", | |
| "riak_pipe_vnodeq_min", | |
| "riak_pipe_vnodeq_total", | |
| "riak_pipe_vnodes_running", | |
| "ring_creation_size", | |
| # "ring_members": ["riak@127.0.0.1"], | |
| "ring_num_partitions", | |
| # "ring_ownership": "[{'riak@127.0.0.1',64}]", | |
| "rings_reconciled", | |
| "rings_reconciled_total", | |
| "sys_process_count", | |
| "vnode_gets", | |
| "vnode_gets_total", | |
| "vnode_index_deletes", | |
| "vnode_index_deletes_postings", | |
| "vnode_index_deletes_postings_total", | |
| "vnode_index_deletes_total", | |
| "vnode_index_reads", | |
| "vnode_index_reads_total", | |
| "vnode_index_writes", | |
| "vnode_index_writes_postings", | |
| "vnode_index_writes_postings_total", | |
| "vnode_index_writes_total", | |
| "vnode_puts", | |
| "vnode_puts_total"] | |
| conn = httplib.HTTPConnection('localhost:5125') | |
| # conn.set_debuglevel(5) | |
| header = {'content-type':'application/x-www-form-urlencoded'} | |
| for key in keys: | |
| path = '/api/riak/%s/%s' % (sys.argv[0], key) | |
| params = {'number' : stat[key]} | |
| conn.request('POST', path, urllib.urlencode(params), | |
| header) | |
| res = conn.getresponse() | |
| print res.status, path #, res.read(), params | |
| conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment