~ubuntu-branches/ubuntu/saucy/munin/saucy

« back to all changes in this revision

Viewing changes to plugins/node.d/snmp__df.in

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 12:54:28 UTC
  • mfrom: (8.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120611125428-k8z25s77rp755vxe
Tags: 2.0.0-1ubuntu1
* Resync with Debian unstable.
* d/munin-node.upstart,munin.upstart: Add upstart configurations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
use strict;
50
50
use Net::SNMP;
51
51
 
52
 
my $DEBUG = 0;
53
52
my $MAXLABEL = 20;
54
53
 
55
54
my $host      = $ENV{host}      || undef;
61
60
 
62
61
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
63
62
{
64
 
        print "index   1.3.6.1.2.1.25.2.3.1.1.\n";
 
63
        print "require 1.3.6.1.2.1.25.2.3.1.1.\n";
65
64
        print "require 1.3.6.1.2.1.25.2.3.1.2. 1.3.6.1.2.1.25.2.1.4\n"; # Type=fixed disk
66
65
        print "require 1.3.6.1.2.1.25.2.3.1.5. [1-9]\n"; # Size > 0
67
66
        exit 0;
78
77
}
79
78
elsif (!defined($host))
80
79
{
81
 
        print "# Debug: $0 -- $1\n" if $DEBUG;
 
80
        print "# Debug: $0 -- $1\n" if $Munin::Plugin::SNMP::DEBUG;
82
81
        die "# Error: couldn't understand what I'm supposed to monitor.";
83
82
}
84
83
 
126
125
        }
127
126
}
128
127
 
129
 
print "# Kept: ", join (',', @keep), "\n" if $DEBUG;
 
128
print "# Kept: ", join (',', @keep), "\n" if $Munin::Plugin::SNMP::DEBUG;
130
129
 
131
130
# Then we take a look at the partitions...
132
131
 
140
139
    {
141
140
        my $mp = get_single ($session, $hrFSMountPoint . $partition);
142
141
        $partitions{$mp}{partition} = $partition;
143
 
        print "# Added partition \"$mp\" as $partition...\n" if $DEBUG
 
142
        print "# Added partition \"$mp\" as $partition...\n" if $Munin::Plugin::SNMP::DEBUG
144
143
    }
145
144
}
146
145
 
153
152
  # solution is to just graph everything that claims to be a FixedDisk,
154
153
  # without checking if it's removable etc
155
154
 
156
 
        print "# Unable to map mountpoints from filesystems to storages. Bugger.\n" if $DEBUG;
 
155
        print "# Unable to map mountpoints from filesystems to storages. Bugger.\n" if $Munin::Plugin::SNMP::DEBUG;
157
156
        $stor_id = get_by_regex ($session, $hrStorageType, "1.3.6.1.2.1.25.2.1.4");
158
157
        %partitions = ();
159
158
 
222
221
        my $handle = shift;
223
222
        my $oid    = shift;
224
223
 
225
 
        print "# Getting single $oid..." if $DEBUG;
 
224
        print "# Getting single $oid..." if $Munin::Plugin::SNMP::DEBUG;
226
225
 
227
226
        $response = $handle->get_request ($oid);
228
227
 
229
228
        if (!defined $response->{$oid})
230
229
        {
231
 
            print "undef\n" if $DEBUG;
 
230
            print "undef\n" if $Munin::Plugin::SNMP::DEBUG;
232
231
            return undef;
233
232
        }
234
233
        else
235
234
        {
236
 
            print "\"$response->{$oid}\"\n" if $DEBUG;
 
235
            print "\"$response->{$oid}\"\n" if $Munin::Plugin::SNMP::DEBUG;
237
236
            return $response->{$oid};
238
237
        }
239
238
}
248
247
        my $ret    = $oid . "0";
249
248
        my $response;
250
249
 
251
 
        print "# Starting browse of $oid...\n" if $DEBUG;
 
250
        print "# Starting browse of $oid...\n" if $Munin::Plugin::SNMP::DEBUG;
252
251
 
253
252
        while (1)
254
253
        {
255
254
                if ($num == 0)
256
255
                {
257
 
                        print "# Checking for $ret...\n" if $DEBUG;
 
256
                        print "# Checking for $ret...\n" if $Munin::Plugin::SNMP::DEBUG;
258
257
                        $response = $handle->get_request ($ret);
259
258
                }
260
259
                if ($num or !defined $response)
261
260
                {
262
 
                        print "# Checking for sibling of $ret...\n" if $DEBUG;
 
261
                        print "# Checking for sibling of $ret...\n" if $Munin::Plugin::SNMP::DEBUG;
263
262
                        $response = $handle->get_next_request ($ret);
264
263
                }
265
264
                if (!$response)
268
267
                }
269
268
                my @keys = keys %$response;
270
269
                $ret = $keys[0];
271
 
                print "# Analyzing $ret (compared to $oid)...\n" if $DEBUG;
 
270
                print "# Analyzing $ret (compared to $oid)...\n" if $Munin::Plugin::SNMP::DEBUG;
272
271
                last unless ($ret =~ /^$oid/);
273
272
                $num++;
274
273
                next unless ($response->{$ret} =~ /$regex/);
275
274
                @keys = split (/\./, $ret);
276
275
                $result->{$keys[-1]} = $response->{$ret};;
277
 
                print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $DEBUG;
 
276
                print "# Index $num: ", $keys[-1], " (", $response->{$ret}, ")\n" if $Munin::Plugin::SNMP::DEBUG;
278
277
        };
279
278
        return $result;
280
279
}