root / plugins / snmp / snmp__netapp_diskusage2_ @ 81db94e2
Historique | Voir | Annoter | Télécharger (6,87 ko)
| 1 | de8aa961 | Claudius | #!/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 | 81db94e2 | Gabriele Pohl | # graph_category netapp # To show plugin in Gallery also in this category |
| 139 | de8aa961 | Claudius | print "graph_category disk\n"; |
| 140 | print "graph_order df64UsedKBytes df64SnapShotUsedKBytes df64SisSavedKBytes df64TotalKBytes df64SnapShotTotalKBytes df64TotalAndSnapTotalKBytes \n"; |
||
| 141 | |||
| 142 | foreach my $k (sort keys %config ) |
||
| 143 | {
|
||
| 144 | print "$k.info $config{$k} of Volume $dfinfo->{$vol}->{dfFileSys}.\n";
|
||
| 145 | print "$k.label $config{$k}\n";
|
||
| 146 | print "$k.min 0\n"; |
||
| 147 | |||
| 148 | if ($k eq "df64TotalKBytes" ) |
||
| 149 | {
|
||
| 150 | print "$k.draw LINE3\n"; |
||
| 151 | } |
||
| 152 | elsif ( $k eq "df64SnapShotTotalKBytes" ) |
||
| 153 | {
|
||
| 154 | print "$k.draw LINE0\n"; |
||
| 155 | } |
||
| 156 | elsif ( $k eq "df64TotalAndSnapTotalKBytes" ) |
||
| 157 | {
|
||
| 158 | print "$k.draw LINE3\n"; |
||
| 159 | } |
||
| 160 | else |
||
| 161 | {
|
||
| 162 | print "$k.draw AREASTACK\n"; |
||
| 163 | } |
||
| 164 | print "$k.type GAUGE\n"; |
||
| 165 | print "$k.cdef $k,1024,*\n" |
||
| 166 | } |
||
| 167 | } |
||
| 168 | |||
| 169 | sub do_fetch_vol |
||
| 170 | {
|
||
| 171 | my (undef, $aggr_name,$vol) = @_; |
||
| 172 | my $sum = 0; |
||
| 173 | my $index = 'U'; |
||
| 174 | my $v = 'U'; |
||
| 175 | |||
| 176 | $index = $dfinfo->{$vol}->{dfIndex};
|
||
| 177 | if ( $dfinfo->{$vol}->{dfFileSys} eq $aggr_name )
|
||
| 178 | {
|
||
| 179 | print "multigraph diskusage2_$aggr_name\n"; |
||
| 180 | } |
||
| 181 | else |
||
| 182 | {
|
||
| 183 | print "multigraph diskusage2_$aggr_name.$dfinfo->{$vol}->{dfFileSys}\n";
|
||
| 184 | } |
||
| 185 | foreach my $k (keys %snapbytes) |
||
| 186 | {
|
||
| 187 | if ( $k eq "df64TotalKBytes" ) |
||
| 188 | {
|
||
| 189 | $sum += $dfinfo->{$index+1}->{$k};
|
||
| 190 | $v = $dfinfo->{$index+1}->{$k};
|
||
| 191 | } |
||
| 192 | else |
||
| 193 | {
|
||
| 194 | $v = $dfinfo->{$index+1}->{$k};
|
||
| 195 | } |
||
| 196 | print "$snapbytes{$k}.value $v\n";
|
||
| 197 | } |
||
| 198 | |||
| 199 | foreach my $k (keys %volbytes) |
||
| 200 | {
|
||
| 201 | if ( $k eq "df64TotalKBytes" ) |
||
| 202 | {
|
||
| 203 | $sum += $dfinfo->{$vol}->{$k};
|
||
| 204 | $v = $dfinfo->{$vol}->{$k};
|
||
| 205 | print "df64TotalAndSnapTotalKBytes.value $sum\n"; |
||
| 206 | } |
||
| 207 | else |
||
| 208 | {
|
||
| 209 | $v = $dfinfo->{$vol}->{$k};
|
||
| 210 | } |
||
| 211 | print "$volbytes{$k}.value $v\n";
|
||
| 212 | } |
||
| 213 | } |
||
| 214 | |||
| 215 | sub do_config_fetch |
||
| 216 | {
|
||
| 217 | my ($func) = @_; |
||
| 218 | my $fcall; |
||
| 219 | my %op = ( |
||
| 220 | 'config' => \&do_config_vol, |
||
| 221 | 'fetch' => \&do_fetch_vol, |
||
| 222 | ); |
||
| 223 | |||
| 224 | my ($host, undef, undef, undef ) = Munin::Plugin::SNMP->config_session(); |
||
| 225 | if ( $func eq "config" ) |
||
| 226 | {
|
||
| 227 | $fcall = $op{config};
|
||
| 228 | print "host_name $host\n" unless $host eq 'localhost'; |
||
| 229 | } |
||
| 230 | elsif ( $func eq "fetch") |
||
| 231 | {
|
||
| 232 | $fcall = $op{fetch};
|
||
| 233 | } |
||
| 234 | foreach my $vol (sort {$a <=> $b} keys %{$dfinfo})
|
||
| 235 | {
|
||
| 236 | $dfinfo->{$vol}->{dfFileSys} =~ s/(\/vol\/)(.*?)\//$2/;
|
||
| 237 | if ( $dfinfo->{$vol}->{dfFileSys} ~~ [ split(' ',$aggrFlexvollist->{$aggr_id}->{aggrFlexvollist}), $aggr_name ])
|
||
| 238 | {
|
||
| 239 | $fcall->($host,$aggr_name,$vol); |
||
| 240 | } |
||
| 241 | } |
||
| 242 | } |
||
| 243 | |||
| 244 | sub do_setaggr {
|
||
| 245 | if ( $0 =~ /netapp_diskusage2_$/) |
||
| 246 | {
|
||
| 247 | die ("Can't run without a symlinked name\n")
|
||
| 248 | } |
||
| 249 | elsif ($0 =~ /netapp_diskusage2_(.+)*$/) |
||
| 250 | {
|
||
| 251 | $aggr_name = $1; |
||
| 252 | foreach my $aggr (keys %{$aggrFlexvollist})
|
||
| 253 | {
|
||
| 254 | if ( $aggr_name =~ $aggrFlexvollist->{$aggr}->{aggrName} )
|
||
| 255 | {
|
||
| 256 | $aggr_id = $aggr; |
||
| 257 | } |
||
| 258 | } |
||
| 259 | } |
||
| 260 | } |
||
| 261 | |||
| 262 | if (defined $ARGV[0]) |
||
| 263 | {
|
||
| 264 | if ($ARGV[0] eq "config") |
||
| 265 | {
|
||
| 266 | do_collect(); |
||
| 267 | do_setaggr(); |
||
| 268 | do_config_fetch("config");
|
||
| 269 | exit 0; |
||
| 270 | } |
||
| 271 | elsif ($ARGV[0] eq "snmpconf") |
||
| 272 | {
|
||
| 273 | print "index 1.3.6.1.4.1.789.1.5.11.1.2.\n"; |
||
| 274 | exit 0; |
||
| 275 | } |
||
| 276 | } |
||
| 277 | else |
||
| 278 | {
|
||
| 279 | do_collect(); |
||
| 280 | do_setaggr(); |
||
| 281 | do_config_fetch("fetch");
|
||
| 282 | } |
||
| 283 | |||
| 284 | exit 0; |
||
| 285 | |||
| 286 | __END__ |
