This file is indexed.

/usr/share/munin/plugins/df_inode is in munin-node 1.4.6-3ubuntu3.4.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/perl -w
# -*-  perl -*-

=head1 NAME

df_inode - Munin plugin to monitor inode usage

=head1 APPLICABLE SYSTEMS

Every Linux system with df installed.

=head1 CONFIGURATION

The plugin excludes per default the following special, read-only or
dynamically allocating file systems from graphing:

  none unknown iso9660 squashfs udf romfs ramfs

To change this set the environment variable "exclude" with a list of
space separated fs types.  The environment variables "warning" and
"critical" sets the percentage from which Munin starts to warn about
the disk usage.

This configuration snipplet is an example with the defaults:

  [df_inode]
    env.exclude none unknown iso9660 squashfs udf romfs ramfs debugfs
    env.warning 92
    env.critical 98

Put it in a file in /etc/munin/plugin-conf.d/ and restart the munin-node.

You may specify filesystem specific warning and critical levels:

    env._dev_sda2_warning 98
    env._dev_sda2_critical 99

Devices can be explicitly included or excluded based on their mountpoint or
device name using the include_re and exclude_re environment variables.  These
environment variables are parsed as whitespace separated regular expressions.
For example, if you wish to ignore the filesystem on /dev/sda2 and all
filesystems mounted under /var except /var/tmp, these rules would achieve this:

    env.include_re ^/var/tmp$
    env.exclude_re /dev/sda2 ^/var/

Please note that these expressions are tried against both mountpoints and
device names, therefore broad matches could potentially filter out desired
devices.  Anchoring is also useful for avoiding false positives (as seen in the
example), but not strictly necessary.  Testing with munin-run is always a good
idea.

Also note that a mountpoint that is excluded by filesystem type but included by
RE will not be included.

=head1 USAGE

Link this plugin to /etc/munin/plugins/ and restart the munin-node.

=head1 MAGIC MARKERS

  #%# family=auto
  #%# capabilities=autoconf

=head1 BUGS

Uses device names instead of mount points to identify mounted
filesystems.

=head1 VERSION

  $Id: df_inode.in 4169 2011-04-19 03:01:40Z bldewolf $

=head1 AUTHOR

Ingvar Hagelund

=head1 LICENSE

GPLv2

=cut

use strict;
use Munin::Plugin;

# For these devices use the mount point, the device is useless
my %usemntpt = ( tmpfs => 1, none => 1, udev => 1 );

my $exclude = $ENV{'exclude'} || 'none unknown iso9660 squashfs udf romfs ramfs vfat debugfs simfs';
my $dfopts  = "-P -l -i ".join(' -x ',('',split('\s+',$exclude)));

my $mode = ($ARGV[0] or "print");

# Compile REs from env
my @include_re;
if (defined $ENV{include_re}) {
    foreach my $re (split m{\s+}, $ENV{include_re}) {
        push @include_re, qr/$re/;
    }
}
my @exclude_re;
if (defined $ENV{exclude_re}) {
    foreach my $re (split m{\s+}, $ENV{exclude_re}) {
        push @exclude_re, qr/$re/;
    }
}

sub skip {
    my $name = shift;
    my $mountpt = shift;

    foreach my $re (@include_re) {
        return 0 if ($name =~ $re or $mountpt =~ $re);
    }

    foreach my $re (@exclude_re) {
        return 1 if ($name =~ $re or $mountpt =~ $re);
    }

    return 0;
}

if ($mode eq 'autoconf' ) {
    if (`/usr/bin/perl $0` eq '' ) {
        print "no (no devices to monitor)\n";
    } else {
        print "yes\n";
    }
    exit 0;
}

if ($mode eq 'config' ) {
    # The headers
    print "graph_title Inode usage in percent\n";
    print "graph_args --upper-limit 100 -l 0\n";
    print "graph_vlabel %\n";
    print "graph_scale no\n";
    print "graph_category disk\n";
}

# Read from df
open (DF,"df $dfopts 2>/dev/null |") or die "Unable to open pipe from df: $!";
<DF>; # Skip the header
while (<DF>) {
    next if m{//};

    # Parse the output
    my ($name, undef, $used, $avail, undef, $mountpt, undef) = split(/\s+/, $_, 7);

    next if skip($name, $mountpt);

    # Calculate percentage used
    my $ps = 0;
    $ps = ($used / ($used+$avail)) * 100 if $used;

    $name = $mountpt if defined($usemntpt{$name}) && $usemntpt{$name};
    $name = clean_fieldname($name);

    if($mode eq 'config') {
        print $name, ".label ", $mountpt, "\n";
        print_thresholds($name,undef,undef,92,98);
    } else {
        print $name, ".value ", $ps, "\n";
    }
}
close DF;

# vim: ft=perl : sw=4 : ts=4 : et