2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

made it work with pathnames containing dots and other special characters

This commit is contained in:
dano229 2010-10-20 16:14:00 +02:00 committed by Steve Schnepp
parent e803e46a50
commit 91e80a8574

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# (c)2009, Christian Kujau <lists@nerdbynature.de>
# (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.:
@ -9,23 +9,25 @@
CACHEFILE=/tmp/munin-du_multidirs.cache
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Directory usage (in MB)'
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'
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/ {gsub(/\//,"_"); print $2 }' $CACHEFILE | sort | while read u; do
echo "$u".label `echo "$u" | sed 's/_/\//g'`
# echo "$u".warning 0
# echo "$u".critical 0
done
exit 0
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/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2
awk '!/lost\+found/ { sub(/[^a-zA-Z_]/,"_",$2); gsub(/[^a-zA-Z0-9_]/,"_",$2); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2