forked from hiroakis/munin-riak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
riak_node_get_put
executable file
·76 lines (56 loc) · 1.63 KB
/
riak_node_get_put
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
=head1 NAME
riak_node_get_put - Plugin to monitor the number of get/put operations coordinated by this node including non-local vnodes.
=head1 AUTHOR
Hiroaki Sano
=head1 CONFIGURATION
No configuration
=head1 LICENSE
MIT License
=cut
"""
import sys
import requests
import os
host = os.getenv('riak_host','127.0.0.1')
port = os.getenv('riak_port',8098)
path = os.getenv('riak_path','stats')
def autoconf():
pass
def get_stats():
r = requests.get("http://{}:{}/{}".format(host,port,path))
return r.json()
def config():
print ('graph_title Riak node_gets/puts')
print ('graph_args --base 1000 -l 0')
print ('graph_vlabel operations/second')
print ('graph_category Riak')
print ('graph_period second')
print ('graph_info This graph shows the number of Riak get/put operations')
print ('node_gets.label node gets')
print ('node_gets.type DERIVE')
print ('node_gets.max 1000000')
print ('node_gets.min 0')
print ('node_gets.info The number of get operations')
print ('node_puts.label node puts')
print ('node_puts.type DERIVE')
print ('node_puts.max 1000000')
print ('node_puts.min 0')
print ('node_puts.info The number of put operations')
def main():
if len(sys.argv) > 1:
command = sys.argv[1]
else:
command = ''
if command == 'autoconf':
autoconf()
elif command == 'config':
config()
else:
ret = get_stats()
print ('node_gets.value %s') % ret['node_gets_total']
print ('node_puts.value %s') % ret['node_puts_total']
if __name__ == '__main__':
main()