forked from fsinf/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf
executable file
·140 lines (131 loc) · 3.46 KB
/
df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/sh
#
# Script to monitor disk usage. The script is forked from the one shipped with
# some munin 1.2.x version because it continously showed some useless
# filesystems. This version is extended so it can exclude certain filesystems
# or devices.
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# Configuration:
#
# This script supports two environment variables:
# EXCLUDE_FS - Exclude given filesystems
# (default: iso9660, udf and none.)
# EXCLUDE_DEVS - Exclude filesystems on given devices. This is useful
# to exclude pseudo filesystems like /dev or /proc.
# (default: "none" - which excludes most pseudo
# filesystems.)
# Note that setting any of these settings *overrides* the default values and
# does NOT *add* to them.
#
# Example configuration:
#
# The following example excludes XFS and JFS filesystems and any filesystems
# with device "none" or "/scratch":
#
# [df]
# env.EXCLUDE_FS=xfs jfs
# env.EXCLUDE_DEVS=none /scratch
#
# $Log$
#
# Revision 2.0
# Added EXLCUDE_FS and EXCLUDE_TYPE paramaters
#
# Revision 1.5.2.4 2005/03/12 21:35:07 jimmyo
# Correct history loss in linux/{df,df_inode}.
#
# Revision 1.5.2.3 2005/03/10 10:04:48 jimmyo
# Fixed minor bug introduced with yesterdays change.
#
# Revision 1.5.2.2 2005/03/09 19:10:32 jimmyo
# Made linux/df work properly with tmpfs and devmapper (Deb#298442).
#
# Revision 1.5.2.1 2005/02/16 22:50:14 jimmyo
# linux/df* now ignores bind mounts.
#
# Revision 1.5 2004/12/09 20:27:45 jimmyo
# Sort fields in df*-plugins alphabetically.
#
# Revision 1.4 2004/09/25 22:29:16 jimmyo
# Added info fields to a bunch of plugins.
#
# Revision 1.3 2004/05/20 13:57:12 jimmyo
# Set categories to some of the plugins.
#
# Revision 1.2 2004/05/18 22:04:30 jimmyo
# Use "sed 1d" instead of "tail +2" in df plugins (patch by Olivier Delhomme).
#
# Revision 1.1 2004/01/02 18:50:01 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.2 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
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
[ -z $EXCLUDE_DEVS ] && EXCLUDE_DEVS="none"
[ -z $EXCLUDE_FS ] && EXCLUDE_FS="iso9660 udf none"
DF_PARAMS='-T -P -l'
for fs in $EXCLUDE_FS; do
DF_PARAMS="$DF_PARAMS -x $fs"
done
clean_name() {
echo $1 | sed 's/[\/.-]/_/g'
}
# Determine if a device should be excluded or not. Return 1 (true) if the device
# name is listed in EXCLUDE_DEVS, 0 (false) otherwise.
exclude_dev() {
if [ "$(echo $EXCLUDE_DEVS | grep -c $1)" -eq "1" ]; then
return 1
else
return 0
fi
}
if [ "$1" = "config" ]; then
echo 'graph_title Filesystem usage (in %)'
echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_vlabel %'
echo 'graph_category disk'
echo 'graph_info This graph shows disk usage on the machine.'
df $DF_PARAMS | sed 1d | while read i; do
exclude_dev $i
if [ "$?" -eq "1" ]; then
continue
fi
name=`clean_name $i`
echo -n "$name.label "
echo $i | awk "{
print \$7
print \"$name.info \" \$7 \" (\" \$2 \") -> \" \$1;
}"
echo "$name.warning 92"
echo "$name.critical 98"
done
exit 0
fi
df $DF_PARAMS | sed 1d | while read i; do
exclude_dev $i
if [ "$?" -eq "1" ]; then
continue
fi
name=`clean_name $i`
echo -n "$name.value "
echo $i | awk '{ print $6 }' | cut -f1 -d%
done