forked from MatthiasLohr/munin-plugins-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitlab_total_issues_throughput
executable file
·38 lines (30 loc) · 1.02 KB
/
gitlab_total_issues_throughput
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
#!/usr/bin/env python
from lib import get_gitlab_instance
import sys
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
print('graph_title GitLab issue throughput')
print('graph_vlabel issues / s')
print('graph_args -l 0')
print('graph_category gitlab')
print('count_opened.label opened issues')
print('count_opened.type DERIVE')
print('count_opened.draw AREA')
print('count_opened.colour 00FF00')
print('count_closed.label closed issues')
print('count_closed.type DERIVE')
print('count_closed.draw STACK')
print('count_closed.colour FF0000')
sys.exit(0)
gitlab = get_gitlab_instance()
db = gitlab.get_db_connection()
cursor = db.cursor()
cursor.execute("SELECT COUNT(*) FROM issues")
count_opened = cursor.fetchone()[0]
cursor.close()
cursor = db.cursor()
cursor.execute("SELECT COUNT(*) FROM issues WHERE state = 'closed'")
count_closed = cursor.fetchone()[0]
cursor.close
db.close()
print('count_opened.value ' + str(count_opened))
print('count_closed.value ' + str(count_closed))