forked from MatthiasLohr/munin-plugins-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab_redis_used_keys
executable file
·29 lines (22 loc) · 867 Bytes
/
gitlab_redis_used_keys
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
#!/usr/bin/env python
# inspired by the redis munin plugin found at
# http://munin-monitoring.org/browser/munin-contrib/plugins/redis/redis_,
# written 2009 by Gleb Voronich <http://stanly.net.ua/>
from lib import get_gitlab_instance
import re
import sys
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
print('graph_title Redis: Used keys')
print('graph_vlabel Used keys')
print('graph_category gitlab')
print('graph_args -l 0')
print('db0_keys.label db keys')
print('db0_expires.label db expires')
sys.exit(0)
gitlab = get_gitlab_instance()
redis_info = gitlab.get_redis_info()
dbinfo = redis_info['db0']
match = re.match('keys=(?P<keys>[0-9]+),expires=(?P<expires>[0-9]+),avg_ttl=(?P<avg_ttl>[0-9]+)', dbinfo)
values = match.groupdict()
print('db0_keys.value ' + values['keys'])
print('db0_expires.value ' + values['expires'])