-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdf
executable file
·87 lines (77 loc) · 2.16 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
#!/bin/bash
# -*- sh -*-
# =head1 NAME
#
# df - Plugin to monitor disk usage (measuring byte usage in percent)
#
# =head1 CONFIGURATION
#
# This shows the default configuration
#
# [df*]
# env.df /usr/sbin/df
# env.warning 92
# env.critical 98
#
# A device specific warning/critical level is also supported. Append
# the munin label (shown in the plugin display page) and append _warning
# or _critical respectively to get the (environment variable) name.
#
# To limit the monitored filesystems, configure the "only" environment variable.
# For example, to only monitor /, one would add to plugin-conf.d:
#
# [df*]
# env.only /
#
# =back
#
# =head1 AUTHOR
#
# Unknown author
#
# =head1 LICENSE
#
# GPLv2
#
# =head1 MAGIC MARKERS
#
# #%# family=auto
# #%# capabilities=autoconf
. $MUNIN_LIBDIR/plugins/plugin.sh
DF=${df:-/usr/sbin/df}
TAIL=/usr/bin/tail
warning=${warning:-92}
critical=${critical:-98}
if [ "$1" = 'autoconf' ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Filesystem usage (in %)'
echo 'graph_args --upper-limit 100'
echo 'graph_category disk'
echo 'graph_scale no'
# Using the mount point as name is silly as / becomes '' after
# the needed substitutions. So in this incarnation we use the
# device name. Since the plugin already changed names this
# should be ok.
$DF -k -l $only | $TAIL +2 | while read dev size used avail pct mnt; do
case $dev:$mnt in
/.zonecontrol:*|/lib:*|/lib/*|/usr:*|/usr/*|/sbin:*|/bin:*|*:/system/*|proc:*|mnttab:*|fd:*|/dev:*|*:/etc/svc/volatile) continue;;
swap:*) name=$(clean_fieldname $mnt);;
*:*) name=$(clean_fieldname $dev);;
esac
echo "$name.label $mnt"
print_warning "$name"
print_critical "$name"
done
exit 0
fi
$DF -k -l $only | $TAIL +2 | while read dev size used avail pct mnt; do
case $dev:$mnt in
/.zonecontrol:*|/lib:*|/lib/*|/usr:*|/usr/*|/sbin:*|/bin:*|*:/system/*|proc:*|mnttab:*|fd:*|/dev:*|*:/etc/svc/volatile) continue;;
swap:*) name=$(clean_fieldname $mnt);;
*:*) name=$(clean_fieldname $dev);;
esac
echo "$name.value $pct" | cut -f1 -d%
done