forked from MatthiasLohr/munin-plugins-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab_todos_by_users
More file actions
executable file
·32 lines (25 loc) · 886 Bytes
/
gitlab_todos_by_users
File metadata and controls
executable file
·32 lines (25 loc) · 886 Bytes
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
#!/usr/bin/env python
from lib import get_gitlab_instance
import sys
SHOW_CONFIG = len(sys.argv) >= 2 and sys.argv[1] == 'config'
gitlab = get_gitlab_instance()
db = gitlab.get_db_connection()
if SHOW_CONFIG:
print('graph_title GitLab open ToDo items by users')
print('graph_vlabel ToDo items')
print('graph_args -l 0')
print('graph_category gitlab')
cursor = db.cursor()
cursor.execute(
"SELECT username, COUNT(username) AS count FROM todos"
" JOIN users ON users.id = todos.user_id WHERE todos.state != 'done'"
" GROUP BY username ORDER BY count DESC")
for row in cursor.fetchall():
username = row[0].replace('.', '_')
if SHOW_CONFIG:
print('{0}.draw LINE'.format(username))
print("{0}.label {1}'s ToDos".format(username, row[0]))
else:
print('{0}.value {1:d}'.format(username, row[1]))
cursor.close()
db.close()