Skip to content

Commit 3286c8b

Browse files
author
Daniel Widerin
committed
Add docker registry dirsize
1 parent 1a5c404 commit 3286c8b

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ user git
3030
[gitlab_redis_*]
3131
user gitlab-redis
3232
#env.redis_socket /var/opt/gitlab/redis/redis.socket # optional, defaults to GitLab omnibus redis instance
33+
34+
[gitlab_total_registry_size]
35+
user registry
3336
```
3437
2. Change your directory to ```/etc/munin/plugins```. Create symlinks for each plugin (```ln -s```) which you want to
3538
activate. Please take a look at the plugin specific documentation.

gitlab_total_registry_size

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
from lib import dirsize
3+
from lib import get_gitlab_instance
4+
import sys
5+
6+
7+
gitlab = get_gitlab_instance()
8+
registry_root = gitlab.get_registry_dir()
9+
10+
if len(sys.argv) >= 2 and sys.argv[1] == 'config':
11+
print('graph_title GitLab docker registry disk usage')
12+
print('graph_vlabel docker registry disk usage')
13+
print('graph_args -l 0 --base 1024')
14+
print('graph_category gitlab')
15+
print('registry_size.label docker registry')
16+
print('registry_size.draw AREA')
17+
sys.exit(0)
18+
19+
registry_size = 0
20+
21+
try:
22+
registry_size = dirsize(registry_root)
23+
except OSError as e:
24+
print(e)
25+
sys.exit(1)
26+
27+
print('registry_size.value ' + str(registry_size))

lib/gitlab.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def get_artifacts_dir(self):
2121
def get_cache_dir(self):
2222
return os.path.join(self.shared_dir, 'cache')
2323

24+
def get_registry_dir(self):
25+
return os.path.join(self.shared_dir, 'registry')
26+
2427
def get_repository_dir(self):
2528
return os.path.join(self.get_data_dir(), 'repositories')
2629

0 commit comments

Comments
 (0)