Projet

Général

Profil

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

root / plugins / snmp / snmp__netapp_diskusage2_ @ de8aa961

Historique | Voir | Annoter | Télécharger (6,8 ko)

1
#!/usr/bin/perl
2
# -*- perl -*-
3
# vim: ft=perl
4

    
5
=head1 NAME
6

    
7
snmp__netapp_cifs -  Munin plugin to retrieve general cifs information from NetApp storage appliances.
8

    
9
=head1 APPLICABLE SYSTEMS
10

    
11
cifs should be reported by any NetApp storage appliance
12
with SNMP agent daemon activated. See na_snmp(8) for details.
13

    
14
=head1 CONFIGURATION
15

    
16
Unfortunately, SNMPv3 is not fully supported on all NetApp equipments.
17
For this reason, this plugin will use SNMPv2 by default, which is
18
insecure because it doesn't encrypt the community string.
19

    
20
The following parameters will help you get this plugin working :
21

    
22
[snmp_*]
23
env.community MyCommunity
24

    
25
If your community name is 'public', you should really worry about
26
security and immediately reconfigure your appliance.
27

    
28
Please see 'perldoc Munin::Plugin::SNMP' for further configuration.
29

    
30
=head1 INTERPRETATION
31

    
32
The plugin reports various cifs connections, users and open files.
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 cifs OID.
38

    
39
=head1 MAGIC MARKERS
40

    
41
  #%# family=snmpauto
42
  #%# capabilities=snmpconf
