-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker_dangling_space
More file actions
executable file
·38 lines (30 loc) · 1.02 KB
/
docker_dangling_space
File metadata and controls
executable file
·38 lines (30 loc) · 1.02 KB
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
#!/bin/bash
#
# Graphs the disk-space used up by dangling volumes. You probably want this to stay at 0
#
DOCKER=${docker_path:-/usr/bin/docker}
VOLUME_FOLDER=${volume_path:-/var/lib/docker/volumes}
case $1 in
autoconf)
if [ -x ${DOCKER} ] ; then
echo "yes"
else
echo "no ('${DOCKER}' is not executable. You can override the path using the 'docker_path' environment variable)!"
fi
exit 0;;
config)
echo "graph_title Dangling Volumes Size"
echo "graph_vlabel size"
echo "graph_category docker"
echo "graph_printf %3.0lf"
echo "graph_args --base 1024 --lower-limit 0"
echo "dangling_size.label Size of dangling volumes"
echo "upgrades.draw AREA"
exit 0;;
esac
TOTAL_SPACE=0
for line in $(${DOCKER} volume ls -f dangling=true | cut -c "21-" | tail -n +2); do
folder_size=$(du -s ${VOLUME_FOLDER}/${line} | cut -f 1)
TOTAL_SPACE=$(($TOTAL_SPACE + $folder_size))
done
echo dangling_size.value ${TOTAL_SPACE}