plugin-homedirs: du_multidirs

File du_multidirs, 0.9 kB (added by ckujau, 3 years ago)

Munin plugin to monitor the size of one or more directories, sh(1) version

Line 
1 #!/bin/sh
2 #
3 # (c)2009, Christian Kujau <lists@nerdbynature.de>
4 # Based on the 'homedirs' plugin, initially written in Perl by Philipp Gruber <pg@flupps.net>
5 #
6 # We still need a cronjob to update CACHEFILE once in a while, e.g.:
7 # 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache
8 #
9 CACHEFILE=/tmp/munin-du_multidirs.cache
10
11 if [ "$1" = "autoconf" ]; then
12         echo yes
13         exit 0
14 fi
15
16 if [ "$1" = "config" ]; then
17         echo 'graph_title Directory usage (in MB)'
18         echo 'graph_args --base 1024 -l 1'
19         echo 'graph_vlabel Bytes'
20         echo 'graph_category disk'
21         echo 'graph_info This graph shows the size of several directories'
22
23         awk '!/lost\+found/ {gsub(/\//,"_"); print $2 }' $CACHEFILE | sort | while read u; do
24                 echo "$u".label `echo "$u" | sed 's/_/\//g'`
25 #               echo "$u".warning 0
26 #               echo "$u".critical 0
27         done
28         exit 0
29 fi      
30
31 awk '!/lost\+found/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2