puppet/munin/files/plugins/df
2009-09-12 11:25:56 +03:00

78 lines
1.8 KiB
Bash
Executable file

#!/bin/sh
#
# Script to monitor disk usage.
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# $Log$
# Revision 1.5 2004/12/09 20:27:45 jimmyo
# Sort fields in df*-plugins alphabetically.
#
# Revision 1.4 2004/05/18 22:04:29 jimmyo
# Use "sed 1d" instead of "tail +2" in df plugins (patch by Olivier Delhomme).
#
# Revision 1.3 2004/01/29 19:39:00 jimmyo
# Generic plugins now use printf instead of echo -n, as this is more portable (SF#885564)
#
# Revision 1.2 2004/01/29 18:57:39 jimmyo
# Disabled plugins df and df_inode on Solaris (SF#882274).
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.6 2003/11/07 17:43:16 jimmyo
# Cleanups and log entries
#
#
#
# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf
MAXLABEL=20
if [ "$1" = "autoconf" ]; then
if [ `uname -s` = SunOS ]; then
echo no
exit 1
else
echo yes
exit 0
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Filesystem usage (in %)'
echo 'graph_category disk'
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_vlabel %'
df -l | sed 1d | grep -v "//" | sort | while read i; do
name=`echo $i | sed 's/[\/.-]/_/g'| awk '{ print $1 }'`
printf "$name.label "
echo $i | awk "{
dir=\$6
if (length(dir) <= $MAXLABEL)
print dir
else
printf (\"...%s\n\", substr (dir, length(dir)-$MAXLABEL+4, $MAXLABEL-3))
}"
echo "$name.warning 92"
echo "$name.critical 98"
done
exit 0
fi
df -P -l | sed 1d | grep -v "//" | while read i; do
name=`echo $i | sed 's/[\/.-]/_/g'| awk '{ print $1 ".value " }'`
printf "$name "
echo $i | awk '{ print $5 }' | cut -f1 -d%
done