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:
parent
e803e46a50
commit
91e80a8574
@ -1,31 +1,33 @@
|
|||||||
#!/bin/sh
|
#!/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>
|
# 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.:
|
# 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
|
# 0 * * * * root [ -O /tmp/munin-du_multidirs.cache ] && du -sk /dir /dir2 dir3/* > /tmp/munin-du_multidirs.cache
|
||||||
#
|
#
|
||||||
CACHEFILE=/tmp/munin-du_multidirs.cache
|
CACHEFILE=/tmp/munin-du_multidirs.cache
|
||||||
|
|
||||||
if [ "$1" = "autoconf" ]; then
|
if [ "$1" = "autoconf" ]; then
|
||||||
echo yes
|
echo yes
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo 'graph_title Directory usage (in MB)'
|
echo 'graph_title Directory usage'
|
||||||
echo 'graph_args --base 1024 -l 1'
|
echo 'graph_args --base 1024 -l 1'
|
||||||
echo 'graph_vlabel Bytes'
|
echo 'graph_vlabel Bytes'
|
||||||
echo 'graph_category disk'
|
echo 'graph_category disk'
|
||||||
echo 'graph_info This graph shows the size of several directories'
|
echo 'graph_info This graph shows the size of several directories'
|
||||||
|
|
||||||
awk '!/lost\+found/ {gsub(/\//,"_"); print $2 }' $CACHEFILE | sort | while read u; do
|
awk '!/lost\+found/ {print $2 }' $CACHEFILE | sort | while read label; do
|
||||||
echo "$u".label `echo "$u" | sed 's/_/\//g'`
|
field=`echo "$label" | sed 's/^[^A-Za-z_]/_/' | sed 's/[^A-Za-z0-9_]/_/g'`
|
||||||
# echo "$u".warning 0
|
echo "$field".label "$label"
|
||||||
# echo "$u".critical 0
|
echo "$field".draw LINE1
|
||||||
done
|
# echo "$field".warning 0
|
||||||
exit 0
|
# echo "$field".critical 0
|
||||||
fi
|
done
|
||||||
|
exit 0
|
||||||
awk '!/lost\+found/ {gsub(/\//,"_"); print $2".value "$1 * 1024 }' $CACHEFILE | sort -r -n -k2
|
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
|
Loading…
Reference in New Issue
Block a user