forked from fsinf/munin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf_abs
executable file
·116 lines (107 loc) · 2.72 KB
/
df_abs
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
#!/bin/sh
#
# Script to monitor absolute 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.2.2.1 2005/02/16 22:50:14 jimmyo
# linux/df* now ignores bind mounts.
#
# Revision 1.2 2004/08/24 13:37:29 ilmari
# Add total line
#
# Revision 1.1 2004/08/24 12:26:48 ilmari
# Added plugin linux/df_abs
#
# 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 bytes)'
echo 'graph_args --base 1024 --lower-limit 0'
echo 'graph_vlabel bytes'
echo 'graph_category disk'
echo 'graph_total Total'
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.cdef $name,1024,*"
size=`echo $i | awk '{print $3}'`
echo "$name.warning $((size / 100 * 92))"
echo "$name.critical $((size / 100 * 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 $4 }'
done