/[nagios-plugins-perl]/trunk/plugins/check_netapp2.pl
ViewVC logotype

Contents of /trunk/plugins/check_netapp2.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 161 - (show annotations) (download)
Fri Nov 13 10:56:18 2015 UTC (5 years ago) by racvision
File MIME type: text/plain
File size: 27880 byte(s)
Check if counter file is correctly open 
1 #!/usr/bin/perl
2
3 #####################################
4 #####################################
5 ### ______ _ =) ###
6 ### | ___ \ | | ###
7 ### | |_/ / __ _ _ __ | | ###
8 ### | / / _` || '_ \ | | ###
9 ### | |\ \| (_| || | | || |____ ###
10 ### \_| \_|\__,_||_| |_|\_____/ ###
11 #####################################
12 #####################################
13 #####################################
14 ## Original version written by
15 ## ran.leibman@gmail.com
16 ## Additionial checks code written
17 ## by laurent.dufour@havas.com
18 ##
19 ## the following parameters has
20 ## been tested against a
21 ## FAS2220
22 ## FAS2240
23 ## FAS3220
24 ## FA2050, NetApp Release 7.3.1.1
25 ## IBM System Storage N6240, Data ONTAP Release 8.1.4P4
26 ##
27 ## DISKSUMMARY|HA|CIFSSESSIONS|
28 ## AUTOSUPPORTSTATUS|NFSOPS|
29 ## CIFSOPS|SHELFINFO
30 ##
31 #####################################
32 #####################################
33
34 use warnings;
35 use strict;
36
37 use POSIX qw(floor);
38 use Net::SNMP;
39 use File::Basename qw(dirname);
40 use Getopt::Long;
41
42 Getopt::Long::Configure('bundling');
43
44 my $stat = 0;
45 my $msg;
46 my $perf;
47 my $script_name = "check_netapp2.pl";
48 my $script_version = 1.1;
49
50 my $counterFilePath="/tmp";
51 my $counterFile;
52
53 my $TIMEOUT = 10;
54
55 my %ERRORS = (
56 'OK' => '0',
57 'WARNING' => '1',
58 'CRITICAL' => '2',
59 'UNKNOWN' => '3',
60 );
61
62 # default return value is UNKNOWN
63 my $state = "UNKNOWN";
64 my $answer = "";
65
66 # time this script was run
67 my $runtime = time();
68
69 my $key;
70 our %snmpIndexes;
71
72
73 # file related variables
74 my $fileRuntime;
75 my $fileHostUptime;
76 my $fileNfsOps;
77 my $fileCifsOps;
78
79 my $snmpHostUptime;
80
81
82 ### SNMP OIDs
83 ###############
84 my $snmpSysUpTime = '.1.3.6.1.2.1.1.3.0';
85 my $snmpFailedFanCount = '.1.3.6.1.4.1.789.1.2.4.2.0';
86 my $snmpFailPowerSupplyCount = '.1.3.6.1.4.1.789.1.2.4.4.0';
87 my $snmpcpuBusyTimePerCent = '.1.3.6.1.4.1.789.1.2.1.3.0';
88 my $snmpenvOverTemperature = '.1.3.6.1.4.1.789.1.2.4.1.0';
89 my $snmpnvramBatteryStatus = '.1.3.6.1.4.1.789.1.2.5.1.0';
90 my $snmpFailedDiskCount = '.1.3.6.1.4.1.789.1.6.4.7.0';
91 my $snmpUpTime = '.1.3.6.1.2.1.1.3.0';
92 my $snmpCacheAge = '.1.3.6.1.4.1.789.1.2.2.23.0';
93 my $snmpGlobalStatus = '.1.3.6.1.4.1.789.1.2.2.4.0';
94 my $snmpGlobalStatus_text = '.1.3.6.1.4.1.789.1.2.2.25.0';
95 my $snmpNdmpSessions = '.1.3.6.1.4.1.789.1.10.2.0';
96 my $snmpCifsSessions = '.1.3.6.1.4.1.789.1.7.2.12.0';
97 my $snmpAutoSupportStatus = '.1.3.6.1.4.1.789.1.2.7.1.0';
98 my $snmpAutoSupportStatus_text = '.1.3.6.1.4.1.789.1.2.7.2.0';
99
100
101
102 my $snmp_netapp_disksummary = '.1.3.6.1.4.1.789.1.6.4';
103 my $snmp_netapp_disksummary_diskTotalCount = '.1.3.6.1.4.1.789.1.6.4.1.0';
104 my $snmp_netapp_disksummary_diskActiveCount = '.1.3.6.1.4.1.789.1.6.4.2.0';
105 my $snmp_netapp_disksummary_diskFailedCount = '.1.3.6.1.4.1.789.1.6.4.7.0';
106 my $snmp_netapp_disksummary_diskSpareCount = '.1.3.6.1.4.1.789.1.6.4.8.0';
107 my $snmp_netapp_disksummary_diskReconstructingCount = '.1.3.6.1.4.1.789.1.6.4.3.0';
108 my $snmp_netapp_disksummary_diskFailedMessage = '.1.3.6.1.4.1.789.1.6.4.10.0';
109
110 my $snmp_netapp_cf = '.1.3.6.1.4.1.789.1.2.3';
111 my $snmp_netapp_cfSettings = '.1.3.6.1.4.1.789.1.2.3.1.0';
112 my $snmp_netapp_cfState = '.1.3.6.1.4.1.789.1.2.3.2.0';
113 my $snmp_netapp_cfCannotTakeoverCause = '.1.3.6.1.4.1.789.1.2.3.3.0';
114 my $snmp_netapp_cfPartnerStatus = '.1.3.6.1.4.1.789.1.2.3.4.0';
115 my $snmp_netapp_cfPartnerName = '.1.3.6.1.4.1.789.1.2.3.6.0';
116 my $snmp_netapp_cfInterconnectStatus = '.1.3.6.1.4.1.789.1.2.3.8.0';
117
118 my $snmpfilesysvolTable = '.1.3.6.1.4.1.789.1.5.8';
119 my $snmpfilesysvolTablevolEntryOptions = "$snmpfilesysvolTable.1.7";
120 my $snmpfilesysvolTablevolEntryvolName = "$snmpfilesysvolTable.1.2";
121
122
123
124
125 my $snmp_netapp_volume_id_table_df = ".1.3.6.1.4.1.789.1.5.4.1";
126 my $snmp_netapp_volume_id_table_df_name = "$snmp_netapp_volume_id_table_df.2";
127 my $snmp_netapp_volume_id_table_df_total = "$snmp_netapp_volume_id_table_df.3";
128 my $snmp_netapp_volume_id_table_df_used = "$snmp_netapp_volume_id_table_df.4";
129 my $snmp_netapp_volume_id_table_df_free = "$snmp_netapp_volume_id_table_df.5";
130 my $snmp_netapp_volume_id_table_df_used_prec = "$snmp_netapp_volume_id_table_df.6";
131
132
133 my $snmp_netapp_enclNumber = '.1.3.6.1.4.1.789.1.21.1.1';
134 my $snmpEnclTable = '.1.3.6.1.4.1.789.1.21.1.2.1';
135 my $snmpEnclTableIndex = "$snmpEnclTable.1";
136 my $snmpEnclTableState = "$snmpEnclTable.2";
137 my $snmpEnclTableShelfAddr = "$snmpEnclTable.3";
138 my $snmpEnclTableProductID = "$snmpEnclTable.5";
139 my $snmpEnclTableProductVendor = "$snmpEnclTable.6";
140 my $snmpEnclTableProductModel = "$snmpEnclTable.7";
141 my $snmpEnclTableProductRevision = "$snmpEnclTable.8";
142 my $snmpEnclTableProductSerial = "$snmpEnclTable.9";
143 my $snmpEnclTablePsFailed = "$snmpEnclTable.15";
144 my $snmpEnclTableFanFailed = "$snmpEnclTable.18";
145 my $snmpEnclTableTempOverFail = "$snmpEnclTable.21";
146 my $snmpEnclTableTempOverWarn = "$snmpEnclTable.22";
147 my $snmpEnclTableTempUnderFail = "$snmpEnclTable.23";
148 my $snmpEnclTableTempUnderWarn = "$snmpEnclTable.24";
149 my $snmpEnclTableCurrentTemp = "$snmpEnclTable.25";
150 my $snmpEnclTableElectronicFailed = "$snmpEnclTable.33";
151 my $snmpEnclTableVoltOverFail = "$snmpEnclTable.36";
152 my $snmpEnclTableVoltOverWarn = "$snmpEnclTable.37";
153 my $snmpEnclTableVoltUnderFail = "$snmpEnclTable.38";
154 my $snmpEnclTableVoltUnderWarn = "$snmpEnclTable.39";
155
156
157 my $snmp_netapp_miscHighNfsOps = '.1.3.6.1.4.1.789.1.2.2.5.0';
158 my $snmp_netapp_miscLowNfsOps = '.1.3.6.1.4.1.789.1.2.2.6.0';
159
160 my $snmp_netapp_miscHighCifsOps = '.1.3.6.1.4.1.789.1.2.2.7.0';
161 my $snmp_netapp_miscLowCifsOps = '.1.3.6.1.4.1.789.1.2.2.8.0';
162
163
164
165 # SNMP Status Codes
166 my %nvramBatteryStatus = (
167 1 => 'ok',
168 2 => 'partially discharged',
169 3 => 'fully discharged',
170 4 => 'not present',
171 5 => 'near end of life',
172 6 => 'at end of life',
173 7 => 'unknown',
174 );
175 my %GlobalStatusIndex = (
176 1 => 'other',
177 2 => 'unknown',
178 3 => 'ok',
179 4 => 'nonCritical',
180 5 => 'critical',
181 6 => 'nonRecoverable',
182 );
183
184 my %AutoSupportStatusIndex = (
185 1 => 'ok',
186 2 => 'smtpFailure',
187 3 => 'postFailure',
188 4 => 'smtpPostFailure',
189 5 => 'unknown',
190 );
191
192 my %cfSettingsIndex = (
193 1 => 'notConfigured',
194 2 => 'enabled',
195 3 => 'disabled',
196 4 => 'takeoverByPartnerDisabled',
197 5 => 'thisNodeDead',
198 );
199
200
201 my %cfStateIndex = (
202 1 => 'dead',
203 2 => 'canTakeover',
204 3 => 'cannotTakeover',
205 4 => 'takeover',
206 );
207
208 my %cfCannotTakeoverCauseIndex = (
209 1 => 'ok',
210 2 => 'unknownReason',
211 3 => 'disabledByOperator',
212 4 => 'interconnectOffline',
213 5 => 'disabledByPartner',
214 6 => 'takeoverFailed',
215 7 => 'mailboxDegraded',
216 8 => 'partnerMailboxUninitialised',
217 9 => 'mailboxVersionMismatch',
218 10 => 'nvramSizeMismatch',
219 11 => 'kernelVersionMismatch',
220 12 => 'partnerBootingUp',
221 13 => 'partnerPerformingRevert',
222 14 => 'performingRevert',
223 15 => 'partnerRequestedTakeover',
224 16 => 'alreadyInTakenoverMode',
225 17 => 'nvramLogUnsynchronized',
226 18 => 'backupMailboxProblems',
227 );
228
229 my %cfPartnerStatusIndex = (
230 1 => 'maybeDown',
231 2 => 'ok',
232 3 => 'dead',
233 );
234
235 my %cfInterconnectStatusIndex = (
236 1 => 'notPresent',
237 2 => 'down',
238 3 => 'partialFailure',
239 4 => 'up',
240 );
241
242 my %EcnlStatusIndex = (
243 1 => 'initializing',
244 2 => 'transitioning',
245 3 => 'active',
246 4 => 'inactive',
247 5 => 'reconfiguring',
248 6 => 'nonexistent',
249 );
250
251 ### Functions
252 ###############
253
254
255 sub _create_session(@) {
256 my ($server, $comm) = @_;
257 my $version = 1;
258 my ($sess, $err) = Net::SNMP->session(
259 -hostname => $server,
260 -version => $version,
261 -community => $comm,
262 -translate => [-timeticks => 0],
263 );
264 if (!defined($sess)) {
265 print "Can't create SNMP session to $server\n";
266 exit(1);
267 }
268 return $sess;
269 }
270
271 sub FSyntaxError($) {
272 my $err = shift;
273 print <<EOU;
274 $err
275
276 Syntax:
277 $script_name
278 Version : $script_version
279
280 -H = Ip/Dns Name of the Filer -w = Warning Value
281 -C = SNMP Community -c = Critical Value
282 -T = Check type --vol = Volume Name
283 -e = vol exclude from snap check
284 TEMP - Temperature
285 FAN - Fan Fail
286 PS - Power Supply Fail
287 CPULOAD - CPU Load (-w -c)
288 NVRAM - NVram Battery Status
289 DISKUSED - Vol Usage Precentage (-w -c --vol)
290 SNAPSHOT - Snapshot Config (-e volname,volname2,volname3)
291 SHELF - Shelf Health
292 SHELFINFO - Shelf Model & Temperature Information
293 NFSOPS - Nfs Ops per seconds (-w -c)
294 CIFSOPS - Cifs Ops per seconds (-w -c)
295 NDMPSESSIONS - Number of ndmp sessions (-w -c)
296 CIFSSESSIONS - Number of cifs sessions (-w -c)
297 GLOBALSTATUS - Global Status of the filer
298 AUTOSUPPORTSTATUS - Auto Support Status of the filer
299 HA - High Availability
300 DISKSUMMARY - Status of disks
301 FAILEDDISK - Number of failed disks
302 UPTIME - Only show\'s uptime
303 CACHEAGE - Cache Age
304
305
306 EOU
307 exit($ERRORS{'UNKNOWN'});
308 }
309
310 sub _get_oid_value(@) {
311 my $sess = shift;
312 my $local_oid = shift;
313 my $r_return = $sess->get_request(-varbindlist => [$local_oid]);
314 return($r_return->{$local_oid});
315 }
316
317 sub _clac_generic_err_stat(@) {
318 my $value = shift;
319 my $value_type = shift;
320 my $tmp_warn = shift;
321 my $tmp_crit = shift;
322 my $scale = shift;
323 my $r_msg;
324 my $r_stat;
325 if ($value <= $tmp_warn) {
326 $r_stat = $ERRORS{'OK'};
327 $r_msg = "OK: $value_type $value $scale";
328 } elsif ($value > $tmp_warn and $value < $tmp_crit) {
329 $r_stat = $ERRORS{'WARNING'};
330 $r_msg = "WARN: $value_type $value $scale";
331 } elsif ($value >= $tmp_crit) {
332 $r_stat = $ERRORS{'CRITICAL'};
333 $r_msg = "CRIT: $value_type $value $scale";
334 }
335 return($r_msg,$r_stat);
336 }
337
338
339 sub _clac_err_stat(@) {
340 my $value = shift;
341 my $value_type = shift;
342 my $tmp_warn = shift;
343 my $tmp_crit = shift;
344 my $r_msg;
345 my $r_stat;
346 if ($value <= $tmp_warn) {
347 $r_stat = $ERRORS{'OK'};
348 $r_msg = "OK: $value_type $value%";
349 } elsif ($value > $tmp_warn and $value < $tmp_crit) {
350 $r_stat = $ERRORS{'WARNING'};
351 $r_msg = "WARN: $value_type $value%";
352 } elsif ($value >= $tmp_crit) {
353 $r_stat = $ERRORS{'CRITICAL'};
354 $r_msg = "CRIT: $value_type $value%";
355 }
356 return($r_msg,$r_stat);
357 }
358
359
360 sub _clac_absolute_err_stat(@) {
361 my $value = shift;
362 my $value_type = shift;
363 my $tmp_warn = shift;
364 my $tmp_crit = shift;
365 my $r_msg;
366 my $r_stat;
367 ($r_msg,$r_stat) = _clac_generic_err_stat($value,$value_type,$tmp_warn,$tmp_crit,"");
368 return($r_msg,$r_stat);
369 }
370
371 sub _clac_minutes_err_stat(@) {
372 my $value = shift;
373 my $value_type = shift;
374 my $tmp_warn = shift;
375 my $tmp_crit = shift;
376 my $r_msg;
377 my $r_stat;
378 ($r_msg,$r_stat) = _clac_generic_err_stat($value,$value_type,$tmp_warn,$tmp_crit,"minutes");
379 return($r_msg,$r_stat);
380 }
381
382
383
384 ### Gather input from user
385 #############################
386 my %opt;
387 $opt{'crit'} = 500;
388 $opt{'warn'} = 500;
389 my $result = GetOptions(\%opt,
390 'filer|H=s',
391 'community|C=s',
392 'check_type|T=s',
393 'warn|w=i',
394 'crit|c=i',
395 'vol|v=s',
396 'exclude|e=s',
397 );
398
399 FSyntaxError("Missing -H") unless defined $opt{'filer'};
400 FSyntaxError("Missing -C") unless defined $opt{'community'};
401 FSyntaxError("Missing -T") unless defined $opt{'check_type'};
402 if ($opt{'vol'}) {
403 if ($opt{'vol'} !~ /^\/.*\/$/) {
404 FSyntaxError("$opt{'vol'} format is /vol/volname/ !");
405 }
406 }
407 if ($opt{'crit'} and $opt{'warn'}) {
408 if ($opt{'warn'} > $opt{'crit'}) {
409 FSyntaxError("Warning can't be larger then Critical: $opt{'warn'} > $opt{'crit'}");
410 }
411 }
412
413
414 if (!defined($counterFilePath)) {
415 $state = "UNKNOWN";
416 $answer = "Filepath must be specified";
417 print "$state: $answer\n";
418 exit $ERRORS{$state};
419 } # end check for filepath
420
421
422
423
424 # Starting Alaram
425 alarm($TIMEOUT);
426
427 # Establish SNMP Session
428 our $snmp_session = _create_session($opt{'filer'},$opt{'community'});
429
430 # setup counterFile now that we have host IP and oid
431 $counterFile = $counterFilePath."/".$opt{'filer'}.".check-netapp-ng.ops.nagioscache";
432
433 $snmpHostUptime = _get_oid_value($snmp_session,$snmpSysUpTime);
434
435 # READ CACHE DATA FROM FILE IF IT EXISTS
436 if (-e $counterFile) {
437 open(FILE, "$counterFile");
438 chomp($fileRuntime = <FILE>);
439 chomp($fileHostUptime = <FILE>);
440 chomp($fileNfsOps = <FILE>);
441 chomp($fileCifsOps = <FILE>);
442 close(FILE);
443 } # end if file exists
444
445
446 # POPULATE CACHE DATA TO FILE
447
448 if ((-w $counterFile) || (-w dirname($counterFile))) {
449 if ( open(FILE, ">$counterFile") ) {
450 print FILE "$runtime\n";
451 print FILE "$snmpHostUptime\n";
452
453 my $low_nfs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscLowNfsOps);
454 my $high_nfs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscHighNfsOps);
455
456 my $temp_high_ops = $high_nfs_ops << 32;
457 my $total_nfs_ops = $temp_high_ops | $low_nfs_ops;
458
459 print FILE "$total_nfs_ops\n";
460
461 my $low_cifs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscLowCifsOps);
462 my $high_cifs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscHighCifsOps);
463
464 $temp_high_ops = $high_cifs_ops << 32;
465 my $total_cifs_ops = $temp_high_ops | $low_cifs_ops;
466
467 print FILE "$total_cifs_ops\n";
468
469 close(FILE);
470 }
471 } else {
472 $state = "WARNING";
473 $answer = "file $counterFile is not writable\n";
474 print ("$state: $answer\n");
475 exit $ERRORS{$state};
476 } # end if file is writable
477
478
479 # check to see if we pulled data from the cache file or not
480 if ( (!defined($fileRuntime)) && ( ($opt{'check_type'} eq "CIFSOPS") or ($opt{'check_type'} eq "NFSOPS") )) {
481 $state = "OK";
482 $answer = "never cached - caching\n";
483 print "$state: $answer\n";
484 exit $ERRORS{$state};
485 } # end if cache file didn't exist
486
487 # check host's uptime to see if it goes backward
488 if ($fileHostUptime > $snmpHostUptime) {
489 $state = "WARNING";
490 $answer = "uptime goes backward - recaching data\n";
491 print "$state: $answer\n";
492 exit $ERRORS{$state};
493 } # end if host uptime goes backward
494
495 my $elapsedtime=$runtime-$fileRuntime;
496
497 if ($elapsedtime<1){ $elapsedtime=1; }
498
499
500
501 # print "fileHostUptime : ".$fileHostUptime."\n";
502 # print "snmpeHostUptime : ".$snmpHostUptime."\n";
503 #print "elapsedTime : ".$elapsedtime."\n";
504
505
506
507
508
509
510
511 ### Temperature ###
512 if ($opt{'check_type'} eq "TEMP") {
513 my $check = _get_oid_value($snmp_session,$snmpenvOverTemperature);
514 if ($check == 1) {
515 $stat = $ERRORS{'OK'};
516 $msg = "OK: $opt{'check_type'} is ok";
517 } else {
518 $stat = $ERRORS{'CRITICAL'};
519 $msg = "CRIT: Over $opt{'check_type'} !";
520 }
521 $perf = "overtemperature=$check";
522
523 ### Fan ###
524 } elsif ($opt{'check_type'} eq "FAN") {
525 my $check = _get_oid_value($snmp_session,$snmpFailedFanCount);
526 if ($check == 0) {
527 $stat = $ERRORS{'OK'};
528 $msg = "OK: $opt{'check_type'} $check";
529 } else {
530 $stat = $ERRORS{'CRITICAL'};
531 $msg = "CRIT: $opt{'check_type'} $check !";
532 }
533 $perf = "failedfans=$check";
534
535 ### PS ###
536 } elsif ($opt{'check_type'} eq "PS") {
537 my $check = _get_oid_value($snmp_session,$snmpFailPowerSupplyCount);
538 if ($check == 0) {
539 $stat = $ERRORS{'OK'};
540 $msg = "OK: $opt{'check_type'} Fail $check";
541 } else {
542 $stat = $ERRORS{'CRITICAL'};
543 $msg = "CRIT: $opt{'check_type'} Fail $check !";
544 }
545 $perf = "failedpowersupplies=$check";
546
547 ### CPULOAD ###
548 } elsif ($opt{'check_type'} eq "CPULOAD") {
549 my $check = _get_oid_value($snmp_session,$snmpcpuBusyTimePerCent);
550 ($msg,$stat) = _clac_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
551 $perf = "cpuload=$check\%";
552
553 ### NFSOPS ###
554 } elsif ($opt{'check_type'} eq "NFSOPS") {
555 my $low_nfs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscLowNfsOps);
556 my $high_nfs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscHighNfsOps);
557
558 my $temp_high_ops = $high_nfs_ops << 32;
559 my $total_nfs_ops = $temp_high_ops | $low_nfs_ops;
560
561 my $nfsops_per_seconds=floor ( ($total_nfs_ops-$fileNfsOps)/$elapsedtime );
562
563 my $check=$nfsops_per_seconds;
564
565 ($msg,$stat) = _clac_absolute_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
566 $perf = "nfsops=$check";
567
568 ### CIFSOPS ###
569 } elsif ($opt{'check_type'} eq "CIFSOPS") {
570 my $low_cifs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscLowCifsOps);
571 my $high_cifs_ops = _get_oid_value($snmp_session,$snmp_netapp_miscHighCifsOps);
572
573 my $temp_high_ops = $high_cifs_ops << 32;
574 my $total_cifs_ops = $temp_high_ops | $low_cifs_ops;
575
576 my $cifsops_per_seconds=floor ( ($total_cifs_ops-$fileCifsOps)/$elapsedtime );
577
578 my $check=$cifsops_per_seconds;
579
580 ($msg,$stat) = _clac_absolute_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
581 $perf = "cifsops=$check";
582
583 ### NVRAM ###
584 } elsif ($opt{'check_type'} eq "NVRAM") {
585 my $check = _get_oid_value($snmp_session,$snmpnvramBatteryStatus);
586 if ($check == 1) {
587 $stat = $ERRORS{'OK'};
588 $msg = "OK: $opt{'check_type'} $nvramBatteryStatus{$check}";
589 } else {
590 $stat = $ERRORS{'CRITICAL'};
591 $msg = "CRIT: $opt{'check_type'} $nvramBatteryStatus{$check}";
592 }
593 # $perf = "nvrambatterystatus=$check";
594
595 ### DISKUSED ###
596 } elsif ($opt{'check_type'} eq "DISKUSED") {
597
598 FSyntaxError("Missing -vol") unless defined $opt{'vol'};
599
600 my $r_vol_tbl = $snmp_session->get_table($snmp_netapp_volume_id_table_df_name);
601 foreach my $key ( keys %{$r_vol_tbl}) {
602
603 print STDERR "Vol: $key ".$$r_vol_tbl{$key}."\n";
604 if ($$r_vol_tbl{$key} eq $opt{'vol'}) {
605 my @tmp_arr = split(/\./, $key);
606 my $oid = pop(@tmp_arr);
607
608 my $used = _get_oid_value($snmp_session,"$snmp_netapp_volume_id_table_df_used.$oid");
609 my $used_prec = _get_oid_value($snmp_session,"$snmp_netapp_volume_id_table_df_used_prec.$oid");
610
611 ($msg,$stat) = _clac_err_stat($used_prec,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
612
613 $perf = "$$r_vol_tbl{$key}=".$used.'k';
614 }
615 }
616 if ($msg =~ /^$/) {
617 $stat = $ERRORS{'WARNING'};
618 $msg = "WARN: Missing volume $opt{'vol'} !";
619 }
620
621 ### SNAPSHOT ###
622 } elsif ($opt{'check_type'} eq "SNAPSHOT") {
623 my @exc_list = split(',',$opt{'exclude'});
624 my @vol_err;
625 my $r_vol_tbl = $snmp_session->get_table($snmpfilesysvolTablevolEntryvolName);
626 foreach my $key ( keys %$r_vol_tbl) {
627 my @tmp_arr = split(/\./, $key);
628 my $oid = pop(@tmp_arr);
629 my $vol_tmp = "$$r_vol_tbl{$key}";
630
631 my $volopt = _get_oid_value($snmp_session,"$snmpfilesysvolTablevolEntryOptions.$oid");
632
633 if ($volopt !~ /nosnap=off/) {
634 my $volcheck = 0;
635 foreach my $exvol (@exc_list) {
636 if ($exvol eq $vol_tmp) {
637 $volcheck++;
638 last;
639 }
640 }
641 if ($volcheck == 0) {
642 push(@vol_err,"$vol_tmp");
643 }
644 }
645 }
646
647 my $err_count = $#vol_err + 1;
648 if ($err_count == 0) {
649 $stat = $ERRORS{'OK'};
650 $msg = "OK: $opt{'check_type'} all ok";
651 } else {
652 $stat = $ERRORS{'CRITICAL'};
653 $msg = "CRIT: $opt{'check_type'} @vol_err not configured";
654 }
655 $perf = "snapoff=$err_count";
656
657 ### FAILEDDISK ###
658 } elsif ($opt{'check_type'} eq "FAILEDDISK") {
659 my $check = _get_oid_value($snmp_session,$snmpFailedDiskCount);
660 if ($check == 0) {
661 $stat = $ERRORS{'OK'};
662 $msg = "OK: $opt{'check_type'} $check";
663 } else {
664 $stat = $ERRORS{'CRITICAL'};
665 $msg = "CRIT: $opt{'check_type'} $check";
666 }
667 $perf = "faileddisks=$check";
668
669 ### DISKSUMMARY ###
670 } elsif ($opt{'check_type'} eq "DISKSUMMARY") {
671 my $diskTotal = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskTotalCount);
672 my $diskActive = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskActiveCount);
673 my $diskFailed = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskFailedCount);
674 my $diskReconstructing = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskReconstructingCount);
675 my $diskSpare = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskSpareCount);
676 my $diskMessage = _get_oid_value($snmp_session,$snmp_netapp_disksummary_diskFailedMessage);
677
678 my $check=$diskFailed;
679
680 if ($check == 0) {
681 $stat = $ERRORS{'OK'};
682 $msg = "OK: $opt{'check_type'} (".$diskMessage.") Disk Summary : Total->".$diskTotal." Active->".$diskActive." Spare->".$diskSpare." Failed ->".$diskFailed. " Reconstructing ->".$diskReconstructing;
683 } elsif ($diskSpare>0) {
684 $stat = $ERRORS{'WARNING'};
685 $msg = "WARN: $opt{'check_type'} (".$diskMessage.") Disk Summary : Total->".$diskTotal." Active->".$diskActive." Spare->".$diskSpare." Failed ->".$diskFailed. " Reconstructing ->".$diskReconstructing;
686 } else {
687 $stat = $ERRORS{'CRITICAL'};
688 $msg = "CRIT: $opt{'check_type'} (".$diskMessage.") Disk Summary : Total->".$diskTotal." Active->".$diskActive." Spare->".$diskSpare." Failed ->".$diskFailed. " Reconstructing ->".$diskReconstructing;
689 }
690 $perf = "faileddisks=$check total=$diskTotal active=$diskActive spare=$diskSpare reconstructing=$diskReconstructing";
691
692 ### HA ###
693 } elsif ($opt{'check_type'} eq "HA") {
694
695 my $cfSettings = _get_oid_value($snmp_session,$snmp_netapp_cfSettings);
696 my $cfState = _get_oid_value($snmp_session,$snmp_netapp_cfState);
697 my $cfCannotTakeoverCause = _get_oid_value($snmp_session,$snmp_netapp_cfCannotTakeoverCause);
698 my $cfPartnerStatus = _get_oid_value($snmp_session,$snmp_netapp_cfPartnerStatus);
699 my $cfPartnerName = _get_oid_value($snmp_session,$snmp_netapp_cfPartnerName);
700 my $cfInterconnectStatus = _get_oid_value($snmp_session,$snmp_netapp_cfInterconnectStatus);
701
702 my $check=$cfSettings;
703
704 if ($cfSettings == 2) {
705
706
707 if ( ($cfPartnerStatus != 2) or ($cfState != 2) or ($cfInterconnectStatus != 4) ) {
708 $stat = $ERRORS{'CRITICAL'};
709 $msg = "CRIT: $opt{'check_type'} HA Summary : Settings->".$cfSettingsIndex{$cfSettings}." State->".$cfStateIndex{$cfState}." Cannot Takeover Cause->".$cfCannotTakeoverCauseIndex{$cfCannotTakeoverCause}." Partner->".$cfPartnerName." Partner Status ->".$cfPartnerStatusIndex{$cfPartnerStatus}." Interconnection State->".$cfInterconnectStatusIndex{$cfInterconnectStatus};
710 } else {
711 $stat = $ERRORS{'OK'};
712 $msg = "OK: $opt{'check_type'} HA Summary : Settings->".$cfSettingsIndex{$cfSettings}." State->".$cfStateIndex{$cfState}." Partner->".$cfPartnerName." Partner Status ->".$cfPartnerStatusIndex{$cfPartnerStatus}." Interconnection State->".$cfInterconnectStatusIndex{$cfInterconnectStatus};
713 }
714
715 } elsif ( ($cfSettings == 3) or ($cfSettings == 1) ) {
716 $stat = $ERRORS{'OK'};
717 $msg = "OK: $opt{'check_type'} HA Summary : Settings ->".$cfSettingsIndex{$cfSettings};
718 } else {
719 $stat = $ERRORS{'CRITICAL'};
720 $msg = "CRIT: $opt{'check_type'} HA Summary : Settings->".$cfSettingsIndex{$cfSettings}." State->".$cfStateIndex{$cfState}." Partner->".$cfPartnerName." Partner Status ->".$cfPartnerStatusIndex{$cfPartnerStatus}." Interconnection State->".$cfInterconnectStatusIndex{$cfInterconnectStatus};
721 }
722 $perf = "hasettings=$check";
723
724
725 ### UPTIME ###
726 } elsif ($opt{'check_type'} eq "UPTIME") {
727 my $check = _get_oid_value($snmp_session,$snmpUpTime);
728 $msg = $opt{'check_type'}.": ".$check;
729 # $check =~ m/^\s*(\d+)\s+days,\s+(\d+):(\d+):(\d+).*$/;
730 $perf = "uptime=" . $check . "s";
731
732 ### CACHEAGE ###
733 } elsif ($opt{'check_type'} eq "CACHEAGE") {
734 my $check = _get_oid_value($snmp_session,$snmpCacheAge);
735 ($msg,$stat) = _clac_minutes_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
736 $perf = "cache_age=$check";
737
738 ### GLOBALSTATUS ###
739 } elsif ($opt{'check_type'} eq "GLOBALSTATUS") {
740 my $check = _get_oid_value($snmp_session,$snmpGlobalStatus);
741 my $global_stat_txt = _get_oid_value($snmp_session,$snmpGlobalStatus_text);
742 my $nagState = 'CRITICAL';
743
744 if ($check == 3) {
745 $nagState = 'OK';
746 } elsif ($check == 4) {
747 $nagState = 'WARNING';
748 } else {
749 $nagState = 'CRITICAL';
750 # $stat = $ERRORS{'CRITICAL'};
751 # $msg = "CRIT: $opt{'check_type'} $GlobalStatusIndex{$check} $check $global_stat_txt";
752 }
753
754 $stat = $ERRORS{$nagState};
755 $msg = "$nagState: $opt{'check_type'} $GlobalStatusIndex{$check}($check): $global_stat_txt";
756 $perf = "globalstatus=$check";
757
758 ### AUTOSUPPORTSTATUS ###
759 } elsif ($opt{'check_type'} eq "AUTOSUPPORTSTATUS") {
760 my $check = _get_oid_value($snmp_session,$snmpAutoSupportStatus);
761 my $autosupport_stat_txt = _get_oid_value($snmp_session,$snmpAutoSupportStatus_text);
762 if ($check == 1) {
763 $stat = $ERRORS{'OK'};
764 $msg = "OK: $opt{'check_type'} $AutoSupportStatusIndex{$check} $check $autosupport_stat_txt";
765 } else {
766 $stat = $ERRORS{'CRITICAL'};
767 $msg = "CRIT: $opt{'check_type'} $AutoSupportStatusIndex{$check} $check $autosupport_stat_txt";
768 }
769 $perf = "autosupportstatus=$check";
770
771 ### NDMPSESSIONS ###
772 } elsif ($opt{'check_type'} eq "NDMPSESSIONS") {
773 my $check = _get_oid_value($snmp_session,$snmpNdmpSessions);
774 ($msg,$stat) = _clac_absolute_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
775 $perf = "ndmpsess=$check";
776
777 ### CIFSSESSIONS ###
778 } elsif ($opt{'check_type'} eq "CIFSSESSIONS") {
779 my $check = _get_oid_value($snmp_session,$snmpCifsSessions);
780 ($msg,$stat) = _clac_absolute_err_stat($check,$opt{'check_type'},$opt{'warn'},$opt{'crit'});
781 $perf = "cifssess=$check";
782
783 ### SHELF ###
784 } elsif ( ($opt{'check_type'} eq "SHELF") or ($opt{'check_type'} eq "SHELFINFO") ) {
785 my @errs;
786 my $r_shelf = $snmp_session->get_table($snmpEnclTableIndex);
787 my $perf_temp = "";
788 foreach my $key ( sort keys %$r_shelf) {
789 my @tmp_arr = split(/\./, $key);
790 my $oid = pop(@tmp_arr);
791
792 my %shelf;
793 my @shelf_err;
794 my $addr = _get_oid_value($snmp_session,"$snmpEnclTableShelfAddr.$oid");
795
796 my $shelf_state = _get_oid_value($snmp_session,"$snmpEnclTableState.$oid");
797
798 if ($shelf_state != 3) {
799 push(@shelf_err,"$addr state $EcnlStatusIndex{$shelf_state},");
800 }
801
802 if ($opt{'check_type'} eq 'SHELFINFO') {
803
804 my $shelf_temp = _get_oid_value($snmp_session,"$snmpEnclTableCurrentTemp.$oid");
805 my @current_temp = split(/\,/, $shelf_temp );
806
807 $shelf{'ShelfNumber'} = $oid;
808 $shelf{'CurrentTemp'} = shift(@current_temp);
809 $shelf{'ProductID'} = _get_oid_value($snmp_session,"$snmpEnclTableProductID.$oid");
810 $shelf{'ProductVendor'} = _get_oid_value($snmp_session,"$snmpEnclTableProductVendor.$oid");
811 $shelf{'ProductModel'} = _get_oid_value($snmp_session,"$snmpEnclTableProductModel.$oid");
812 $shelf{'ProductRevision'} = _get_oid_value($snmp_session,"$snmpEnclTableProductRevision.$oid");
813 $shelf{'ProductSerial'} = _get_oid_value($snmp_session,"$snmpEnclTableProductSerial.$oid");
814 } else {
815 $shelf{'PsFail'} = _get_oid_value($snmp_session,"$snmpEnclTablePsFailed.$oid");
816 $shelf{'FanFail'} = _get_oid_value($snmp_session,"$snmpEnclTableFanFailed.$oid");
817 $shelf{'ElectFail'} = _get_oid_value($snmp_session,"$snmpEnclTableElectronicFailed.$oid");
818 $shelf{'TempOverFail'} = _get_oid_value($snmp_session,"$snmpEnclTableTempOverFail.$oid");
819 $shelf{'TempOver'} = _get_oid_value($snmp_session,"$snmpEnclTableTempOverWarn.$oid");
820 $shelf{'TempUnderFail'} = _get_oid_value($snmp_session,"$snmpEnclTableTempUnderFail.$oid");
821 $shelf{'TempUnderWarn'} = _get_oid_value($snmp_session,"$snmpEnclTableTempUnderWarn.$oid");
822 $shelf{'VoltOverFail'} = _get_oid_value($snmp_session,"$snmpEnclTableVoltOverFail.$oid");
823 $shelf{'VoltOverWarn'} = _get_oid_value($snmp_session,"$snmpEnclTableVoltOverWarn.$oid");
824 $shelf{'VoltUnderFail'} = _get_oid_value($snmp_session,"$snmpEnclTableVoltUnderFail.$oid");
825 $shelf{'VoltUnderWarn'} = _get_oid_value($snmp_session,"$snmpEnclTableVoltUnderWarn.$oid");
826 }
827
828
829 foreach my $subkey ( sort keys %shelf) {
830 if ( $shelf{$subkey} ne "" ) {
831 print "$subkey->$shelf{$subkey} ";
832 if ( $subkey eq "CurrentTemp" ) {
833 $shelf{$subkey} =~ m/^([0-9]+)C.*$/;
834 $perf_temp = "$perf_temp, temp_$shelf{'ShelfNumber'}=$1";
835 }
836 } else {
837 print "$subkey->"; print "None ";
838 }
839
840 if ($opt{'check_type'} eq 'SHELF') {
841 if ($shelf{$subkey}) {
842 push(@shelf_err,"$addr $subkey,")
843 }
844 }
845 }
846
847 { print "\n"; }
848 ##if ($opt{'check_type'} eq "SHELFINFO") { print "\n"; }
849
850 if ($#shelf_err != -1) {
851 push(@errs,@shelf_err)
852 }
853 }
854
855 if ($#errs == -1) {
856 $stat = $ERRORS{'OK'};
857 $msg = "OK: $opt{'check_type'} ok";
858 if ($opt{'check_type'} eq "SHELFINFO") {
859 $perf = "shelfinfo=0$perf_temp";
860 } else {
861 $perf = "shelf=0";
862 }
863 } else {
864 $stat = $ERRORS{'CRITICAL'};
865 $msg = "CRIT: $opt{'check_type'} Errors -";
866 foreach(@errs) {
867 $msg = "$msg $_";
868 }
869 if ($opt{'check_type'} eq "SHELFINFO") {
870 $perf = "shelfinfo=1$perf_temp";
871 } else {
872 $perf = "shelf=1";
873 }
874 }
875 ### Syntax Error ###
876 } else {
877 FSyntaxError("$opt{'check_type'} invalid parameter !");
878 }
879
880
881 print "$msg | $perf\n";
882 exit($stat);

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.8