5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2010 Trond H. Amundsen
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 require 5.006; # Perl v5.6.0 or newer is required
29 use POSIX qw(isatty ceil);
30 use Getopt::Long qw(:config no_ignore_case);
32 # Global (package) variables used throughout the code
33 use vars qw( $NAME $VERSION $AUTHOR $CONTACT $E_OK $E_WARNING $E_CRITICAL
34 $E_UNKNOWN $FW_LOCK $USAGE $HELP $LICENSE
35 $snmp_session $snmp_error $omreport $globalstatus $global
36 $linebreak $omopt_chassis $omopt_system $blade
37 $exit_code $snmp $original_sigwarn
38 %check %opt %perfdata %reverse_exitcode %status2nagios
39 %snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
40 %blacklist %nagios_alert_count %count
41 @perl_warnings @controllers @enclosures
42 @report_storage @report_chassis @report_other
45 #---------------------------------------------------------------------
46 # Initialization and global variables
47 #---------------------------------------------------------------------
49 # Small subroutine to collect any perl warnings during execution
50 sub collect_perl_warning {
51 push @perl_warnings, [@_];
54 # Set the WARN signal to use our collect subroutine above
55 $original_sigwarn = $SIG{__WARN__};
56 $SIG{__WARN__} = \&collect_perl_warning;
58 # Version and similar info
59 $NAME = 'check_openmanage';
60 $VERSION = '3.5.7-beta14';
61 $AUTHOR = 'Trond H. Amundsen';
62 $CONTACT = 't.h.amundsen@usit.uio.no';
70 # Firmware update lock file [FIXME: location on Windows?]
71 $FW_LOCK = '/var/lock/.spsetup'; # default on Linux
74 $USAGE = <<"END_USAGE";
75 Usage: $NAME [OPTION]...
83 -p, --perfdata Output performance data
84 -t, --timeout Plugin timeout in seconds
85 -c, --critical Customise temperature critical limits
86 -w, --warning Customise temperature warning limits
87 -d, --debug Debug output, reports everything
88 -h, --help Display this help text
89 -V, --version Display version info
93 -H, --hostname Hostname or IP of the server (needed for SNMP)
94 -C, --community SNMP community string
95 -P, --protocol SNMP protocol version
96 --port SNMP port number
100 -i, --info Prefix any alerts with the service tag
101 -e, --extinfo Append system info to alerts
102 -s, --state Prefix alerts with alert state
103 -S, --short-state Prefix alerts with alert state (abbreviated)
104 -o, --okinfo Verbosity when check result is OK
105 -I, --htmlinfo HTML output with clickable links
107 CHECK CONTROL AND BLACKLISTING:
109 -a, --all Check everything, even log content
110 -b, --blacklist Blacklist missing and/or failed components
111 --only Only check a certain component or alert type
112 --check Fine-tune which components are checked
114 For more information and advanced options, see the manual page or URL:
115 http://folk.uio.no/trondham/software/check_openmanage.html
118 # Version and license text
119 $LICENSE = <<"END_LICENSE";
121 Copyright (C) 2010 $AUTHOR
122 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
123 This is free software: you are free to change and redistribute it.
124 There is NO WARRANTY, to the extent permitted by law.
126 Written by $AUTHOR <$CONTACT>
129 # Options with default values
130 %opt = ( 'blacklist' => [], # blacklisting
131 'check' => [], # check control
132 'critical' => [], # temperature critical limits
133 'warning' => [], # temperature warning limits
134 'timeout' => 30, # default timeout is 30 seconds
135 'debug' => 0, # debugging / verbose output
136 'help' => 0, # display help output
137 'perfdata' => undef, # output performance data
138 'info' => 0, # display servicetag
139 'extinfo' => 0, # display extra info
140 'htmlinfo' => undef, # html tags in output
141 'postmsg' => undef, # post message
142 'state' => 0, # display alert type
143 'short-state' => 0, # display alert type (short)
144 'okinfo' => 0, # default "ok" output level
145 'linebreak' => undef, # specify linebreak
146 'version' => 0, # plugin version info
147 'all' => 0, # check everything
148 'only' => undef, # only one component
149 'omreport' => undef, # omreport path
150 'port' => 161, # default SNMP port
151 'hostname' => undef, # hostname or IP
152 'community' => 'public', # SMNP v1 or v2c
153 'protocol' => 2, # default SNMP protocol 2c
154 'username' => undef, # SMNP v3
155 'authpassword' => undef, # SMNP v3
156 'authkey' => undef, # SMNP v3
157 'authprotocol' => undef, # SMNP v3
158 'privpassword' => undef, # SMNP v3
159 'privkey' => undef, # SMNP v3
160 'privprotocol' => undef, # SMNP v3
161 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
165 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
166 'check=s' => \@{ $opt{check} },
167 'c|critical=s' => \@{ $opt{critical} },
168 'w|warning=s' => \@{ $opt{warning} },
169 't|timeout=i' => \$opt{timeout},
170 'd|debug' => \$opt{debug},
171 'h|help' => \$opt{help},
172 'V|version' => \$opt{version},
173 'p|perfdata:s' => \$opt{perfdata},
174 'i|info' => \$opt{info},
175 'e|extinfo' => \$opt{extinfo},
176 'I|htmlinfo:s' => \$opt{htmlinfo},
177 'postmsg=s' => \$opt{postmsg},
178 's|state' => \$opt{state},
179 'S|short-state' => \$opt{shortstate},
180 'o|ok-info=i' => \$opt{okinfo},
181 'linebreak=s' => \$opt{linebreak},
182 'a|all' => \$opt{all},
183 'only=s' => \$opt{only},
184 'omreport=s' => \$opt{omreport},
185 'port=i' => \$opt{port},
186 'H|hostname=s' => \$opt{hostname},
187 'C|community=s' => \$opt{community},
188 'P|protocol=i' => \$opt{protocol},
189 'U|username=s' => \$opt{username},
190 'authpassword=s' => \$opt{authpassword},
191 'authkey=s' => \$opt{authkey},
192 'authprotocol=s' => \$opt{authprotocol},
193 'privpassword=s' => \$opt{privpassword},
194 'privkey=s' => \$opt{privkey},
195 'privprotocol=s' => \$opt{privprotocol},
196 'use-get_table' => \$opt{use_get_table},
197 ) or do { print $USAGE; exit $E_UNKNOWN };
199 # If user requested help
205 # If user requested version info
213 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
218 # If we're using SNMP
219 $snmp = defined $opt{hostname} ? 1 : 0;
221 # SNMP session variables
222 $snmp_session = undef;
225 # The omreport command
228 # Check flags, override available with the --check option
229 %check = ( 'storage' => 1, # check storage subsystem
230 'memory' => 1, # check memory (dimms)
231 'fans' => 1, # check fan status
232 'power' => 1, # check power supplies
233 'temp' => 1, # check temperature
234 'cpu' => 1, # check processors
235 'voltage' => 1, # check voltage
236 'batteries' => 1, # check battery probes
237 'amperage' => 1, # check power consumption
238 'intrusion' => 1, # check intrusion detection
239 'alertlog' => 0, # check the alert log
240 'esmlog' => 0, # check the ESM log (hardware log)
241 'esmhealth' => 1, # check the ESM log overall health
245 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
247 # Line break from option
248 if (defined $opt{linebreak}) {
249 if ($opt{linebreak} eq 'REG') {
252 elsif ($opt{linebreak} eq 'HTML') {
253 $linebreak = '<br/>';
256 $linebreak = $opt{linebreak};
260 # Exit with status=UNKNOWN if there is firmware upgrade in progress
261 if (!$snmp && -f $FW_LOCK) {
262 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
266 # List of controllers and enclosures
267 @controllers = (); # controllers
268 @enclosures = (); # enclosures
271 @report_storage = (); # messages with associated nagios level (storage)
272 @report_chassis = (); # messages with associated nagios level (chassis)
273 @report_other = (); # messages with associated nagios level (other)
275 # Counters for everything
278 'pdisk' => 0, # number of physical disks
279 'vdisk' => 0, # number of logical drives (virtual disks)
280 'temp' => 0, # number of temperature probes
281 'volt' => 0, # number of voltage probes
282 'amp' => 0, # number of amperage probes
283 'intr' => 0, # number of intrusion probes
284 'dimm' => 0, # number of memory modules
285 'fan' => 0, # number of fan probes
286 'cpu' => 0, # number of CPUs
287 'bat' => 0, # number of batteries
288 'power' => 0, # number of power supplies
290 'Critical' => 0, # critical entries in ESM log
291 'Non-Critical' => 0, # warning entries in ESM log
292 'Ok' => 0, # ok entries in ESM log
295 'Critical' => 0, # critical entries in alert log
296 'Non-Critical' => 0, # warning entries in alert log
297 'Ok' => 0, # ok entries in alert log
304 # Global health status
305 $global = 1; # default is to check global status
306 $globalstatus = $E_OK; # default global health status is "OK"
308 # Nagios error levels reversed
312 $E_WARNING => 'WARNING',
313 $E_CRITICAL => 'CRITICAL',
314 $E_UNKNOWN => 'UNKNOWN',
317 # OpenManage (omreport) and SNMP error levels
320 'Unknown' => $E_CRITICAL,
321 'Critical' => $E_CRITICAL,
322 'Non-Critical' => $E_WARNING,
324 'Non-Recoverable' => $E_CRITICAL,
325 'Other' => $E_CRITICAL,
336 6 => 'Non-Recoverable',
339 # Probe Status via SNMP
342 1 => 'Other', # probe status is not one of the following:
343 2 => 'Unknown', # probe status is unknown (not known or monitored)
344 3 => 'Ok', # probe is reporting a value within the thresholds
345 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
346 5 => 'criticalUpper', # probe has crossed upper critical threshold
347 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
348 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
349 8 => 'criticalLower', # probe has crossed lower critical threshold
350 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
351 10 => 'failed', # probe is not functional
354 # Probe status translated to Nagios alarm levels
357 'Other' => $E_CRITICAL,
358 'Unknown' => $E_CRITICAL,
360 'nonCriticalUpper' => $E_WARNING,
361 'criticalUpper' => $E_CRITICAL,
362 'nonRecoverableUpper' => $E_CRITICAL,
363 'nonCriticalLower' => $E_WARNING,
364 'criticalLower' => $E_CRITICAL,
365 'nonRecoverableLower' => $E_CRITICAL,
366 'failed' => $E_CRITICAL,
369 # System information gathered
372 'bios' => 'N/A', # BIOS version
373 'biosdate' => 'N/A', # BIOS release date
374 'serial' => 'N/A', # serial number (service tag)
375 'model' => 'N/A', # system model
376 'osname' => 'N/A', # OS name
377 'osver' => 'N/A', # OS version
378 'om' => 'N/A', # OMSA version
379 'bmc' => 0, # HAS baseboard management controller (BMC)
380 'rac' => 0, # HAS remote access controller (RAC)
381 'rac_name' => 'N/A', # remote access controller (RAC)
382 'bmc_fw' => 'N/A', # BMC firmware
383 'rac_fw' => 'N/A', # RAC firmware
386 # Adjust which checks to perform
387 adjust_checks() if defined $opt{check};
389 # Blacklisted components
390 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
392 # If blacklisting is in effect, don't check global health status
393 if (scalar keys %blacklist > 0) {
397 # Take into account new hardware and blades
398 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
399 $omopt_system = 'system'; # default "system" option to omreport
400 $blade = 0; # if this is a blade system
402 # Some initializations and checking before we begin
404 snmp_initialize(); # initialize SNMP
405 snmp_check(); # check that SNMP works
406 snmp_detect_blade(); # detect blade via SNMP
409 # Find the omreport binary
411 # Check help output from omreport, see which options are available.
412 # Also detecting blade via omreport.
413 check_omreport_options();
417 #---------------------------------------------------------------------
419 #---------------------------------------------------------------------
422 # Store a message in one of the message arrays
425 my ($type, $msg, $exval, $id) = @_;
426 defined $id or $id = q{};
430 'storage' => \@report_storage,
431 'chassis' => \@report_chassis,
432 'other' => \@report_other,
435 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
440 # Run command, put resulting output lines in an array and return a
441 # pointer to that array
446 open my $CMD, '-|', $command
447 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
451 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
452 and return \@lines };
457 # Run command, put resulting output in a string variable and return it
462 open my $CMD, '-|', $command
463 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
464 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
467 # NOTE: We don't check the return value of close() since omreport
468 # does something weird sometimes.
476 sub snmp_initialize {
477 # Legal SNMP v3 protocols
478 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
479 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
481 # Parameters to Net::SNMP->session()
484 '-port' => $opt{port},
485 '-hostname' => $opt{hostname},
486 '-version' => $opt{protocol},
489 # Parameters for SNMP v3
490 if ($opt{protocol} == 3) {
492 # Username is mandatory
493 if (defined $opt{username}) {
494 $param{'-username'} = $opt{username};
497 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
501 # Authpassword is optional
502 if (defined $opt{authpassword}) {
503 $param{'-authpassword'} = $opt{authpassword};
506 # Authkey is optional
507 if (defined $opt{authkey}) {
508 $param{'-authkey'} = $opt{authkey};
511 # Privpassword is optional
512 if (defined $opt{privpassword}) {
513 $param{'-privpassword'} = $opt{privpassword};
516 # Privkey is optional
517 if (defined $opt{privkey}) {
518 $param{'-privkey'} = $opt{privkey};
521 # Privprotocol is optional
522 if (defined $opt{privprotocol}) {
523 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
524 $param{'-privprotocol'} = $opt{privprotocol};
527 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
528 . "must be one of [des|aes|aes128|3des|3desde]\n";
533 # Authprotocol is optional
534 if (defined $opt{authprotocol}) {
535 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
536 $param{'-authprotocol'} = $opt{authprotocol};
539 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
540 . "must be one of [md5|sha]\n";
545 # Parameters for SNMP v2c or v1
546 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
547 $param{'-community'} = $opt{community};
550 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
554 # Try to initialize the SNMP session
555 if ( eval { require Net::SNMP; 1 } ) {
556 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
557 if (!defined $snmp_session) {
558 printf "SNMP: %s\n", $snmp_error;
563 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
570 # Checking if SNMP works by probing for "chassisModelName", which all
571 # servers should have
574 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
575 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
577 # Typically if remote host isn't responding
578 if (!defined $result) {
579 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
583 # If OpenManage isn't installed or is not working
584 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
585 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
592 # Detecting blade via SNMP
594 sub snmp_detect_blade {
595 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
596 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
598 # Identify blade. Older models (4th and 5th gen models) and/or old
599 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
600 # similar, we assume that this isn't a blade
601 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
608 # Locate the omreport binary
611 # If user has specified path to omreport
612 if (defined $opt{omreport} and -x $opt{omreport}) {
613 $omreport = qq{"$opt{omreport}"};
617 # Possible full paths for omreport
620 '/usr/bin/omreport', # default on Linux
621 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA 6.2.0
622 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
623 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
624 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
625 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
626 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
627 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
630 # Find the one to use
632 foreach my $bin (@omreport_paths) {
634 $omreport = qq{"$bin"};
639 # Exit with status=UNKNOWN if OM is not installed, or we don't
640 # have permission to execute the binary
641 if (!defined $omreport) {
642 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
649 # Checks output from 'omreport -?' and searches for arguments to
650 # omreport, to accommodate deprecated options "chassis" and "system"
651 # (on newer hardware), as well as blade servers.
653 sub check_omreport_options {
654 foreach (@{ run_command("$omreport -? 2>&1") }) {
655 if (m/\A servermodule /xms) {
656 # If "servermodule" argument to omreport exists, use it
657 # instead of argument "system"
658 $omopt_system = 'servermodule';
660 elsif (m/\A mainsystem /xms) {
661 # If "mainsystem" argument to omreport exists, use it
662 # instead of argument "chassis"
663 $omopt_chassis = 'mainsystem';
665 elsif (m/\A modularenclosure /xms) {
666 # If "modularenclusure" argument to omreport exists, assume
667 # that this is a blade
675 # Read the blacklist option and return a hash containing the
676 # blacklisted components
682 if (scalar @{ $opt{blacklist} } >= 0) {
683 foreach my $black (@{ $opt{blacklist} }) {
686 open my $BL, '<', $black
687 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
700 return {} if $#bl < 0;
702 # Parse blacklist string, put in hash
703 foreach my $black (@bl) {
704 my @comps = split m{/}xms, $black;
705 foreach my $c (@comps) {
706 next if $c !~ m/=/xms;
707 my ($key, $val) = split /=/xms, $c;
708 my @vals = split /,/xms, $val;
709 $blacklist{$key} = \@vals;
717 # Read the check option and adjust the hash %check, which is a rough
718 # list of components to be checked
723 # Adjust checking based on the '--all' option
726 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
727 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
730 if (scalar @{ $opt{check} } > 0) {
731 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
735 # set the check hash to check everything
736 map { $_ = 1 } values %check;
741 # Adjust checking based on the '--only' option
742 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
744 if (scalar @{ $opt{check} } > 0) {
745 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
748 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
749 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
753 # reset the check hash
754 map { $_ = 0 } values %check;
756 # adjust the check hash
757 if ($opt{only} eq 'chassis') {
758 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
759 batteries amperage intrusion esmhealth);
762 $check{$opt{only}} = 1;
768 # Adjust checking based on the '--check' option
769 if (scalar @{ $opt{check} } >= 0) {
770 foreach my $check (@{ $opt{check} }) {
773 open my $CL, '<', $check
774 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
787 # Parse checklist string, put in hash
788 foreach my $check (@cl) {
789 my @checks = split /,/xms, $check;
790 foreach my $c (@checks) {
791 next if $c !~ m/=/xms;
792 my ($key, $val) = split /=/xms, $c;
797 # Check if we should check global health status
799 foreach (keys %check) {
800 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
801 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
803 if ($check{$_} == 0) { # found something with checking turned off
813 # Runs omreport and returns an array of anonymous hashes containing
815 # Takes one argument: string containing parameters to omreport
822 # Errors that are OK. Some low-end poweredge (and blades) models
823 # don't have RAID controllers, intrusion detection sensor, or
824 # redundant/instrumented power supplies etc.
827 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
828 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
829 | No\scontrollers\sfound # No RAID controller
830 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
831 | Invalid\scommand:\spwrmonitoring # Older OMSAs lack this command(?)
832 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
835 # Errors that are OK on blade servers
838 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
841 # Run omreport and fetch output
842 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
843 return [] if !defined $rawtext;
845 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
846 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
848 # Openmanage sometimes puts a linebreak between "Error" and the
850 $rawtext =~ s{^Error\s*\n}{Error: }xms;
852 # Parse output, store in array
853 for ((split m{\n}xms, $rawtext)) {
855 next if m{$ok_errors}xms;
856 next if ($blade and m{$ok_blade_errors}xms);
857 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
860 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
861 my @vals = split /;/xms;
862 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed) \z/xms) {
867 push @output, { map { $_ => $vals[$i++] } @keys };
872 # Finally, return the collected information
878 # Checks if a component is blacklisted. Returns 1 if the component is
879 # blacklisted, 0 otherwise. Takes two arguments:
880 # arg1: component name
881 # arg2: component id or index
884 my $name = shift; # component name
885 my $id = shift; # component id
886 my $ret = 0; # return value
888 if (defined $blacklist{$name}) {
889 foreach my $comp (@{ $blacklist{$name} }) {
890 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
899 # Converts the NexusID from SNMP to our version
902 $nexus =~ s{\A \\}{}xms;
903 $nexus =~ s{\\}{:}gxms;
907 # Sets custom temperature thresholds based on user supplied options
908 sub custom_temperature_thresholds {
909 my $type = shift; # type of threshold, either w (warning) or c (critical)
910 my %thres = (); # will contain the thresholds
911 my @limits = (); # holds the input
913 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
915 if (scalar @opt >= 0) {
916 foreach my $t (@opt) {
920 or do { report('other', "Couldn't open temperature threshold file $t: $!",
921 $E_UNKNOWN) and return {} };
932 # Parse checklist string, put in hash
933 foreach my $th (@limits) {
934 my @tmp = split m{,}xms, $th;
935 foreach my $t (@tmp) {
936 next if $t !~ m{=}xms;
937 my ($key, $val) = split m{=}xms, $t;
938 if ($val =~ m{/}xms) {
939 my ($max, $min) = split m{/}xms, $val;
940 $thres{$key}{max} = $max;
941 $thres{$key}{min} = $min;
944 $thres{$key}{max} = $val;
953 # Gets the output from SNMP result according to the OIDs checked
954 sub get_snmp_output {
955 my ($result,$oidref) = @_;
959 foreach my $oid (keys %{ $result }) {
961 $short =~ s{\s}{}gxms; # remove whitespace
962 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
964 if (exists $oidref->{$short}) {
965 $temp[$id]{$oidref->{$short}} = $result->{$oid};
969 # Remove any empty indexes
970 foreach my $out (@temp) {
980 # Map the controller or other item in-place
982 my ($key, $val, $list) = @_;
984 foreach my $lst (@{ $list }) {
985 if (!exists $lst->{$key}) {
992 # Return the URL for official Dell documentation for a specific
994 sub documentation_url {
997 # create model short form, e.g. "r710"
998 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
1000 # special case for blades (e.g. M600, M710), they have common
1002 $model =~ s{\A m\d+ \z}{m}xms;
1004 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1007 # Return the URL for warranty information for a server with a given
1008 # serial number (servicetag)
1012 # Dell support sites for different parts of the world
1015 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1016 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1017 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1020 # warranty URLs for different country codes
1024 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1025 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1026 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1027 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1028 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1029 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1030 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1031 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1032 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1033 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1034 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1035 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1036 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1037 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1038 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1039 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1040 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1041 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1042 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1043 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1045 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1046 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1047 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1048 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1050 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1051 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1052 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1054 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1057 if (exists $url{$opt{htmlinfo}}) {
1058 return $url{$opt{htmlinfo}} . $tag;
1061 return $url{XX} . $tag;
1066 # This helper function returns the corresponding value of a hash key,
1067 # but takes into account that the key may not exist
1069 my $key = shift || return undef;
1071 return exists $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1076 #---------------------------------------------------------------------
1078 #---------------------------------------------------------------------
1080 #-----------------------------------------
1081 # Check global health status
1082 #-----------------------------------------
1088 # Checks global status, i.e. both storage and chassis
1090 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1091 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1092 if (!defined $result) {
1093 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1096 $health = $status2nagios{$snmp_status{$result->{$systemStateGlobalSystemStatus}}};
1100 # NB! This does not check storage, only chassis...
1102 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1104 next if m/\A SEVERITY;COMPONENT/xms;
1105 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1106 $health = $status2nagios{$1};
1117 #-----------------------------------------
1118 # STORAGE: Check controllers
1119 #-----------------------------------------
1120 sub check_controllers {
1121 return if blacklisted('ctrl', 'all');
1130 my $firmware = undef;
1132 my $minstdr = undef; # Minimum required Storport driver version
1133 my $stdr = undef; # Storport driver version
1139 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1140 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1141 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1142 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1143 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1144 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1145 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1146 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1147 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1148 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1149 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1152 # We use get_table() here for the odd case where a server has
1153 # two or more controllers, and where some OIDs are missing on
1154 # one of the controllers.
1155 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1156 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1158 # No controllers is OK
1159 return if !defined $result;
1161 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1164 @output = @{ run_omreport('storage controller') };
1178 foreach my $out (@output) {
1180 $id = $out->{controllerNumber} - 1;
1181 $name = $out->{controllerName};
1182 $state = get_hashval($out->{controllerState}, \%ctrl_state);
1183 $status = $snmp_status{$out->{controllerComponentStatus}};
1184 $minfw = exists $out->{controllerMinFWVersion}
1185 ? $out->{controllerMinFWVersion} : undef;
1186 $mindr = exists $out->{controllerMinDriverVersion}
1187 ? $out->{controllerMinDriverVersion} : undef;
1188 $firmware = exists $out->{controllerFWVersion}
1189 ? $out->{controllerFWVersion} : 'N/A';
1190 $driver = exists $out->{controllerDriverVersion}
1191 ? $out->{controllerDriverVersion} : 'N/A';
1192 $minstdr = exists $out->{'controllerMinRequiredStorportVer'}
1193 ? $out->{controllerMinRequiredStorportVer} : undef;
1194 $stdr = exists $out->{controllerStorportDriverVersion}
1195 ? $out->{controllerStorportDriverVersion} : undef;
1196 $nexus = convert_nexus($out->{controllerNexusID});
1200 $name = $out->{Name};
1201 $state = $out->{State};
1202 $status = $out->{Status};
1203 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1204 ? $out->{'Minimum Required Firmware Version'} : undef;
1205 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1206 ? $out->{'Minimum Required Driver Version'} : undef;
1207 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1208 ? $out->{'Firmware Version'} : 'N/A';
1209 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1210 ? $out->{'Driver Version'} : 'N/A';
1211 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1212 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1213 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1214 $stdr = (exists $out->{'Storport Driver Version'}
1215 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1216 ? $out->{'Storport Driver Version'} : undef;
1220 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1221 push @controllers, $id;
1223 # Collecting some storage info
1224 $sysinfo{'controller'}{$id}{'id'} = $nexus;
1225 $sysinfo{'controller'}{$id}{'name'} = $name;
1226 $sysinfo{'controller'}{$id}{'driver'} = $driver;
1227 $sysinfo{'controller'}{$id}{'firmware'} = $firmware;
1228 $sysinfo{'controller'}{$id}{'storport'} = $stdr;
1230 next CTRL if blacklisted('ctrl', $nexus);
1232 # Special case: old firmware
1233 if (!blacklisted('ctrl_fw', $id) && defined $minfw) {
1235 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1236 $id, $name, $firmware;
1237 report('storage', $msg, $E_WARNING, $nexus);
1239 # Special case: old driver
1240 if (!blacklisted('ctrl_driver', $id) && defined $mindr) {
1242 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1243 $id, $name, $driver;
1244 report('storage', $msg, $E_WARNING, $nexus);
1246 # Special case: old storport driver
1247 if (!blacklisted('ctrl_stdr', $id) && defined $minstdr) {
1249 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1251 report('storage', $msg, $E_WARNING, $nexus);
1254 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1255 and (defined $minfw or defined $mindr or defined $minstdr))) {
1256 my $msg = sprintf 'Controller %d [%s] is %s',
1258 report('storage', $msg, $E_OK, $nexus);
1262 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1264 report('storage', $msg, $status2nagios{$status}, $nexus);
1271 #-----------------------------------------
1272 # STORAGE: Check physical drives
1273 #-----------------------------------------
1274 sub check_physical_disks {
1275 return if $#controllers == -1;
1276 return if blacklisted('pdisk', 'all');
1286 my $vendor = undef; # disk vendor
1287 my $product = undef; # product ID
1288 my $capacity = undef; # disk length (size) in bytes
1294 '1.3.6.1.4.1.674.10893.1.20.130.4.1.1' => 'arrayDiskNumber',
1295 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1296 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1297 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1298 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1299 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1300 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1301 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1302 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1303 '1.3.6.1.4.1.674.10893.1.20.130.4.1.16' => 'arrayDiskLunID',
1304 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1305 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1306 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1307 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1308 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1311 if ($opt{use_get_table}) {
1312 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1313 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1314 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1316 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1317 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1318 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1320 if (defined $result) {
1321 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1322 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1326 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1329 if (!defined $result) {
1330 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1331 $snmp_session->close;
1335 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1338 foreach my $c (@controllers) {
1339 # This blacklists disks with broken firmware, which includes
1340 # illegal XML characters that makes openmanage choke on itself
1341 next if blacklisted('ctrl_pdisk', $c);
1343 push @output, @{ run_omreport("storage pdisk controller=$c") };
1344 map_item('ctrl', $c, \@output);
1359 22 => 'Replacing', # FIXME: this one is not defined in the OM 6.2.0.1 MIBs
1363 28 => 'Diagnostics',
1364 34 => 'Predictive failure',
1365 35 => 'Initializing',
1368 41 => 'Unsupported',
1369 53 => 'Incompatible',
1372 # Check physical disks on each of the controllers
1374 foreach my $out (@output) {
1376 $name = $out->{arrayDiskName};
1377 if (exists $out->{arrayDiskEnclosureID}) {
1378 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskEnclosureID},
1379 $out->{arrayDiskTargetID});
1382 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskTargetID});
1384 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state);
1385 $status = $snmp_status{$out->{arrayDiskComponentStatus}};
1386 $fpred = $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1388 $nexus = convert_nexus($out->{arrayDiskNexusID});
1389 $vendor = $out->{arrayDiskVendor};
1390 $product = $out->{arrayDiskProductID};
1391 $capacity = $out->{arrayDiskLengthInMB} * 1024**2;
1392 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1393 $ctrl = $out->{arrayDiskEnclosureConnectionControllerNumber} - 1;
1395 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1396 $ctrl = $out->{arrayDiskChannelConnectionControllerNumber} - 1;
1404 $name = $out->{'Name'};
1405 $state = $out->{'State'};
1406 $status = $out->{'Status'};
1407 $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
1408 $progr = ' [' . $out->{'Progress'} . ']';
1409 $ctrl = $out->{'ctrl'};
1410 $nexus = join q{:}, $out->{ctrl}, $id;
1411 $vendor = $out->{'Vendor ID'};
1412 $product = $out->{'Product ID'};
1413 $capacity = $out->{'Capacity'};
1414 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1417 next PDISK if blacklisted('pdisk', $nexus);
1420 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1421 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1423 # Calculate human readable capacity
1424 $capacity = ceil($capacity / 1000**3) >= 1000
1425 ? sprintf '%.1fTB', ($capacity / 1000**4)
1426 : sprintf '%.0fGB', ($capacity / 1000**3);
1427 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1428 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1429 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1431 # Capitalize only the first letter of the vendor name
1432 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1434 # Remove unnecessary trademark rubbish from vendor name
1435 $vendor =~ s{\(tm\)\z}{}xms;
1437 # Special case: Failure predicted
1439 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1440 $name, $vendor, $product, $capacity, $ctrl;
1441 $msg .= " ($state)" if $state ne 'Predictive failure';
1442 report('storage', $msg,
1443 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1445 # Special case: Rebuilding / Replacing
1446 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1447 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1448 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1449 report('storage', $msg, $E_WARNING, $nexus);
1452 elsif ($status ne 'Ok') {
1453 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1454 $name, $vendor, $product, $capacity, $ctrl, $state;
1455 report('storage', $msg, $status2nagios{$status}, $nexus);
1459 my $msg = sprintf '%s [%s] on ctrl %d is %s',
1460 $name, $capacity, $ctrl, $state;
1461 report('storage', $msg, $E_OK, $nexus);
1468 #-----------------------------------------
1469 # STORAGE: Check logical drives
1470 #-----------------------------------------
1471 sub check_virtual_disks {
1472 return if $#controllers == -1;
1473 return if blacklisted('vdisk', 'all');
1490 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1491 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1492 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1493 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1494 '1.3.6.1.4.1.674.10893.1.20.140.1.1.17' => 'virtualDiskTargetID',
1495 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1496 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1499 if ($opt{use_get_table}) {
1500 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1501 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1504 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1507 # No logical drives is OK
1508 return if !defined $result;
1510 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1513 foreach my $c (@controllers) {
1514 push @output, @{ run_omreport("storage vdisk controller=$c") };
1515 map_item('ctrl', $c, \@output);
1528 16 => 'Regenerating',
1531 32 => 'Reconstructing',
1532 35 => 'Initializing',
1533 36 => 'Background Initialization',
1534 38 => 'Resynching Paused',
1535 52 => 'Permanently Degraded',
1536 54 => 'Degraded Redundancy',
1541 1 => 'Concatenated',
1548 19 => 'Concatenated RAID-1',
1552 # Check virtual disks on each of the controllers
1554 foreach my $out (@output) {
1556 $id = $out->{virtualDiskTargetID};
1557 $dev = $out->{virtualDiskDeviceName};
1558 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state);
1559 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout);
1560 $status = $snmp_status{$out->{virtualDiskComponentStatus}};
1561 $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
1562 $progr = q{}; # can't get this from SNMP(?)
1563 $nexus = convert_nexus($out->{virtualDiskNexusID});
1564 $ctrl = $nexus; # We use the nexus id to get the controller id
1565 $ctrl =~ s{\A (\d+):\d+ \z}{$1}xms;
1569 $dev = $out->{'Device Name'};
1570 $state = $out->{State};
1571 $status = $out->{Status};
1572 $layout = $out->{Layout};
1573 $size = $out->{Size};
1574 $progr = ' [' . $out->{Progress} . ']';
1575 $size =~ s{\A (.*GB).* \z}{$1}xms;
1576 $nexus = join q{:}, $out->{ctrl}, $id;
1577 $ctrl = $out->{ctrl};
1580 next VDISK if blacklisted('vdisk', $nexus);
1583 # The device name is undefined sometimes
1584 $dev = q{} if !defined $dev;
1586 # Special case: Regenerating
1587 if ($state eq 'Regenerating') {
1588 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s%s},
1589 $id, $dev, $layout, $size, $ctrl, $state, $progr;
1590 report('storage', $msg, $E_WARNING, $nexus);
1593 elsif ($status ne 'Ok') {
1594 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d needs attention: %s},
1595 $id, $dev, $layout, $size, $ctrl, $state;
1596 report('storage', $msg, $status2nagios{$status}, $nexus);
1600 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s},
1601 $id, $dev, $layout, $size, $ctrl, $state;
1602 report('storage', $msg, $E_OK, $nexus);
1609 #-----------------------------------------
1610 # STORAGE: Check cache batteries
1611 #-----------------------------------------
1612 sub check_cache_battery {
1613 return if $#controllers == -1;
1614 return if blacklisted('bat', 'all');
1621 my $learn = undef; # learn state
1622 my $pred = undef; # battery's ability to be charged
1628 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1629 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1630 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1631 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1632 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1633 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1636 if ($opt{use_get_table}) {
1637 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1638 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1640 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1641 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1643 if (defined $result) {
1644 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1648 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1651 # No cache battery is OK
1652 return if !defined $result;
1654 @output = @{ get_snmp_output($result, \%bat_oid) };
1657 foreach my $c (@controllers) {
1658 push @output, @{ run_omreport("storage battery controller=$c") };
1659 map_item('ctrl', $c, \@output);
1669 7 => 'Reconditioning',
1677 # Specifies the learn state activity of the battery
1687 # This property displays the battery's ability to be charged
1690 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1691 2 => 'Ready', # The battery can be charged to full capacity
1692 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1693 # battery cannot be determined until the Learn cycle is complete
1696 # Check battery on each of the controllers
1698 foreach my $out (@output) {
1700 $status = $snmp_status{$out->{batteryComponentStatus}};
1701 $state = get_hashval($out->{batteryState}, \%bat_state);
1702 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state);
1703 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap);
1704 $ctrl = $out->{batteryConnectionControllerNumber} - 1;
1705 $nexus = convert_nexus($out->{batteryNexusID});
1707 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1711 $state = $out->{'State'};
1712 $status = $out->{'Status'};
1713 $learn = $out->{'Learn State'};
1714 $pred = $out->{'Predicted Capacity Status'};
1715 $ctrl = $out->{'ctrl'};
1716 $nexus = join q{:}, $out->{ctrl}, $id;
1719 next BATTERY if blacklisted('bat', $nexus);
1721 # Special case: Charging
1722 if ($state eq 'Charging') {
1723 if ($pred eq 'Failed') {
1724 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [replace battery]',
1725 $id, $ctrl, $state, $pred;
1726 report('storage', $msg, $E_CRITICAL, $nexus);
1729 next BATTERY if blacklisted('bat_charge', $nexus);
1730 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1731 $id, $ctrl, $state, $pred;
1732 report('storage', $msg, $E_WARNING, $nexus);
1735 # Special case: Learning (battery learns its capacity)
1736 elsif ($state eq 'Learning') {
1737 if ($learn eq 'Failed') {
1738 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s)',
1739 $id, $ctrl, $state, $learn;
1740 report('storage', $msg, $E_CRITICAL, $nexus);
1743 next BATTERY if blacklisted('bat_charge', $nexus);
1744 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1745 $id, $ctrl, $state, $learn;
1746 report('storage', $msg, $E_WARNING, $nexus);
1749 # Special case: Power Low (first part of recharge cycle)
1750 elsif ($state eq 'Power Low') {
1751 next BATTERY if blacklisted('bat_charge', $nexus);
1752 my $msg = sprintf 'Cache battery %d in controller %d is %s [probably harmless]',
1754 report('storage', $msg, $E_WARNING, $nexus);
1756 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1757 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1758 next BATTERY if blacklisted('bat_charge', $nexus);
1759 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1760 $id, $ctrl, $state, $status;
1761 report('storage', $msg, $E_WARNING, $nexus);
1764 elsif ($status ne 'Ok') {
1765 my $msg = sprintf 'Cache battery %d in controller %d needs attention: %s (%s)',
1766 $id, $ctrl, $state, $status;
1767 report('storage', $msg, $status2nagios{$status}, $nexus);
1771 my $msg = sprintf 'Cache battery %d in controller %d is %s',
1773 report('storage', $msg, $E_OK, $nexus);
1780 #-----------------------------------------
1781 # STORAGE: Check connectors (channels)
1782 #-----------------------------------------
1783 sub check_connectors {
1784 return if $#controllers == -1;
1785 return if blacklisted('conn', 'all');
1799 '1.3.6.1.4.1.674.10893.1.20.130.2.1.1' => 'channelNumber',
1800 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1801 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1802 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1803 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1804 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1807 if ($opt{use_get_table}) {
1808 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1809 $result = $snmp_session->get_table(-baseoid => $channelTable);
1812 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1815 if (!defined $result) {
1816 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1817 $snmp_session->close;
1821 @output = @{ get_snmp_output($result, \%conn_oid) };
1824 foreach my $c (@controllers) {
1825 push @output, @{ run_omreport("storage connector controller=$c") };
1826 map_item('ctrl', $c, \@output);
1844 3 => 'Fibre Channel',
1851 # Check connectors on each of the controllers
1853 foreach my $out (@output) {
1855 $id = $out->{channelNumber} - 1;
1856 $name = $out->{channelName};
1857 $status = $snmp_status{$out->{channelComponentStatus}};
1858 $state = get_hashval($out->{channelState}, \%conn_state);
1859 $type = get_hashval($out->{channelBusType}, \%conn_bustype);
1860 $nexus = convert_nexus($out->{channelNexusID});
1862 $ctrl =~ s{(\d+):\d+}{$1}xms;
1866 $name = $out->{'Name'};
1867 $state = $out->{'State'};
1868 $status = $out->{'Status'};
1869 $type = $out->{'Connector Type'};
1870 $ctrl = $out->{ctrl};
1871 $nexus = join q{:}, $out->{ctrl}, $id;
1874 next CHANNEL if blacklisted('conn', $nexus);
1876 my $msg = sprintf '%s [%s] on controller %d is %s',
1877 $name, $type, $ctrl, $state;
1878 report('storage', $msg, $status2nagios{$status}, $nexus);
1884 #-----------------------------------------
1885 # STORAGE: Check enclosures
1886 #-----------------------------------------
1887 sub check_enclosures {
1888 return if blacklisted('encl', 'all');
1895 my $firmware = undef;
1902 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
1903 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
1904 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
1905 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
1906 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
1907 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
1908 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
1911 if ($opt{use_get_table}) {
1912 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
1913 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
1916 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
1919 # No enclosures is OK
1920 return if !defined $result;
1922 @output = @{ get_snmp_output($result, \%encl_oid) };
1925 foreach my $c (@controllers) {
1926 push @output, @{ run_omreport("storage enclosure controller=$c") };
1927 map_item('ctrl', $c, \@output);
1942 foreach my $out (@output) {
1944 $id = $out->{enclosureNumber} - 1;
1945 $name = $out->{enclosureName};
1946 $state = get_hashval($out->{enclosureState}, \%encl_state);
1947 $status = $snmp_status{$out->{enclosureComponentStatus}};
1948 $firmware = exists $out->{enclosureFirmwareVersion}
1949 ? $out->{enclosureFirmwareVersion} : 'N/A';
1950 $nexus = convert_nexus($out->{enclosureNexusID});
1952 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
1956 $name = $out->{Name};
1957 $state = $out->{State};
1958 $status = $out->{Status};
1959 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1960 ? $out->{'Firmware Version'} : 'N/A';
1961 $nexus = join q{:}, $out->{ctrl}, $id;
1962 $ctrl = $out->{ctrl};
1965 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1966 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
1968 # store enclosure data for future use
1969 push @enclosures, { 'id' => $id,
1970 'ctrl' => $out->{ctrl},
1973 # Collecting some storage info
1974 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
1975 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
1976 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
1978 next ENCLOSURE if blacklisted('encl', $nexus);
1980 my $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
1981 $nexus, $name, $ctrl, $state;
1982 report('storage', $msg, $status2nagios{$status}, $nexus);
1988 #-----------------------------------------
1989 # STORAGE: Check enclosure fans
1990 #-----------------------------------------
1991 sub check_enclosure_fans {
1992 return if $#controllers == -1;
1993 return if blacklisted('encl_fan', 'all');
2001 my $encl_id = undef;
2002 my $encl_name = undef;
2008 '1.3.6.1.4.1.674.10893.1.20.130.7.1.1' => 'fanNumber',
2009 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2010 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2011 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2012 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2013 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2014 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2015 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2018 if ($opt{use_get_table}) {
2019 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2020 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2022 $result = $snmp_session->get_table(-baseoid => $fanTable);
2023 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2025 if (defined $result) {
2026 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2030 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2033 # No enclosure fans is OK
2034 return if !defined $result;
2036 @output = @{ get_snmp_output($result, \%fan_oid) };
2039 foreach my $enc (@enclosures) {
2040 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2041 map_item('ctrl', $enc->{ctrl}, \@output);
2042 map_item('encl_id', $enc->{id}, \@output);
2043 map_item('encl_name', $enc->{name}, \@output);
2058 # Check fans on each of the enclosures
2060 foreach my $out (@output) {
2062 $id = $out->{fanNumber} - 1;
2063 $name = $out->{fanName};
2064 $state = get_hashval($out->{fanState}, \%fan_state);
2065 $status = $snmp_status{$out->{fanComponentStatus}};
2066 $speed = $out->{fanProbeCurrValue};
2067 $encl_id = $out->{fanConnectionEnclosureNumber} - 1;
2068 $encl_name = $out->{fanConnectionEnclosureName};
2069 $nexus = convert_nexus($out->{fanNexusID});
2073 $name = $out->{'Name'};
2074 $state = $out->{'State'};
2075 $status = $out->{'Status'};
2076 $speed = $out->{'Speed'};
2077 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2078 $encl_name = $out->{encl_name};
2079 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2082 next FAN if blacklisted('encl_fan', $nexus);
2085 if ($status ne 'Ok') {
2086 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2087 $name, $encl_id, $encl_name, $state;
2088 report('storage', $msg, $status2nagios{$status}, $nexus);
2092 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2093 $name, $encl_id, $encl_name, $state, $speed;
2094 report('storage', $msg, $E_OK, $nexus);
2101 #-----------------------------------------
2102 # STORAGE: Check enclosure power supplies
2103 #-----------------------------------------
2104 sub check_enclosure_pwr {
2105 return if $#controllers == -1;
2106 return if blacklisted('encl_ps', 'all');
2113 my $encl_id = undef;
2114 my $encl_name = undef;
2120 '1.3.6.1.4.1.674.10893.1.20.130.9.1.1' => 'powerSupplyNumber',
2121 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2122 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2123 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2124 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2125 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2126 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2129 if ($opt{use_get_table}) {
2130 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2131 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2133 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2134 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2136 if (defined $result) {
2137 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2141 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2144 # No enclosure power supplies is OK
2145 return if !defined $result;
2147 @output = @{ get_snmp_output($result, \%ps_oid) };
2150 foreach my $enc (@enclosures) {
2151 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2152 map_item('ctrl', $enc->{ctrl}, \@output);
2153 map_item('encl_id', $enc->{id}, \@output);
2154 map_item('encl_name', $enc->{name}, \@output);
2163 5 => 'Not Installed',
2169 # Check power supplies on each of the enclosures
2171 foreach my $out (@output) {
2173 $id = $out->{powerSupplyNumber};
2174 $name = $out->{powerSupplyName};
2175 $state = get_hashval($out->{powerSupplyState}, \%ps_state);
2176 $status = $snmp_status{$out->{powerSupplyComponentStatus}};
2177 $encl_id = $out->{powerSupplyConnectionEnclosureNumber} - 1;
2178 $encl_name = $out->{powerSupplyConnectionEnclosureName};
2179 $nexus = convert_nexus($out->{powerSupplyNexusID});
2183 $name = $out->{'Name'};
2184 $state = $out->{'State'};
2185 $status = $out->{'Status'};
2186 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2187 $encl_name = $out->{encl_name};
2188 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2191 next PS if blacklisted('encl_ps', $nexus);
2194 if ($status ne 'Ok') {
2195 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2196 $name, $encl_id, $encl_name, $state;
2197 report('storage', $msg, $status2nagios{$status}, $nexus);
2201 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2202 $name, $encl_id, $encl_name, $state;
2203 report('storage', $msg, $E_OK, $nexus);
2210 #-----------------------------------------
2211 # STORAGE: Check enclosure temperatures
2212 #-----------------------------------------
2213 sub check_enclosure_temp {
2214 return if $#controllers == -1;
2215 return if blacklisted('encl_temp', 'all');
2222 my $reading = undef;
2224 my $max_warn = undef;
2225 my $max_crit = undef;
2226 my $encl_id = undef;
2227 my $encl_name = undef;
2233 '1.3.6.1.4.1.674.10893.1.20.130.11.1.1' => 'temperatureProbeNumber',
2234 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2235 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2236 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2237 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2238 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2239 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2240 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2241 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2242 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2243 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2246 if ($opt{use_get_table}) {
2247 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2248 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2250 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2251 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2253 if (defined $result) {
2254 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2258 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2261 # No enclosure temperature probes is OK
2262 return if !defined $result;
2264 @output = @{ get_snmp_output($result, \%temp_oid) };
2267 foreach my $enc (@enclosures) {
2268 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2269 map_item('ctrl', $enc->{ctrl}, \@output);
2270 map_item('encl_id', $enc->{id}, \@output);
2271 map_item('encl_name', $enc->{name}, \@output);
2286 # Check temperature probes on each of the enclosures
2288 foreach my $out (@output) {
2290 $id = $out->{temperatureProbeNumber} - 1;
2291 $name = $out->{temperatureProbeName};
2292 $state = get_hashval($out->{temperatureProbeState}, \%temp_state);
2293 $status = $snmp_status{$out->{temperatureProbeComponentStatus}};
2294 $unit = $out->{temperatureProbeUnit};
2295 $reading = $out->{temperatureProbeCurValue};
2296 $max_warn = $out->{temperatureProbeMaxWarning};
2297 $max_crit = $out->{temperatureProbeMaxCritical};
2298 $encl_id = $out->{temperatureConnectionEnclosureNumber} - 1;
2299 $encl_name = $out->{temperatureConnectionEnclosureName};
2300 $nexus = convert_nexus($out->{temperatureProbeNexusID});
2304 $name = $out->{'Name'};
2305 $state = $out->{'State'};
2306 $status = $out->{'Status'};
2308 $reading = $out->{'Reading'}; $reading =~ s{\s*C}{}xms;
2309 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\s*C}{}xms;
2310 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\s*C}{}xms;
2311 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2312 $encl_name = $out->{encl_name};
2313 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2316 next TEMP if blacklisted('encl_temp', $nexus);
2319 if ($status ne 'Ok') {
2320 my $msg = sprintf '%s in enclosure %s [%s] is %s C at %s (%s max)',
2321 $name, $encl_id, $encl_name, $state, $reading, $max_crit;
2322 report('storage', $msg, $status2nagios{$status}, $nexus);
2326 my $msg = sprintf '%s in enclosure %s [%s]: %s C (%s max)',
2327 $name, $encl_id, $encl_name, $reading, $max_crit;
2328 report('storage', $msg, $E_OK, $nexus);
2331 # Collect performance data
2332 if (defined $opt{perfdata}) {
2333 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2334 my $pkey = "enclosure_${encl_id}_${name}";
2335 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2336 $perfdata{$pkey} = $pval;
2343 #-----------------------------------------
2344 # STORAGE: Check enclosure management modules (EMM)
2345 #-----------------------------------------
2346 sub check_enclosure_emms {
2347 return if $#controllers == -1;
2348 return if blacklisted('encl_emm', 'all');
2355 my $encl_id = undef;
2356 my $encl_name = undef;
2362 '1.3.6.1.4.1.674.10893.1.20.130.13.1.1' => 'enclosureManagementModuleNumber',
2363 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2364 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2365 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2366 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2367 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2368 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2371 if ($opt{use_get_table}) {
2372 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2373 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2375 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2376 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2378 if (defined $result) {
2379 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2383 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2386 # No enclosure EMMs is OK
2387 return if !defined $result;
2389 @output = @{ get_snmp_output($result, \%emms_oid) };
2392 foreach my $enc (@enclosures) {
2393 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2394 map_item('ctrl', $enc->{ctrl}, \@output);
2395 map_item('encl_id', $enc->{id}, \@output);
2396 map_item('encl_name', $enc->{name}, \@output);
2407 5 => 'Not Installed',
2412 # Check temperature probes on each of the enclosures
2414 foreach my $out (@output) {
2416 $id = $out->{enclosureManagementModuleNumber} - 1;
2417 $name = $out->{enclosureManagementModuleName};
2418 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state);
2419 $status = $snmp_status{$out->{enclosureManagementModuleComponentStatus}};
2420 $encl_id = $out->{enclosureManagementModuleConnectionEnclosureNumber} - 1;
2421 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
2422 $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
2426 $name = $out->{'Name'};
2427 $state = $out->{'State'};
2428 $status = $out->{'Status'};
2429 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2430 $encl_name = $out->{encl_name};
2431 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2434 next EMM if blacklisted('encl_emm', $nexus);
2437 if ($status ne 'Ok') {
2438 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2439 $name, $encl_id, $encl_name, $state;
2440 report('storage', $msg, $status2nagios{$status}, $nexus);
2444 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2445 $name, $encl_id, $encl_name, $state;
2446 report('storage', $msg, $E_OK, $nexus);
2453 #-----------------------------------------
2454 # CHASSIS: Check memory modules
2455 #-----------------------------------------
2457 return if blacklisted('dimm', 'all');
2461 my $location = undef;
2470 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2471 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2472 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2473 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2474 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2477 if ($opt{use_get_table}) {
2478 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2479 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2482 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2485 if (!defined $result) {
2486 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2487 $snmp_session->close;
2491 @output = @{ get_snmp_output($result, \%dimm_oid) };
2494 @output = @{ run_omreport("$omopt_chassis memory") };
2497 # Note: These values are bit masks, so combination values are
2498 # possible. If value is 0 (zero), memory device has no faults.
2501 1 => 'ECC single bit correction warning rate exceeded',
2502 2 => 'ECC single bit correction failure rate exceeded',
2503 4 => 'ECC multibit fault encountered',
2504 8 => 'ECC single bit correction logging disabled',
2505 16 => 'device disabled because of spare activation',
2509 foreach my $out (@output) {
2510 @failures = (); # Initialize
2512 $index = $out->{memoryDeviceIndex};
2513 $status = $snmp_status{$out->{memoryDeviceStatus}};
2514 $location = $out->{memoryDeviceLocationName};
2515 $size = sprintf '%d MB', $out->{memoryDeviceSize}/1024;
2516 $modes = $out->{memoryDeviceFailureModes};
2518 foreach my $mask (sort keys %failure_mode) {
2519 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2524 $index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
2525 $status = $out->{'Status'};
2526 $location = $out->{'Connector Name'};
2527 $size = $out->{'Size'};
2528 if (defined $size) {
2529 $size =~ s{\s\s}{ }gxms;
2531 # Run 'omreport chassis memory index=X' to get the failures
2532 if ($status ne 'Ok' && defined $index) {
2533 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2534 if (m/\A Failures; (.+?) \z/xms) {
2535 chop(my $fail = $1);
2536 push @failures, split m{\.}xms, $fail;
2541 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2543 next DIMM if blacklisted('dimm', $index);
2545 # Ignore empty memory slots
2546 next DIMM if !defined $index;
2549 if ($status ne 'Ok') {
2551 if (scalar @failures == 0) {
2552 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2553 $index, $location, $size, $status;
2556 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2557 $index, $location, $size, (join q{, }, @failures);
2560 report('chassis', $msg, $status2nagios{$status}, $index);
2564 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2565 $index, $location, $size, $status;
2566 report('chassis', $msg, $E_OK, $index);
2573 #-----------------------------------------
2574 # CHASSIS: Check fans
2575 #-----------------------------------------
2577 return if blacklisted('fan', 'all');
2581 my $reading = undef;
2582 my $location = undef;
2583 my $max_crit = undef;
2584 my $max_warn = undef;
2590 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2591 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2592 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2593 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2594 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2595 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2598 if ($opt{use_get_table}) {
2599 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2600 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2603 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2606 if ($blade && !defined $result) {
2609 elsif (!$blade && !defined $result) {
2610 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2611 $snmp_session->close;
2615 @output = @{ get_snmp_output($result, \%cool_oid) };
2618 @output = @{ run_omreport("$omopt_chassis fans") };
2622 foreach my $out (@output) {
2624 $index = $out->{coolingDeviceIndex};
2625 $status = $snmp_probestatus{$out->{coolingDeviceStatus}};
2626 $reading = $out->{coolingDeviceReading};
2627 $location = $out->{coolingDeviceLocationName};
2628 $max_crit = exists $out->{coolingDeviceUpperCriticalThreshold}
2629 ? $out->{coolingDeviceUpperCriticalThreshold} : 0;
2630 $max_warn = exists $out->{coolingDeviceUpperNonCriticalThreshold}
2631 ? $out->{coolingDeviceUpperNonCriticalThreshold} : 0;
2634 $index = $out->{'Index'};
2635 $status = $out->{'Status'};
2636 $reading = $out->{'Reading'};
2637 $location = $out->{'Probe Name'};
2638 $max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
2639 ? $out->{'Maximum Failure Threshold'} : 0;
2640 $max_warn = $out->{'Maximum Warning Threshold'} ne '[N/A]'
2641 ? $out->{'Maximum Warning Threshold'} : 0;
2642 $reading =~ s{\A (\d+).* \z}{$1}xms;
2643 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2644 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2647 next FAN if blacklisted('fan', $index);
2650 if ($status ne 'Ok') {
2651 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2652 $index, $location, $status;
2653 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2654 report('chassis', $msg, $err, $index);
2657 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2658 $index, $location, $reading;
2659 report('chassis', $msg, $E_OK, $index);
2662 # Collect performance data
2663 if (defined $opt{perfdata}) {
2664 my $pname = lc $location;
2665 $pname =~ s{\s}{_}gxms;
2666 $pname =~ s{proc_}{cpu#}xms;
2667 my $pkey = join q{_}, 'fan', $index, $pname;
2668 my $pval = join q{;}, "${reading}RPM", $max_warn, $max_crit;
2669 $perfdata{$pkey} = $pval;
2676 #-----------------------------------------
2677 # CHASSIS: Check power supplies
2678 #-----------------------------------------
2679 sub check_powersupplies {
2680 return if blacklisted('ps', 'all');
2685 my $err_type = undef;
2693 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2694 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2695 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2696 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2697 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2700 if ($opt{use_get_table}) {
2701 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2702 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2705 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2708 # No instrumented PSU is OK (blades, low-end servers)
2709 return 0 if !defined $result;
2711 @output = @{ get_snmp_output($result, \%ps_oid) };
2714 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2724 6 => 'Uninterruptible Power Supply',
2734 1 => 'Presence detected',
2735 2 => 'Failure detected',
2736 4 => 'Predictive Failure',
2738 16 => 'AC lost or out-of-range',
2739 32 => 'AC out-of-range but present',
2740 64 => 'Configuration error',
2743 my %ps_config_error_type
2745 1 => 'Vendor mismatch',
2746 2 => 'Revision mismatch',
2747 3 => 'Processor missing',
2751 foreach my $out (@output) {
2753 @states = (); # contains states for the PS
2755 $index = $out->{powerSupplyIndex} - 1;
2756 $status = $snmp_status{$out->{powerSupplyStatus}};
2757 $type = get_hashval($out->{powerSupplyType}, \%ps_type);
2758 $err_type = defined $out->{powerSupplyConfigurationErrorType}
2759 ? $ps_config_error_type{$out->{powerSupplyConfigurationErrorType}} : undef;
2761 # get the combined state from the StatusReading OID
2762 foreach my $mask (sort keys %ps_state) {
2763 if (($out->{powerSupplySensorState} & $mask) != 0) {
2764 push @states, $ps_state{$mask};
2768 # If configuration error, also include the error type
2769 if (defined $err_type) {
2770 push @states, $err_type;
2773 # Finally, construct the state string
2774 $state = join q{, }, @states;
2777 $index = $out->{'Index'};
2778 $status = $out->{'Status'};
2779 $type = $out->{'Type'};
2780 $state = $out->{'Online Status'};
2783 next PS if blacklisted('ps', $index);
2786 if ($status ne 'Ok') {
2787 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2788 $index, $type, $state;
2789 report('chassis', $msg, $status2nagios{$status}, $index);
2792 my $msg = sprintf 'Power Supply %d [%s]: %s',
2793 $index, $type, $state;
2794 report('chassis', $msg, $E_OK, $index);
2801 #-----------------------------------------
2802 # CHASSIS: Check temperatures
2803 #-----------------------------------------
2804 sub check_temperatures {
2805 return if blacklisted('temp', 'all');
2809 my $reading = undef;
2810 my $location = undef;
2811 my $max_crit = undef;
2812 my $max_warn = undef;
2813 my $min_warn = undef;
2814 my $min_crit = undef;
2816 my $discrete = undef;
2819 # Getting custom temperature thresholds (user option)
2820 my %warn_threshold = %{ custom_temperature_thresholds('w') };
2821 my %crit_threshold = %{ custom_temperature_thresholds('c') };
2826 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
2827 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
2828 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
2829 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
2830 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
2831 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
2832 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
2833 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
2834 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
2835 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
2837 # this didn't work well for some reason
2838 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2840 # Getting values using the table
2841 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
2842 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2844 if (!defined $result) {
2845 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
2846 $snmp_session->close;
2850 @output = @{ get_snmp_output($result, \%temp_oid) };
2853 @output = @{ run_omreport("$omopt_chassis temps") };
2858 1 => 'Other', # type is other than following values
2859 2 => 'Unknown', # type is unknown
2860 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
2861 16 => 'Discrete', # type is temperature probe with discrete reading
2865 foreach my $out (@output) {
2867 $index = $out->{temperatureProbeIndex} - 1;
2868 $status = $snmp_probestatus{$out->{temperatureProbeStatus}};
2869 $reading = $out->{temperatureProbeReading} / 10;
2870 $location = $out->{temperatureProbeLocationName};
2871 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} / 10;
2872 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} / 10;
2873 $min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
2874 ? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
2875 $min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
2876 ? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
2877 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
2878 $discrete = exists $out->{temperatureProbeDiscreteReading}
2879 ? $out->{temperatureProbeDiscreteReading} : undef;
2882 $index = $out->{'Index'};
2883 $status = $out->{'Status'};
2884 $reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
2885 $location = $out->{'Probe Name'};
2886 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
2887 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\.0\s+C}{}xms;
2888 $min_crit = $out->{'Minimum Failure Threshold'}; $min_crit =~ s{\.0\s+C}{}xms;
2889 $min_warn = $out->{'Minimum Warning Threshold'}; $min_warn =~ s{\.0\s+C}{}xms;
2890 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
2891 $discrete = $reading;
2894 next TEMP if blacklisted('temp', $index);
2897 if ($type eq 'Discrete') {
2898 my $msg = sprintf 'Temperature probe %d (%s): is %s',
2899 $index, $location, $discrete;
2900 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2901 report('chassis', $msg, $err, $index);
2904 # First check according to custom thresholds
2905 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
2906 # Custom critical MAX
2907 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2908 $index, $location, $reading, $crit_threshold{$index}{max};
2909 report('chassis', $msg, $E_CRITICAL, $index);
2911 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
2912 # Custom warning MAX
2913 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2914 $index, $location, $reading, $warn_threshold{$index}{max};
2915 report('chassis', $msg, $E_WARNING, $index);
2917 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
2918 # Custom critical MIN
2919 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2920 $index, $location, $reading, $crit_threshold{$index}{min};
2921 report('chassis', $msg, $E_CRITICAL, $index);
2923 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
2924 # Custom warning MIN
2925 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2926 $index, $location, $reading, $warn_threshold{$index}{min};
2927 report('chassis', $msg, $E_WARNING, $index);
2929 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2930 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
2931 $index, $location, $reading;
2932 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2933 report('chassis', $msg, $err, $index);
2935 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2936 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
2937 $index, $location, $reading;
2938 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2939 report('chassis', $msg, $err, $index);
2941 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2942 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
2943 $index, $location, $reading;
2944 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2945 report('chassis', $msg, $err, $index);
2947 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2948 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
2949 $index, $location, $reading;
2950 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2951 report('chassis', $msg, $err, $index);
2955 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
2956 $index, $location, $reading;
2957 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
2958 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2961 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2962 $min_warn, $min_crit, $max_warn, $max_crit;
2964 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2965 report('chassis', $msg, $err, $index);
2968 # Collect performance data
2969 if (defined $opt{perfdata}) {
2970 my $pname = lc $location;
2971 $pname =~ s{\s}{_}gxms;
2972 $pname =~ s{_temp\z}{}xms;
2973 $pname =~ s{proc_}{cpu#}xms;
2974 my $pkey = join q{_}, 'temp', $index, $pname;
2975 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2976 $perfdata{$pkey} = $pval;
2984 #-----------------------------------------
2985 # CHASSIS: Check processors
2986 #-----------------------------------------
2987 sub check_processors {
2988 return if blacklisted('cpu', 'all');
3001 # NOTE: For some reason, older models don't have the
3002 # "Processor Device Status" OIDs. We check both the newer
3003 # (preferred) OIDs and the old ones.
3007 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3008 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3009 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3010 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3011 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3012 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3013 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3014 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3015 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3016 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3019 if ($opt{use_get_table}) {
3020 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3021 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3023 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3024 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3026 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3029 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3032 if (!defined $result) {
3033 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3034 $snmp_session->close;
3038 @output = @{ get_snmp_output($result, \%cpu_oid) };
3041 @output = @{ run_omreport("$omopt_chassis processors") };
3046 1 => 'Other', # other than following values
3047 2 => 'Unknown', # unknown
3048 3 => 'Enabled', # enabled
3049 4 => 'User Disabled', # disabled by user via BIOS setup
3050 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3056 1 => 'Internal Error', # Internal Error
3057 2 => 'Thermal Trip', # Thermal Trip
3058 32 => 'Configuration Error', # Configuration Error
3059 128 => 'Present', # Processor Present
3060 256 => 'Disabled', # Processor Disabled
3061 512 => 'Terminator Present', # Terminator Present
3062 1024 => 'Throttled', # Processor Throttled
3065 # Mapping between family numbers from SNMP and actual CPU family
3068 1 => 'Other', 2 => 'Unknown', 3 => '8086',
3069 4 => '80286', 5 => '386', 6 => '486',
3070 7 => '8087', 8 => '80287', 9 => '80387',
3071 10 => '80487', 11 => 'Pentium', 12 => 'Pentium Pro',
3072 13 => 'Pentium II', 14 => 'Pentium with MMX', 15 => 'Celeron',
3073 16 => 'Pentium II Xeon', 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3074 19 => 'Pentium III', 20 => 'Itanium', 21 => 'Xeon',
3075 22 => 'Pentium 4', 23 => 'Xeon MP', 24 => 'Itanium 2',
3076 25 => 'K5', 26 => 'K6', 27 => 'K6-2',
3077 28 => 'K6-3', 29 => 'Athlon', 30 => 'AMD2900',
3078 31 => 'K6-2+', 32 => 'Power PC', 33 => 'Power PC 601',
3079 34 => 'Power PC 603', 35 => 'Power PC 603+', 36 => 'Power PC 604',
3080 37 => 'Power PC 620', 38 => 'Power PC x704', 39 => 'Power PC 750',
3081 48 => 'Alpha', 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3082 51 => 'Alpha 21164', 52 => 'Alpha 21164PC', 53 => 'Alpha 21164a',
3083 54 => 'Alpha 21264', 55 => 'Alpha 21364', 64 => 'MIPS',
3084 65 => 'MIPS R4000', 66 => 'MIPS R4200', 67 => 'MIPS R4400',
3085 68 => 'MIPS R4600', 69 => 'MIPS R10000', 80 => 'SPARC',
3086 81 => 'SuperSPARC', 82 => 'microSPARC II', 83 => 'microSPARC IIep',
3087 84 => 'UltraSPARC', 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3088 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi', 96 => '68040',
3089 97 => '68xxx', 98 => '68000', 99 => '68010',
3090 100 => '68020', 101 => '68030', 112 => 'Hobbit',
3091 120 => 'Crusoe TM5000', 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3092 128 => 'Weitek', 131 => 'Athlon 64', 132 => 'Opteron',
3093 133 => 'Sempron', 134 => 'Turion 64 Mobile', 135 => 'Dual-Core Opteron',
3094 136 => 'Athlon 64 X2 DC', 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3095 139 => '3rd gen Opteron', 144 => 'PA-RISC', 145 => 'PA-RISC 8500',
3096 146 => 'PA-RISC 8000', 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3097 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100', 160 => 'V30',
3098 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200', 173 => 'Quad-Core Xeon 7300',
3099 174 => 'Quad-Core Xeon 7400', 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3100 177 => 'M2', 180 => 'AS400', 182 => 'Athlon XP',
3101 183 => 'Athlon MP', 184 => 'Duron', 185 => 'Pentium M',
3102 186 => 'Celeron D', 187 => 'Pentium D', 188 => 'Pentium Extreme',
3103 189 => 'Core Solo', 190 => 'Core2', 191 => 'Core2 Duo',
3104 198 => 'Core i7', 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3105 201 => 'G4', 202 => 'G5', 203 => 'ESA/390 G6',
3106 204 => 'z/Architectur', 210 => 'C7-M', 211 => 'C7-D',
3107 212 => 'C7', 213 => 'Eden', 214 => 'Multi-Core Xeon',
3108 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx', 218 => 'Dual-Core Xeon 5xxx',
3109 219 => 'Quad-Core Xeon 5xxx', 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3110 223 => 'Multi-Core Xeon 7xxx', 250 => 'i860', 251 => 'i960',
3114 foreach my $out (@output) {
3116 $index = exists $out->{processorDeviceStatusIndex}
3117 ? $out->{processorDeviceStatusIndex} - 1
3118 : $out->{processorDeviceIndex} - 1;
3119 $status = exists $out->{processorDeviceStatusStatus}
3120 ? $snmp_status{$out->{processorDeviceStatusStatus}}
3121 : $snmp_status{$out->{processorDeviceStatus}};
3122 if (exists $out->{processorDeviceStatusReading}) {
3123 my @states = (); # contains states for the CPU
3125 # get the combined state from the StatusReading OID
3126 foreach my $mask (sort keys %cpu_reading) {
3127 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3128 push @states, $cpu_reading{$mask};
3132 # Finally, create the state string
3133 $state = join q{, }, @states;
3136 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state);
3138 $man = $out->{processorDeviceManufacturerName};
3139 $family = (exists $out->{processorDeviceFamily}
3140 and exists $cpu_family{$out->{processorDeviceFamily}})
3141 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3142 $speed = $out->{processorDeviceCurrentSpeed};
3143 $brand = $out->{processorDeviceBrandName};
3146 $index = $out->{'Index'};
3147 $status = $out->{'Status'};
3148 $state = $out->{'State'};
3149 $brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
3150 $family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
3151 $man = exists $out->{'Processor Manufacturer'} ? $out->{'Processor Manufacturer'} : undef;
3152 $speed = exists $out->{'Current Speed'} ? $out->{'Current Speed'} : undef;
3155 next CPU if blacklisted('cpu', $index);
3157 # Ignore unoccupied CPU slots (omreport)
3158 next CPU if (defined $out->{'Processor Manufacturer'}
3159 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3160 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3162 # Ignore unoccupied CPU slots (snmp)
3163 if ($snmp and exists $out->{processorDeviceStatusReading}
3164 and $out->{processorDeviceStatusReading} == 0) {
3170 if (defined $brand) {
3171 $brand =~ s{\s\s+}{ }gxms;
3172 $brand =~ s{\((R|tm)\)}{}gxms;
3173 $brand =~ s{\s(CPU|Processor)}{}xms;
3174 $brand =~ s{\s\@}{}xms;
3176 elsif (defined $family and defined $man and defined $speed) {
3177 $speed =~ s{\A (\d+) .*}{$1}xms;
3178 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3185 if ($status ne 'Ok') {
3186 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3187 $index, $brand, $state;
3188 report('chassis', $msg, $status2nagios{$status}, $index);
3192 my $msg = sprintf 'Processor %d [%s] is %s',
3193 $index, $brand, $state;
3194 report('chassis', $msg, $E_OK, $index);
3201 #-----------------------------------------
3202 # CHASSIS: Check voltage probes
3203 #-----------------------------------------
3205 return if blacklisted('volt', 'all');
3209 my $reading = undef;
3210 my $location = undef;
3216 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3217 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3218 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3219 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3220 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3223 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3224 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3226 if (!defined $result) {
3227 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3228 $snmp_session->close;
3232 @output = @{ get_snmp_output($result, \%volt_oid) };
3235 @output = @{ run_omreport("$omopt_chassis volts") };
3238 my %volt_discrete_reading
3245 foreach my $out (@output) {
3247 $index = $out->{voltageProbeIndex} - 1;
3248 $status = $snmp_probestatus{$out->{voltageProbeStatus}};
3249 $reading = exists $out->{voltageProbeReading}
3250 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3251 : get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading);
3252 $location = $out->{voltageProbeLocationName};
3255 $index = $out->{'Index'};
3256 $status = $out->{'Status'};
3257 $reading = $out->{'Reading'};
3258 $location = $out->{'Probe Name'};
3261 next VOLT if blacklisted('volt', $index);
3264 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3265 $index, $location, $reading;
3266 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3267 report('chassis', $msg, $err, $index);
3273 #-----------------------------------------
3274 # CHASSIS: Check batteries
3275 #-----------------------------------------
3276 sub check_batteries {
3277 return if blacklisted('bp', 'all');
3281 my $reading = undef;
3282 my $location = undef;
3288 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3289 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3290 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3291 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3294 if ($opt{use_get_table}) {
3295 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3296 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3299 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3302 # No batteries is OK
3303 return 0 if !defined $result;
3305 @output = @{ get_snmp_output($result, \%bat_oid) };
3308 @output = @{ run_omreport("$omopt_chassis batteries") };
3313 1 => 'Predictive Failure',
3315 4 => 'Presence Detected',
3319 foreach my $out (@output) {
3321 $index = $out->{batteryIndex} - 1;
3322 $status = $snmp_status{$out->{batteryStatus}};
3323 $reading = get_hashval($out->{batteryReading}, \%bat_reading);
3324 $location = $out->{batteryLocationName};
3327 $index = $out->{'Index'};
3328 $status = $out->{'Status'};
3329 $reading = $out->{'Reading'};
3330 $location = $out->{'Probe Name'};
3333 next BATTERY if blacklisted('bp', $index);
3336 my $msg = sprintf 'Battery probe %d [%s] is %s',
3337 $index, $location, $reading;
3338 report('chassis', $msg, $status2nagios{$status}, $index);
3344 #-----------------------------------------
3345 # CHASSIS: Check amperage probes (power monitoring)
3346 #-----------------------------------------
3347 sub check_pwrmonitoring {
3348 return if blacklisted('amp', 'all');
3352 my $reading = undef;
3353 my $location = undef;
3354 my $max_crit = undef;
3355 my $max_warn = undef;
3362 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3363 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3364 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3365 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3366 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3367 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3368 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3369 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3372 if ($opt{use_get_table}) {
3373 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3374 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3377 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3380 # No pwrmonitoring is OK
3381 return 0 if !defined $result;
3383 @output = @{ get_snmp_output($result, \%amp_oid) };
3386 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3389 my %amp_type # Amperage probe types
3391 1 => 'amperageProbeTypeIsOther', # other than following values
3392 2 => 'amperageProbeTypeIsUnknown', # unknown
3393 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3394 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3395 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3396 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3397 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3398 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3399 9 => 'amperageProbeTypeIsIO', # I/O probe
3400 10 => 'amperageProbeTypeIsCore', # Core probe
3401 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3402 12 => 'amperageProbeTypeIsBattery', # Battery probe
3403 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3404 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3405 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3406 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3407 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3408 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3409 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3410 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3421 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3422 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3423 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3424 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3425 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3429 foreach my $out (@output) {
3431 $index = $out->{amperageProbeIndex} - 1;
3432 $status = $snmp_status{$out->{amperageProbeStatus}};
3433 $reading = get_hashval($out->{amperageProbeType}, \%amp_type) eq 'amperageProbeTypeIsDiscrete'
3434 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3435 : $out->{amperageProbeReading};
3436 $location = $out->{amperageProbeLocationName};
3437 $max_crit = exists $out->{amperageProbeUpperCriticalThreshold}
3438 ? $out->{amperageProbeUpperCriticalThreshold} : 0;
3439 $max_warn = exists $out->{amperageProbeUpperNonCriticalThreshold}
3440 ? $out->{amperageProbeUpperNonCriticalThreshold} : 0;
3441 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3442 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3443 if ($unit eq 'hA') {
3451 $index = $out->{'Index'};
3452 next AMP if (!defined $index || $index !~ m/^\d+$/x);
3453 $status = $out->{'Status'};
3454 $reading = $out->{'Reading'};
3455 $location = $out->{'Probe Name'};
3456 $max_crit = $out->{'Failure Threshold'} ne '[N/A]'
3457 ? $out->{'Failure Threshold'} : 0;
3458 $max_warn = $out->{'Warning Threshold'} ne '[N/A]'
3459 ? $out->{'Warning Threshold'} : 0;
3460 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3462 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3463 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3466 next AMP if blacklisted('amp', $index);
3467 next AMP if $index !~ m{\A \d+ \z}xms;
3470 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3471 $index, $location, $reading, $unit, $status;
3472 report('chassis', $msg, $status2nagios{$status}, $index);
3474 # Collect performance data
3475 if (defined $opt{perfdata}) {
3476 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3477 my $pname = lc $location;
3478 $pname =~ s{\s}{_}gxms;
3479 my $pkey = join q{_}, 'pwr_mon', $index, $pname;
3480 my $pval = join q{;}, "$reading$unit", $max_warn, $max_crit;
3481 $perfdata{$pkey} = $pval;
3485 # Collect EXTRA performance data not found at first run. This is a
3487 if (defined $opt{perfdata} && !$snmp) {
3493 foreach (keys %perfdata) {
3494 if (m/\A pwr_mon_(\d+)/xms) {
3500 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3502 if ($line eq 'Location;Reading') {
3510 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s ([AW]) \z/xms) {
3514 $aname =~ s{\s}{_}gxms;
3516 # don't use an existing index
3517 while (exists $used{$index}) { ++$index; }
3519 $perfdata{"pwr_mon_${index}_${aname}"} = "$aval$aunit;0;0";
3529 #-----------------------------------------
3530 # CHASSIS: Check intrusion
3531 #-----------------------------------------
3532 sub check_intrusion {
3533 return if blacklisted('intr', 'all');
3537 my $reading = undef;
3543 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3544 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3545 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3548 if ($opt{use_get_table}) {
3549 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3550 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3553 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3556 # No intrusion is OK
3557 return 0 if !defined $result;
3559 @output = @{ get_snmp_output($result, \%int_oid) };
3562 @output = @{ run_omreport("$omopt_chassis intrusion") };
3567 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3568 2 => 'Breached', # chassis currently breached
3569 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3570 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3574 foreach my $out (@output) {
3576 $index = $out->{intrusionIndex} - 1;
3577 $status = $snmp_status{$out->{intrusionStatus}};
3578 $reading = get_hashval($out->{intrusionReading}, \%int_reading);
3581 $index = $out->{'Index'};
3582 $status = $out->{'Status'};
3583 $reading = $out->{'State'};
3586 next INTRUSION if blacklisted('intr', $index);
3589 if ($status ne 'Ok') {
3590 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3592 report('chassis', $msg, $E_WARNING, $index);
3596 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3597 $index, $status, $reading;
3598 report('chassis', $msg, $E_OK, $index);
3605 #-----------------------------------------
3606 # CHASSIS: Check alert log
3607 #-----------------------------------------
3608 sub check_alertlog {
3609 return if $snmp; # Not supported with SNMP
3611 my @output = @{ run_omreport("$omopt_system alertlog") };
3612 foreach my $out (@output) {
3613 ++$count{alert}{$out->{Severity}};
3616 # Create error messages and set exit value if appropriate
3618 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
3619 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3621 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
3622 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
3623 report('other', $msg, $err);
3628 #-----------------------------------------
3629 # CHASSIS: Check ESM log overall health
3630 #-----------------------------------------
3631 sub check_esmlog_health {
3635 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
3636 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
3637 if (!defined $result) {
3638 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
3639 $snmp_session->error;
3640 report('other', $msg, $E_UNKNOWN);
3642 $health = $snmp_status{$result->{$systemStateEventLogStatus}};
3645 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
3646 if (m/\A Health;(.+) \z/xms) {
3654 # If the overall health of the ESM log is other than "Ok", the
3655 # fill grade of the log is more than 80% and the log should be
3657 if ($health eq 'Ok') {
3658 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
3659 report('other', $msg, $E_OK);
3661 elsif ($health eq 'Critical') {
3662 my $msg = sprintf 'ESM log is 100%% full';
3663 report('other', $msg, $status2nagios{$health});
3666 my $msg = sprintf 'ESM log is more than 80%% full';
3667 report('other', $msg, $status2nagios{$health});
3673 #-----------------------------------------
3674 # CHASSIS: Check ESM log
3675 #-----------------------------------------
3682 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
3684 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
3687 return if !defined $result;
3689 @output = @{ get_snmp_output($result, \%esm_oid) };
3690 foreach my $out (@output) {
3691 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
3695 @output = @{ run_omreport("$omopt_system esmlog") };
3696 foreach my $out (@output) {
3697 ++$count{esm}{$out->{Severity}};
3701 # Create error messages and set exit value if appropriate
3703 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
3704 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3706 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
3707 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
3708 report('other', $msg, $err);
3714 # Handy function for checking all storage components
3717 check_controllers();
3718 check_physical_disks();
3719 check_virtual_disks();
3720 check_cache_battery();
3723 check_enclosure_fans();
3724 check_enclosure_pwr();
3725 check_enclosure_temp();
3726 check_enclosure_emms();
3732 #---------------------------------------------------------------------
3734 #---------------------------------------------------------------------
3737 # Fetch output from 'omreport chassis info', put in sysinfo hash
3739 sub get_omreport_chassis_info {
3740 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
3741 my @lines = <$INFO>;
3744 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag)/xms;
3745 my ($key, $val) = split /;/xms;
3746 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3747 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3748 if ($key eq 'Chassis Model' or $key eq 'Model') {
3749 $sysinfo{model} = $val;
3751 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
3752 $sysinfo{serial} = $val;
3760 # Fetch output from 'omreport chassis bios', put in sysinfo hash
3762 sub get_omreport_chassis_bios {
3763 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
3764 my @lines = <$BIOS>;
3768 my ($key, $val) = split /;/xms;
3769 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3770 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3771 $sysinfo{bios} = $val if $key eq 'Version';
3772 $sysinfo{biosdate} = $val if $key eq 'Release Date';
3779 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
3781 sub get_omreport_system_operatingsystem {
3782 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
3787 my ($key, $val) = split /;/xms;
3788 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3789 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3790 if ($key eq 'Operating System') {
3791 $sysinfo{osname} = $val;
3793 elsif ($key eq 'Operating System Version') {
3794 $sysinfo{osver} = $val;
3802 # Fetch output from 'omreport about', put in sysinfo hash
3804 sub get_omreport_about {
3805 if (open my $OM, '-|', "$omreport about -fmt ssv") {
3809 if (m/\A Version;(.+) \z/xms) {
3819 # Fetch chassis info via SNMP, put in sysinfo hash
3821 sub get_snmp_chassis_info {
3824 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
3825 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
3828 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
3829 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
3831 if (defined $result) {
3832 foreach my $oid (keys %{ $result }) {
3833 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
3834 $sysinfo{model} = $result->{$oid};
3835 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
3837 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
3838 $sysinfo{serial} = $result->{$oid};
3843 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
3844 $snmp_session->error;
3845 report('other', $msg, $E_UNKNOWN);
3851 # Fetch BIOS info via SNMP, put in sysinfo hash
3853 sub get_snmp_chassis_bios {
3856 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
3857 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
3860 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
3861 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
3863 if (defined $result) {
3864 foreach my $oid (keys %{ $result }) {
3865 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
3866 $sysinfo{biosdate} = $result->{$oid};
3867 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
3869 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
3870 $sysinfo{bios} = $result->{$oid};
3875 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
3876 $snmp_session->error;
3877 report('other', $msg, $E_UNKNOWN);
3883 # Fetch OS info via SNMP, put in sysinfo hash
3885 sub get_snmp_system_operatingsystem {
3888 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
3889 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
3892 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
3893 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
3895 if (defined $result) {
3896 foreach my $oid (keys %{ $result }) {
3897 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
3898 $sysinfo{osname} = ($result->{$oid});
3900 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
3901 $sysinfo{osver} = $result->{$oid};
3906 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
3907 $snmp_session->error;
3908 report('other', $msg, $E_UNKNOWN);
3914 # Fetch OMSA version via SNMP, put in sysinfo hash
3916 sub get_snmp_about {
3919 '1.3.6.1.4.1.674.10892.1.100.10.0' => 'systemManagementSoftwareGlobalVersionName',
3921 my $systemManagementSoftwareGroup = '1.3.6.1.4.1.674.10892.1.100';
3922 my $result = $snmp_session->get_table(-baseoid => $systemManagementSoftwareGroup);
3923 if (defined $result) {
3924 foreach my $oid (keys %{ $result }) {
3925 if (exists $omsa_oid{$oid} and $omsa_oid{$oid} eq 'systemManagementSoftwareGlobalVersionName') {
3926 $sysinfo{om} = ($result->{$oid});
3931 my $msg = sprintf 'SNMP ERROR getting OMSA info: %s',
3932 $snmp_session->error;
3933 report('other', $msg, $E_UNKNOWN);
3939 # Collects some information about the system
3943 # Get system model and serial number
3944 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
3946 # Get BIOS information. Only if needed
3947 if ( $opt{okinfo} >= 1
3949 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
3950 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
3953 # Get OMSA information. Only if needed
3954 if ($opt{okinfo} >= 3 or $opt{debug}) {
3955 $snmp ? get_snmp_about() : get_omreport_about();
3958 # Return now if debug
3959 return if $opt{debug};
3961 # Get OS information. Only if needed
3962 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
3963 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
3970 # Helper function for running omreport when the results are strictly
3972 sub run_omreport_info {
3973 my $command = shift;
3977 # Run omreport and fetch output
3978 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
3980 # Parse output, store in array
3981 for ((split /\n/xms, $rawtext)) {
3982 if (m/\A Error/xms) {
3983 my $msg = "Problem running 'omreport $command': $_";
3984 report('other', $msg, $E_UNKNOWN);
3986 next if !m/;/xms; # ignore lines with less than two fields
3987 my @vals = split m/;/xms;
3988 $output{$vals[0]} = $vals[1];
3991 # Finally, return the collected information
3995 # Get various firmware information (BMC, RAC)
3996 sub get_firmware_info {
3997 my @snmp_output = ();
3998 my %nrpe_output = ();
4003 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4004 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4005 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4008 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4009 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4011 # Some don't have this OID, this is ok
4012 if (!defined $result) {
4016 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4019 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4022 my %fw_type # Firmware types
4024 1 => 'other', # other than following values
4025 2 => 'unknown', # unknown
4026 3 => 'systemBIOS', # System BIOS
4027 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4028 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4029 6 => 'systemBackPlane', # System (Primary) Backplane
4030 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4031 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4032 9 => 'frontPanel', # Front Panel Controller
4033 10 => 'baseboardManagementController', # Baseboard Management Controller
4034 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4035 12 => 'sensorData', # Sensor Data Records
4036 13 => 'peripheralBay', # Peripheral Bay Backplane
4037 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4038 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4039 16 => 'rac', # Remote Access Controller
4040 17 => 'imc' # Integrated Management Controller
4045 foreach my $out (@snmp_output) {
4046 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4047 $sysinfo{'bmc'} = 1;
4048 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4050 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|imc \z}xms) {
4051 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4052 $sysinfo{'rac'} = 1;
4053 $sysinfo{'rac_name'} = $name;
4054 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4059 foreach my $key (keys %nrpe_output) {
4060 next if !defined $nrpe_output{$key};
4061 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4062 $sysinfo{'bmc'} = 1;
4063 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4065 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4067 $sysinfo{'rac'} = 1;
4068 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4069 $sysinfo{'rac_name'} = $name;
4079 #=====================================================================
4081 #=====================================================================
4083 # Here we do the actual checking of components
4084 # Check global status if applicable
4086 $globalstatus = check_global();
4089 # Do multiple selected checks
4090 if ($check{storage}) { check_storage(); }
4091 if ($check{memory}) { check_memory(); }
4092 if ($check{fans}) { check_fans(); }
4093 if ($check{power}) { check_powersupplies(); }
4094 if ($check{temp}) { check_temperatures(); }
4095 if ($check{cpu}) { check_processors(); }
4096 if ($check{voltage}) { check_volts(); }
4097 if ($check{batteries}) { check_batteries(); }
4098 if ($check{amperage}) { check_pwrmonitoring(); }
4099 if ($check{intrusion}) { check_intrusion(); }
4100 if ($check{alertlog}) { check_alertlog(); }
4101 if ($check{esmlog}) { check_esmlog(); }
4102 if ($check{esmhealth}) { check_esmlog_health(); }
4105 #---------------------------------------------------------------------
4107 #---------------------------------------------------------------------
4118 # Get system information
4121 # Get firmware info if requested via option
4122 if ($opt{okinfo} >= 1) {
4123 get_firmware_info();
4126 # Close SNMP session
4128 $snmp_session->close;
4133 print " System: $sysinfo{model}\n";
4134 print " ServiceTag: $sysinfo{serial}";
4135 print q{ } x (25 - length $sysinfo{serial}), "OMSA version: $sysinfo{om}\n";
4136 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4137 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Plugin version: $VERSION\n";
4138 if ($#report_storage >= 0) {
4139 print "-----------------------------------------------------------------------------\n";
4140 print " Storage Components \n";
4141 print "=============================================================================\n";
4142 print " STATE | ID | MESSAGE TEXT \n";
4143 print "---------+----------+--------------------------------------------------------\n";
4144 foreach (@report_storage) {
4145 my ($msg, $level, $nexus) = @{$_};
4146 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4147 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4148 $nagios_alert_count{$reverse_exitcode{$level}}++;
4151 if ($#report_chassis >= 0) {
4152 print "-----------------------------------------------------------------------------\n";
4153 print " Chassis Components \n";
4154 print "=============================================================================\n";
4155 print " STATE | ID | MESSAGE TEXT \n";
4156 print "---------+------+------------------------------------------------------------\n";
4157 foreach (@report_chassis) {
4158 my ($msg, $level, $nexus) = @{$_};
4159 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4160 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4161 $nagios_alert_count{$reverse_exitcode{$level}}++;
4164 if ($#report_other >= 0) {
4165 print "-----------------------------------------------------------------------------\n";
4166 print " Other messages \n";
4167 print "=============================================================================\n";
4168 print " STATE | MESSAGE TEXT \n";
4169 print "---------+-------------------------------------------------------------------\n";
4170 foreach (@report_other) {
4171 my ($msg, $level, $nexus) = @{$_};
4172 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4173 $nagios_alert_count{$reverse_exitcode{$level}}++;
4178 my $c = 0; # counter to determine linebreaks
4180 # Run through each message, sorted by severity level
4182 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4183 my ($msg, $level, $nexus) = @{ $_ };
4184 next ALERT if $level == $E_OK;
4186 if (defined $opt{only}) {
4187 # If user wants only critical alerts
4188 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4190 # If user wants only warning alerts
4191 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4194 # Prefix with service tag if specified with option '-i|--info'
4196 if (defined $opt{htmlinfo}) {
4197 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4198 . "\">$sysinfo{serial}</a>] " . $msg;
4201 $msg = "[$sysinfo{serial}] " . $msg;
4205 # Prefix with nagios level if specified with option '--state'
4206 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4208 # Prefix with one-letter nagios level if specified with option '--short-state'
4209 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4211 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4213 $nagios_alert_count{$reverse_exitcode{$level}}++;
4217 # Determine our exit code
4219 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4220 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4221 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4223 # Global status via SNMP.. extra safety check
4224 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4225 print "OOPS! Something is wrong with this server, but I don't know what. ";
4226 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4227 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4228 print "please file a bug report.\n";
4233 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4235 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4236 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4237 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4238 'memory' => "MEMORY OK - $count{dimm} memory modules checked",
4239 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4240 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4241 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4242 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4243 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4244 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4245 'alertlog' => $snmp ? 'OK - not supported via snmp' : "OK - Alert Log content: $count{alert}{Ok} ok, $count{alert}{'Non-Critical'} warning and $count{alert}{Critical} critical",
4246 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4247 'esmhealth' => "ESM LOG OK - less than 80% used",
4250 print $okmsg{$opt{only}};
4252 elsif ($exit_code == $E_OK && !$opt{debug}) {
4253 if (defined $opt{htmlinfo}) {
4254 printf q{OK - System: '<a href="%s">%s</a>', SN: '<a href="%s">%s</a>', hardware working fine},
4255 documentation_url($sysinfo{model}), $sysinfo{model},
4256 warranty_url($sysinfo{serial}), $sysinfo{serial};
4259 printf q{OK - System: '%s', SN: '%s', hardware working fine},
4260 $sysinfo{model}, $sysinfo{serial};
4263 if ($check{storage}) {
4264 printf ', %d logical drives, %d physical drives',
4265 $count{vdisk}, $count{pdisk};
4268 print ', not checking storage';
4271 if ($opt{okinfo} >= 1) {
4273 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4275 if ($sysinfo{rac}) {
4276 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4278 if ($sysinfo{bmc}) {
4279 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4283 if ($opt{okinfo} >= 2) {
4284 if ($check{storage}) {
4285 my @storageprint = ();
4286 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4287 chomp $sysinfo{controller}{$id}{driver};
4288 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4289 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4290 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4291 if (defined $sysinfo{controller}{$id}{storport}) {
4292 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4294 push @storageprint, $msg;
4296 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4297 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4298 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4299 $sysinfo{enclosure}{$id}->{firmware};
4303 foreach my $line (@storageprint) {
4304 print $linebreak, $line;
4309 if ($opt{okinfo} >= 3) {
4310 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4315 if ($opt{extinfo}) {
4317 if (defined $opt{htmlinfo}) {
4318 printf '------ SYSTEM: <a href="%s">%s</a>, SN: <a href="%s">%s</a>',
4319 documentation_url($sysinfo{model}), $sysinfo{model},
4320 warranty_url($sysinfo{serial}), $sysinfo{serial};
4323 printf '------ SYSTEM: %s, SN: %s',
4324 $sysinfo{model}, $sysinfo{serial};
4327 if (defined $opt{postmsg}) {
4329 if (-f $opt{postmsg}) {
4330 open my $POST, '<', $opt{postmsg}
4331 or ( print $linebreak
4332 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4333 and exit $E_UNKNOWN );
4339 $post = $opt{postmsg};
4341 if (defined $post) {
4343 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4344 $post =~ s{[%]m}{$sysinfo{model}}gxms;
4345 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4346 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4347 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4348 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4349 $post =~ s{[%]p}{$count{pdisk}}gxms;
4350 $post =~ s{[%]l}{$count{vdisk}}gxms;
4351 $post =~ s{[%]n}{$linebreak}gxms;
4352 $post =~ s{[%]{2}}{%}gxms;
4358 # Print any perl warnings that have occured
4359 if (@perl_warnings) {
4360 foreach (@perl_warnings) {
4362 print "${linebreak}INTERNAL ERROR: @$_";
4364 $exit_code = $E_UNKNOWN;
4367 # Reset the WARN signal
4368 $SIG{__WARN__} = $original_sigwarn;
4370 # Print performance data
4371 if (defined $opt{perfdata} && !$opt{debug} && %perfdata) {
4372 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4383 return ($order{(split /_/, $a, 2)[0]} cmp $order{(split /_/, $b, 2)[0]}) || $a cmp $b;
4386 print join $lb, map { "'$_'=$perfdata{$_}" } sort perfdata keys %perfdata;
4389 # Print a linebreak at the end
4390 print "\n" if !$opt{debug};
4392 # Exit with proper exit code