forked from MatthiasLohr/munin-plugins-gitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab_total_repo_count
executable file
·51 lines (45 loc) · 1.5 KB
/
gitlab_total_repo_count
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
#!/usr/bin/env python
from lib import get_gitlab_instance
import os
import sys
gitlab = get_gitlab_instance()
repository_root = gitlab.get_repository_dir()
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
print('graph_title GitLab Repository Count')
print('graph_vlabel Repository Count')
print('graph_args -l 0')
print('graph_category gitlab')
print('repo_count.label Repository Count')
print('repo_count.draw AREA')
print('wiki_count.label Wiki Count')
print('wiki_count.draw STACK')
print('wiki_empty_count.label Empty Wiki Count')
print('wiki_empty_count.draw STACK')
sys.exit(0)
repo_count = 0
wiki_count = 0
wiki_empty_count = 0
try:
namespaces = os.listdir(repository_root)
for namespace in namespaces:
subdir = repository_root + os.sep + namespace
if os.path.isfile(subdir):
continue
repos = os.listdir(subdir)
for repo in repos:
if repo.endswith('.wiki.git'):
try:
if os.listdir(subdir + os.sep + repo + '/objects/pack'):
wiki_count += 1
else:
wiki_empty_count += 1
except OSError:
wiki_empty_count += 1
elif repo.endswith('.git'):
repo_count += 1
except OSError as e:
print(e)
sys.exit(1)
print('repo_count.value ' + str(repo_count))
print('wiki_count.value ' + str(wiki_count))
print('wiki_empty_count.value ' + str(wiki_empty_count))