Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / disk / snmp__netapp_diskusage_ @ c96bafa1

Historique | Voir | Annoter | Télécharger (5,25 ko)

1 bb70b52b Guillaume Blairon
#!/usr/bin/perl
2
3
=head1 NAME
4
5
snmp__netapp_diskusage_ - Munin plugin to retrieve file systems usage on
6
NetApp storage appliances.
7
8
=head1 APPLICABLE SYSTEMS
9
10
File systems usage stats should be reported by any NetApp storage
11
appliance with SNMP agent daemon activated. See na_snmp(8) for details.
12
13
=head1 CONFIGURATION
14
15
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments.
16
For this reason, this plugin will use SNMPv2 by default, which is
17
insecure because it doesn't encrypt the community string. 
18
19
The following parameters will help you get this plugin working :
20
21
[snmp_*]
22
env.community MyCommunity
23
24
If your community name is 'public', you should really worry about
25
security and immediately reconfigure your appliance.
26
27
Please see 'perldoc Munin::Plugin::SNMP' for further configuration.
28
29
=head1 INTERPRETATION
30
31
The plugin reports file systems usage. This can help you monitoring file
32
systems usage in a given period of time.
33
34
=head1 MIB INFORMATION
35
36
This plugin requires support for the NETWORK-APPLIANCE-MIB issued by
37
Network Appliance. It reports the content of the DfEntry OID.
38
39
=head1 MAGIC MARKERS
40
41
#%# family=snmpauto
42
#%# capabilities=snmpconf
43
44
=head1 VERSION
45
46
v1.0 - 06/22/2009 14:05:03 CEST
47
Initial revision
48
49
=head1 AUTHOR
50
51
This plugin is copyright (c) 2009 by Guillaume Blairon.
52
53
NetApp is a registered trademark and Network Appliance is a trademark
54
of Network Appliance, Inc. in the U.S. and other countries.
55
56
=head1 BUGS
57
58 dfbf9b33 Guillaume Blairon
This plugin wasn't tested on many hardware. If you encounter bugs,
59
please report them to Guillaume Blairon E<lt>L<g@yom.be>E<gt>.
60 bb70b52b Guillaume Blairon
61
=head1 LICENSE
62
63
GPLv2 or (at your option) any later version.
64
65
=cut
66
67
use strict;
68
use warnings;
69
use Munin::Plugin::SNMP;
70
use vars qw($DEBUG);
71
72
$DEBUG = $ENV{'MUNIN_DEBUG'};
73
74
my @palette =
75
   #Better colours from munin 1.3.x
76
   #Greens Blues Oranges Dk yel Dk blu Purple Lime   Reds   Gray
77
 qw(00CC00 0066B3 FF8000 FFCC00 330099 990099 CCFF00 FF0000 808080
78
    008F00 00487D B35A00 B38F00        6B006B 8FB300 B30000 BEBEBE
79
    80FF80 80C9FF FFC080 FFE680 AA80FF EE00CC FF8080
80
    666600 FFBFFF 00FFCC CC6699 999900);
81
82
my %oids = (
83
84
    # - dfHigh.* : 32 most significant bits counters
85
    # - dfLow.*  : 32 least significant bits counters
86
87
    dfHighTotalKBytes => '1.3.6.1.4.1.789.1.5.4.1.14.',
88
    dfLowTotalKBytes  => '1.3.6.1.4.1.789.1.5.4.1.15.',
89
    dfHighUsedKBytes  => '1.3.6.1.4.1.789.1.5.4.1.16.',
90
    dfLowUsedKBytes   => '1.3.6.1.4.1.789.1.5.4.1.17.',
91
    dfHighAvailKBytes => '1.3.6.1.4.1.789.1.5.4.1.18.',
92
    dfLowAvailKBytes  => '1.3.6.1.4.1.789.1.5.4.1.19.',
93
94
);
95
96
sub to_32bit_int {
97
    my ($l, $h) = @_;
98
    return "U" if ((!defined $l) || (!defined $h));
99
    my $bin = unpack( 'B32', pack('N', $l) . pack('N', $h) );
100
    return unpack( 'N', pack('B32', $bin) );
101
}
102
103
if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
104
    print "number 1.3.6.1.4.1.789.1.5.6.0\n";
105
    print "index 1.3.6.1.4.1.789.1.5.4.1.1.\n";
106
    foreach (keys %oids) {
107
        print "require $oids{$_} [0-9]\n";
108
    }
109
    exit 0;
110
}
111
112
my $session = Munin::Plugin::SNMP->session();
113
my ($host, undef, undef, $tail) = Munin::Plugin::SNMP->config_session();
114
my ($df_id, $name_oid);
115
116 dfbf9b33 Guillaume Blairon
if ($tail =~ /^netapp_diskusage_(\d+)$/) {
117 bb70b52b Guillaume Blairon
    $df_id    = $1;
118
    $name_oid = '1.3.6.1.4.1.789.1.5.4.1.2.' . $df_id;
119
} else {
120
    die "Couldn't understand what I'm supposed to monitor";
121
}
122
123
if (defined $ARGV[0] and $ARGV[0] eq "config") {
124
    my $df_name = $session->get_single($name_oid);
125
126
    print "host_name $host\n" unless $host eq 'localhost';
127
    print "graph_title $host disk usage on $df_name\n";
128
    print "graph_args --base 1024 --lower-limit 0\n";
129
    print "graph_vlabel bytes\n";
130
    print "graph_category disk\n";
131
    print "graph_info This graph shows the disk usage for $df_name on NetApp host $host\n";
132
    print "graph_order used avail total\n";
133
    print "used.info The total disk space in KBytes that is in use on the $df_name file system.\n";
134
    print "used.type GAUGE\n";
135
    print "used.draw AREA\n";
136
    print "used.label Used\n";
137
    print "used.cdef used,1024,*\n";
138
    print "used.min 0\n";
139
    print "used.colour $palette[1]\n";
140
    print "avail.info The total disk space in KBytes that is free for use on the $df_name file system.\n";
141
    print "avail.type GAUGE\n";
142
    print "avail.draw STACK\n";
143
    print "avail.label Available\n";
144
    print "avail.cdef avail,1024,*\n";
145
    print "avail.min 0\n";
146
    print "avail.colour $palette[3]\n";
147
    print "total.info The total capacity in KBytes for the $df_name file system.\n";
148
    print "total.type GAUGE\n";
149
    print "total.draw LINE2\n";
150
    print "total.label Total\n";
151
    print "total.cdef total,1024,*\n";
152
    print "total.min 0\n";
153
    print "total.colour $palette[7]\n";
154
155
    exit 0;
156
}
157
158
my $used_l  = $session->get_single($oids{dfLowUsedKBytes}.$df_id);
159
my $used_h  = $session->get_single($oids{dfHighUsedKBytes}.$df_id);
160
my $avail_l = $session->get_single($oids{dfLowAvailKBytes}.$df_id);
161
my $avail_h = $session->get_single($oids{dfHighAvailKBytes}.$df_id);
162
my $total_l = $session->get_single($oids{dfLowTotalKBytes}.$df_id);
163
my $total_h = $session->get_single($oids{dfHighTotalKBytes}.$df_id);
164
165
my $used  = to_32bit_int($used_l, $used_h);
166
my $avail = to_32bit_int($avail_l, $avail_h);
167
my $total = to_32bit_int($total_l, $total_h);
168
169
print "used.value $used\n";
170
print "avail.value $avail\n";
171
print "total.value $total\n";
172
173
exit 0;
174
175
__END__