-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathriak_read_repairs
executable file
·68 lines (50 loc) · 1.37 KB
/
riak_read_repairs
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
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
=head1 NAME
riak_read_repairs - Plugin to monitor the number of read repair operations on this node.
=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 read repairs')
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 read repair operations')
print ('read_repair.label read repair')
print ('read_repair.type DERIVE')
print ('read_repair.max 1000000')
print ('read_repair.min 0')
print ('read_repair.info The number of read repair 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 ('read_repair.value %s') % ret['read_repairs_total']
if __name__ == '__main__':
main()