File: df.in

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (93 lines) | stat: -rw-r--r-- 2,121 bytes parent folder | download | duplicates (5)
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
#!@@BASH@@
# -*- sh -*-

: << =cut

=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

=cut

. "$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 Disk usage in percent'
    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.

    # shellcheck disable=SC2086
    $DF -k -l ${only:-} | $TAIL +2 | while read -r dev size used avail pct mnt; do

	case $dev:$mnt in
	    /usr/lib*|ctfs:*|objfs:*|mnttab:*|sharefs:*|*:/cdrom/*|*:/media/*) 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

# shellcheck disable=SC2034,SC2086
$DF -k -l ${only:-} | $TAIL +2 | while read -r dev size used avail pct mnt; do
	case $dev:$mnt in
	    /usr/lib*|ctfs:*|objfs:*|mnttab:*|sharefs:*|*:/cdrom/*|*:/media/*) continue;;
	    swap:*) name=$(clean_fieldname "$mnt");;
	    *:*)    name=$(clean_fieldname "$dev");;
	esac
        echo "$name.value $pct" | cut -f1 -d%
done