root / plugins / disk / df_with_nfs @ 8589c6df
Historique | Voir | Annoter | Télécharger (2,5 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# Script to monitor disk usage. |
| 4 |
# |
| 5 |
# Parameters understood: |
| 6 |
# |
| 7 |
# config (required) |
| 8 |
# autoconf (optional - used by munin-config) |
| 9 |
# |
| 10 |
# $Log$ |
| 11 |
# Revision 1.5.2.5 2011/04/20 14:25:07 ward |
| 12 |
# Exclude tmpfs partitions from 'config'. |
| 13 |
# |
| 14 |
# Revision 1.5.2.4 2005/03/12 21:35:07 jimmyo |
| 15 |
# Correct history loss in linux/{df,df_inode}.
|
| 16 |
# |
| 17 |
# Revision 1.5.2.3 2005/03/10 10:04:48 jimmyo |
| 18 |
# Fixed minor bug introduced with yesterdays change. |
| 19 |
# |
| 20 |
# Revision 1.5.2.2 2005/03/09 19:10:32 jimmyo |
| 21 |
# Made linux/df work properly with tmpfs and devmapper (Deb#298442). |
| 22 |
# |
| 23 |
# Revision 1.5.2.1 2005/02/16 22:50:14 jimmyo |
| 24 |
# linux/df* now ignores bind mounts. |
| 25 |
# |
| 26 |
# Revision 1.5 2004/12/09 20:27:45 jimmyo |
| 27 |
# Sort fields in df*-plugins alphabetically. |
| 28 |
# |
| 29 |
# Revision 1.4 2004/09/25 22:29:16 jimmyo |
| 30 |
# Added info fields to a bunch of plugins. |
| 31 |
# |
| 32 |
# Revision 1.3 2004/05/20 13:57:12 jimmyo |
| 33 |
# Set categories to some of the plugins. |
| 34 |
# |
| 35 |
# Revision 1.2 2004/05/18 22:04:30 jimmyo |
| 36 |
# Use "sed 1d" instead of "tail +2" in df plugins (patch by Olivier Delhomme). |
| 37 |
# |
| 38 |
# Revision 1.1 2004/01/02 18:50:01 jimmyo |
| 39 |
# Renamed occurrences of lrrd -> munin |
| 40 |
# |
| 41 |
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo |
| 42 |
# Import of LRRD CVS tree after renaming to Munin |
| 43 |
# |
| 44 |
# Revision 1.2 2003/11/07 17:43:16 jimmyo |
| 45 |
# Cleanups and log entries |
| 46 |
# |
| 47 |
# |
| 48 |
# |
| 49 |
# Magic markers (optional - used by munin-config and installation |
| 50 |
# scripts): |
| 51 |
# |
| 52 |
#%# family=auto |
| 53 |
#%# capabilities=autoconf |
| 54 |
|
| 55 |
MAXLABEL=20 |
| 56 |
|
| 57 |
if [ "$1" = "autoconf" ]; then |
| 58 |
echo yes |
| 59 |
exit 0 |
| 60 |
fi |
| 61 |
|
| 62 |
clean_name() {
|
| 63 |
echo $1 $7 $2 | sed 's/[\/.-]/_/g'| awk "{
|
| 64 |
if (\$3 == \"tmpfs\") |
| 65 |
n=\$1\$2 |
| 66 |
else |
| 67 |
n=\$1 |
| 68 |
print n |
| 69 |
}" |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
if [ "$1" = "config" ]; then |
| 74 |
|
| 75 |
echo 'graph_title Filesystem usage (in %)' |
| 76 |
echo 'graph_args --upper-limit 100 -l 0' |
| 77 |
echo 'graph_vlabel %' |
| 78 |
echo 'graph_category disk' |
| 79 |
echo 'graph_info This graph shows disk usage on the machine.' |
| 80 |
df -T -P -l -x none -x unknown -x udf -x iso9660 -x romfs -x ramfs -x tmpfs | sed 1d | grep -v "//" | sort | while read i; do |
| 81 |
name=`clean_name $i` |
| 82 |
echo -n "$name.label " |
| 83 |
echo $i | awk "{
|
| 84 |
dir=\$7 |
| 85 |
if (length(dir) <= $MAXLABEL) |
| 86 |
print dir |
| 87 |
else |
| 88 |
printf (\"...%s\n\", substr (dir, length(dir)-$MAXLABEL+4, $MAXLABEL-3)) |
| 89 |
print \"$name.info \" \$7 \" (\" \$2 \") -> \" \$1; |
| 90 |
}" |
| 91 |
echo "$name.warning 92" |
| 92 |
echo "$name.critical 98" |
| 93 |
done |
| 94 |
exit 0 |
| 95 |
fi |
| 96 |
|
| 97 |
df -T -P -l -x none -x unknown -x udf -x iso9660 -x romfs -x ramfs -x proc -x sysfs -x tmpfs -x udev | sed 1d | grep -v "//" | while read i; do |
| 98 |
name=`clean_name $i` |
| 99 |
echo -n "$name.value " |
| 100 |
echo $i | awk '{ print $6 }' | cut -f1 -d%
|
| 101 |
done |
