2014-10-04 19:53:20 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# (c)2009, Christian Kujau <lists@nerdbynature.de> modified by dano229
|
|
|
|
# Based on the 'homedirs' plugin, initially written in Perl by Philipp Gruber <pg@flupps.net>
|
|
|
|
#
|
|
|
|
# We still need a cronjob to update CACHEFILE once in a while, e.g.:
|
|
|
|
# 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache
|
|
|
|
#
|
|
|
|
CACHEFILE=/tmp/munin-du_multidirs.cache
|
|
|
|
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
echo 'graph_title Directory usage'
|
|
|
|
echo 'graph_args --base 1024 -l 1'
|
|
|
|
echo 'graph_vlabel Bytes'
|
|
|
|
echo 'graph_category disk'
|
|
|
|
echo 'graph_info This graph shows the size of several directories'
|
|
|
|
|
|
|
|
awk '!/lost\+found/ {print $2 }' $CACHEFILE | sort | while read label; do
|
|
|
|
field=`echo "$label" | sed 's/^[^A-Za-z_]/_/' | sed 's/[^A-Za-z0-9_]/_/g'`
|
|
|
|
echo "$field".label "$label"
|
|
|
|
echo "$field".draw LINE1
|
|
|
|
# echo "$field".warning 0
|
|
|
|
# echo "$field".critical 0
|
|
|
|
done
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
awk '!/lost\+found/ { sub(/[^a-zA-Z_]/,"_",$2); gsub(/[^a-zA-Z0-9_]/,"_",$2); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2
|