-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdu_
More file actions
executable file
·96 lines (81 loc) · 2.22 KB
/
du_
File metadata and controls
executable file
·96 lines (81 loc) · 2.22 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# Graphs disk usage of up to five paths. Any more might make the graph
# unreadable. To graph more paths, you should create multiple profiles
#
# Usage
# =====
#
# - put this script-file somewhere and make it executable
#
# - create a symlink to your munin-plugins folder (appending a profile name)::
#
# ln -s <path/to/du_> </path/to/munin-plugins/du_profilename>
#
# - write a profile config for this plugin::
#
# [du_profilename]
# user root
# env.PATH1 /var/cache/apt-proxy
# env.PATH2 /var/log
#
# - Optionally, you can define a maximum value (in bytes)::
#
# [du_profilename]
# ...
# env.PATH_MAX 1234567890
#
# This will simply draw a horizontal rule in the graph.
#
# Remember: You can only specify up to 5 paths. For more paths you need to
# link a new profile, and create a corresponding config.
#
function get_size() {
if [ $# != 2 ]; then
return
fi
PATH=$1
if [ "${PATH}" ]; then
SIZE=$(/usr/bin/du -bs ${PATH} | /usr/bin/cut -f 1)
echo "${2}.value ${SIZE}"
fi
}
case $1 in
config)
echo "graph_title Per-Folder disk usage (profile $(basename $0))"
echo "graph_vlabel size"
if [ ${PATH_MAX} ]; then
echo "graph_args --base 1024 -l 0 --upper-limit ${PATH_MAX}"
else
echo "graph_args --base 1024 -l 0"
fi
echo "graph_category disk"
if [ ${PATH1} ]; then
echo "path1.label ${PATH1}"
echo "path1.draw AREA"
fi
if [ ${PATH2} ]; then
echo "path2.label ${PATH2}"
echo "path2.draw STACK"
fi
if [ ${PATH3} ]; then
echo "path3.label ${PATH3}"
echo "path3.draw STACK"
fi
if [ ${PATH4} ]; then
echo "path4.label ${PATH4}"
echo "path4.draw STACK"
fi
if [ ${PATH5} ]; then
echo "path5.label ${PATH5}"
echo "path5.draw STACK"
fi
if [ ${PATH_MAX} ]; then
echo "path1.line ${PATH_MAX}:000000:Limit"
fi
exit 0;;
esac
get_size ${PATH1} "path1"
get_size ${PATH2} "path2"
get_size ${PATH3} "path3"
get_size ${PATH4} "path4"
get_size ${PATH5} "path5"