43

    
44
=head1 BUGS
45

    
46
This plugin wasn't tested on many hardware and only on Ontap 7.3.x.
47

    
48
=head1 AUTHOR
49

    
50
2013, Claudius Herder
51
NetApp is a registered trademark and Network Appliance is a trademark
52
of Network Appliance, Inc. in the U.S. and other countries.
53

    
54
=head1 LICENSE
55

    
56
GPLv2.
57

    
58
=cut
59

    
60
use strict;
61
use warnings;
62
use Munin::Plugin;
63
use Munin::Plugin::SNMP;
64
need_multigraph();
65

    
66
my %volbytes =
67
(
68
    df64TotalKBytes    => 'df64TotalKBytes',
69
    df64UsedKBytes     => 'df64UsedKBytes',
70
    df64SisSavedKBytes => 'df64SisSavedKBytes',
71
);
72
my %snapbytes =
73
(
74
    df64TotalKBytes => 'df64SnapShotTotalKBytes',
75
    df64UsedKBytes  => 'df64SnapShotUsedKBytes',
76
);
77
my %config =
78
(
79
    df64TotalKBytes             => 'VolumeSize',
80
    df64UsedKBytes              => 'Used',
81
    df64SisSavedKBytes          => 'SisSaved',
82
    df64SnapShotTotalKBytes     => 'SnapShotReserve',
83
    df64SnapShotUsedKBytes      => 'SnapShotUsed',
84
    df64TotalAndSnapTotalKBytes => 'Total',
85
);
86

    
87
my $dfinfo;
88
my $aggrFlexvollist;
89
my $aggr_name;
90
my $aggr_id;
91

    
92
sub do_collect
93
{
94
    my $session = Munin::Plugin::SNMP->session();
95

    
96
    $dfinfo = $session->get_hash
97
    (
98
        -baseoid => '1.3.6.1.4.1.789.1.5.4.1',
99
        -cols =>
100
        {
101
             1 => 'dfIndex',
102
             2 => 'dfFileSys',
103
            29 => 'df64TotalKBytes',
104
            30 => 'df64UsedKBytes',
105
            31 => 'df64AvailKBytes',
106
            33 => 'df64SisSavedKBytes',
107
        },
108
    );
109
    $aggrFlexvollist = $session->get_hash
110
    (
111
        -baseoid => '1.3.6.1.4.1.789.1.5.11.1',
112
        -cols =>
113
        {
114
            2 => 'aggrName',
115
            9 => 'aggrFlexvollist',
116
        },
117
    );
118
}
119

    
120
sub do_config_vol
121
{
122
    my ($host,$aggr_name,$vol) = @_;
123
    my $extrainfo = '';
124
    if (  $dfinfo->{$vol}->{dfFileSys} eq $aggr_name )
125
    {
126
        print "multigraph diskusage2_$aggr_name\n";
127
        print "graph_title $host disk usage of $aggr_name\n";
128
        print "graph_info This graph shows the disk usage on NetApp host $host\n";
129
    }
130
    else
131
    {
132
        print "multigraph diskusage2_$aggr_name.$dfinfo->{$vol}->{dfFileSys}\n";
133
        print "graph_title $host disk usage of $dfinfo->{$vol}->{dfFileSys} on $aggr_name\n";
134
        print "graph_info This graph shows the disk usage for $dfinfo->{$vol}->{dfFileSys} on NetApp host $host\n";
135
    }
136
    print "graph_args --base 1024 --lower-limit 0\n";
137
    print "graph_vlabel bytes\n";
138
    print "graph_category disk\n";
139
    print "graph_order df64UsedKBytes df64SnapShotUsedKBytes df64SisSavedKBytes df64TotalKBytes df64SnapShotTotalKBytes df64TotalAndSnapTotalKBytes \n";
140

    
141
    foreach my $k (sort keys %config )
142
    {
143
        print "$k.info $config{$k} of Volume $dfinfo->{$vol}->{dfFileSys}.\n";
144
        print "$k.label $config{$k}\n";
145
        print "$k.min 0\n";
146

    
147
        if ($k eq "df64TotalKBytes" )
148
        {
149
            print "$k.draw LINE3\n";
150
        }
151
        elsif ( $k eq "df64SnapShotTotalKBytes" )
152
        {
153
            print "$k.draw LINE0\n";
154
        }
155
        elsif ( $k eq "df64TotalAndSnapTotalKBytes" )
156
        {
157
            print "$k.draw LINE3\n";
158
        }
159
        else
160
        {
161
            print "$k.draw AREASTACK\n";
162
        }
163
        print "$k.type GAUGE\n";
164
        print "$k.cdef $k,1024,*\n"
165
    }
166
}
167

    
168
sub do_fetch_vol
169
{
170
    my (undef, $aggr_name,$vol) = @_;
171
    my $sum = 0;
172
    my $index = 'U';
173
    my $v = 'U';
174

    
175
    $index = $dfinfo->{$vol}->{dfIndex};
176
    if (  $dfinfo->{$vol}->{dfFileSys} eq $aggr_name )
177
    {
178
        print "multigraph diskusage2_$aggr_name\n";
179
    }
180
    else
181
    {
182
        print "multigraph diskusage2_$aggr_name.$dfinfo->{$vol}->{dfFileSys}\n";
183
    }
184
    foreach my $k (keys %snapbytes)
185
    {
186
        if ( $k eq "df64TotalKBytes" )
187
        {
188
            $sum += $dfinfo->{$index+1}->{$k};
189
            $v = $dfinfo->{$index+1}->{$k};
190
        }
191
        else
192
        {
193
            $v = $dfinfo->{$index+1}->{$k};
194
        }
195
        print "$snapbytes{$k}.value $v\n";
196
    }
197

    
198
    foreach my $k (keys %volbytes)
199
    {
200
        if ( $k eq "df64TotalKBytes" )
201
        {
202
            $sum += $dfinfo->{$vol}->{$k};
203
            $v = $dfinfo->{$vol}->{$k};
204
            print "df64TotalAndSnapTotalKBytes.value $sum\n";
205
        }
206
        else
207
        {
208
            $v = $dfinfo->{$vol}->{$k};
209
        }
210
        print "$volbytes{$k}.value $v\n";
211
    }
212
}
213

    
214
sub do_config_fetch
215
{
216
    my ($func) = @_;
217
    my $fcall;
218
    my %op = (
219
        'config' => \&do_config_vol,
220
        'fetch'  => \&do_fetch_vol,
221
    );
222

    
223
    my ($host, undef, undef, undef ) = Munin::Plugin::SNMP->config_session();
224
    if ( $func eq "config" )
225
    {
226
        $fcall = $op{config};
227
        print "host_name $host\n" unless $host eq 'localhost';
228
    }
229
    elsif ( $func eq "fetch")
230
    {
231
        $fcall = $op{fetch};
232
    }
233
    foreach my $vol (sort {$a <=> $b} keys %{$dfinfo})
234
    {
235
        $dfinfo->{$vol}->{dfFileSys} =~ s/(\/vol\/)(.*?)\//$2/;
236
        if ( $dfinfo->{$vol}->{dfFileSys} ~~ [ split(' ',$aggrFlexvollist->{$aggr_id}->{aggrFlexvollist}), $aggr_name ])
237
        {
238
            $fcall->($host,$aggr_name,$vol);
239
        }
240
    }
241
}
242

    
243
sub do_setaggr {
244
    if ( $0 =~ /netapp_diskusage2_$/)
245
    {
246
        die ("Can't run without a symlinked name\n")
247
    }
248
    elsif ($0 =~ /netapp_diskusage2_(.+)*$/)
249
    {
250
        $aggr_name = $1;
251
        foreach my $aggr (keys %{$aggrFlexvollist})
252
        {
253
            if ( $aggr_name =~  $aggrFlexvollist->{$aggr}->{aggrName} )
254
            {
255
                $aggr_id = $aggr;
256
            }
257
        }
258
    }
259
}
260

    
261
if (defined $ARGV[0])
262
{
263
    if ($ARGV[0] eq "config")
264
    {
265
       do_collect();
266
       do_setaggr();
267
       do_config_fetch("config");
268
       exit 0;
269
    }
270
    elsif ($ARGV[0] eq "snmpconf")
271
    {
272
        print "index 1.3.6.1.4.1.789.1.5.11.1.2.\n";
273
        exit 0;
274
    }
275
}
276
else
277
{
278
    do_collect();
279
    do_setaggr();
280
    do_config_fetch("fetch");
281
}
282

    
283
exit 0;
284

    
285
__END__