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
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 $SIG{__WARN__} = \&collect_perl_warning;
57 # Version and similar info
58 $NAME = 'check_openmanage';
59 $VERSION = '3.5.7-beta16';
60 $AUTHOR = 'Trond H. Amundsen';
61 $CONTACT = 't.h.amundsen@usit.uio.no';
69 # Firmware update lock file [FIXME: location on Windows?]
70 $FW_LOCK = '/var/lock/.spsetup'; # default on Linux
73 $USAGE = <<"END_USAGE";
74 Usage: $NAME [OPTION]...
82 -p, --perfdata Output performance data
83 -t, --timeout Plugin timeout in seconds
84 -c, --critical Customise temperature critical limits
85 -w, --warning Customise temperature warning limits
86 -d, --debug Debug output, reports everything
87 -h, --help Display this help text
88 -V, --version Display version info
92 -H, --hostname Hostname or IP of the server (needed for SNMP)
93 -C, --community SNMP community string
94 -P, --protocol SNMP protocol version
95 --port SNMP port number
99 -i, --info Prefix any alerts with the service tag
100 -e, --extinfo Append system info to alerts
101 -s, --state Prefix alerts with alert state
102 -S, --short-state Prefix alerts with alert state (abbreviated)
103 -o, --okinfo Verbosity when check result is OK
104 -I, --htmlinfo HTML output with clickable links
106 CHECK CONTROL AND BLACKLISTING:
108 -a, --all Check everything, even log content
109 -b, --blacklist Blacklist missing and/or failed components
110 --only Only check a certain component or alert type
111 --check Fine-tune which components are checked
113 For more information and advanced options, see the manual page or URL:
114 http://folk.uio.no/trondham/software/check_openmanage.html
117 # Version and license text
118 $LICENSE = <<"END_LICENSE";
120 Copyright (C) 2010 $AUTHOR
121 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
122 This is free software: you are free to change and redistribute it.
123 There is NO WARRANTY, to the extent permitted by law.
125 Written by $AUTHOR <$CONTACT>
128 # Options with default values
129 %opt = ( 'blacklist' => [], # blacklisting
130 'check' => [], # check control
131 'critical' => [], # temperature critical limits
132 'warning' => [], # temperature warning limits
133 'timeout' => 30, # default timeout is 30 seconds
134 'debug' => 0, # debugging / verbose output
135 'help' => 0, # display help output
136 'perfdata' => undef, # output performance data
137 'info' => 0, # display servicetag
138 'extinfo' => 0, # display extra info
139 'htmlinfo' => undef, # html tags in output
140 'postmsg' => undef, # post message
141 'state' => 0, # display alert type
142 'short-state' => 0, # display alert type (short)
143 'okinfo' => 0, # default "ok" output level
144 'linebreak' => undef, # specify linebreak
145 'version' => 0, # plugin version info
146 'all' => 0, # check everything
147 'only' => undef, # only one component
148 'omreport' => undef, # omreport path
149 'port' => 161, # default SNMP port
150 'hostname' => undef, # hostname or IP
151 'community' => 'public', # SMNP v1 or v2c
152 'protocol' => 2, # default SNMP protocol 2c
153 'username' => undef, # SMNP v3
154 'authpassword' => undef, # SMNP v3
155 'authkey' => undef, # SMNP v3
156 'authprotocol' => undef, # SMNP v3
157 'privpassword' => undef, # SMNP v3
158 'privkey' => undef, # SMNP v3
159 'privprotocol' => undef, # SMNP v3
160 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
164 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
165 'check=s' => \@{ $opt{check} },
166 'c|critical=s' => \@{ $opt{critical} },
167 'w|warning=s' => \@{ $opt{warning} },
168 't|timeout=i' => \$opt{timeout},
169 'd|debug' => \$opt{debug},
170 'h|help' => \$opt{help},
171 'V|version' => \$opt{version},
172 'p|perfdata:s' => \$opt{perfdata},
173 'i|info' => \$opt{info},
174 'e|extinfo' => \$opt{extinfo},
175 'I|htmlinfo:s' => \$opt{htmlinfo},
176 'postmsg=s' => \$opt{postmsg},
177 's|state' => \$opt{state},
178 'S|short-state' => \$opt{shortstate},
179 'o|ok-info=i' => \$opt{okinfo},
180 'linebreak=s' => \$opt{linebreak},
181 'a|all' => \$opt{all},
182 'only=s' => \$opt{only},
183 'omreport=s' => \$opt{omreport},
184 'port=i' => \$opt{port},
185 'H|hostname=s' => \$opt{hostname},
186 'C|community=s' => \$opt{community},
187 'P|protocol=i' => \$opt{protocol},
188 'U|username=s' => \$opt{username},
189 'authpassword=s' => \$opt{authpassword},
190 'authkey=s' => \$opt{authkey},
191 'authprotocol=s' => \$opt{authprotocol},
192 'privpassword=s' => \$opt{privpassword},
193 'privkey=s' => \$opt{privkey},
194 'privprotocol=s' => \$opt{privprotocol},
195 'use-get_table' => \$opt{use_get_table},
196 ) or do { print $USAGE; exit $E_UNKNOWN };
198 # If user requested help
204 # If user requested version info
212 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
217 # If we're using SNMP
218 $snmp = defined $opt{hostname} ? 1 : 0;
220 # SNMP session variables
221 $snmp_session = undef;
224 # The omreport command
227 # Check flags, override available with the --check option
228 %check = ( 'storage' => 1, # check storage subsystem
229 'memory' => 1, # check memory (dimms)
230 'fans' => 1, # check fan status
231 'power' => 1, # check power supplies
232 'temp' => 1, # check temperature
233 'cpu' => 1, # check processors
234 'voltage' => 1, # check voltage
235 'batteries' => 1, # check battery probes
236 'amperage' => 1, # check power consumption
237 'intrusion' => 1, # check intrusion detection
238 'alertlog' => 0, # check the alert log
239 'esmlog' => 0, # check the ESM log (hardware log)
240 'esmhealth' => 1, # check the ESM log overall health
244 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
246 # Line break from option
247 if (defined $opt{linebreak}) {
248 if ($opt{linebreak} eq 'REG') {
251 elsif ($opt{linebreak} eq 'HTML') {
252 $linebreak = '<br/>';
255 $linebreak = $opt{linebreak};
259 # Exit with status=UNKNOWN if there is firmware upgrade in progress
260 if (!$snmp && -f $FW_LOCK) {
261 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
265 # List of controllers and enclosures
266 @controllers = (); # controllers
267 @enclosures = (); # enclosures
270 @report_storage = (); # messages with associated nagios level (storage)
271 @report_chassis = (); # messages with associated nagios level (chassis)
272 @report_other = (); # messages with associated nagios level (other)
274 # Counters for everything
277 'pdisk' => 0, # number of physical disks
278 'vdisk' => 0, # number of logical drives (virtual disks)
279 'temp' => 0, # number of temperature probes
280 'volt' => 0, # number of voltage probes
281 'amp' => 0, # number of amperage probes
282 'intr' => 0, # number of intrusion probes
283 'dimm' => 0, # number of memory modules
284 'fan' => 0, # number of fan probes
285 'cpu' => 0, # number of CPUs
286 'bat' => 0, # number of batteries
287 'power' => 0, # number of power supplies
289 'Critical' => 0, # critical entries in ESM log
290 'Non-Critical' => 0, # warning entries in ESM log
291 'Ok' => 0, # ok entries in ESM log
294 'Critical' => 0, # critical entries in alert log
295 'Non-Critical' => 0, # warning entries in alert log
296 'Ok' => 0, # ok entries in alert log
303 # Global health status
304 $global = 1; # default is to check global status
305 $globalstatus = $E_OK; # default global health status is "OK"
307 # Nagios error levels reversed
311 $E_WARNING => 'WARNING',
312 $E_CRITICAL => 'CRITICAL',
313 $E_UNKNOWN => 'UNKNOWN',
316 # OpenManage (omreport) and SNMP error levels
319 'Unknown' => $E_CRITICAL,
320 'Critical' => $E_CRITICAL,
321 'Non-Critical' => $E_WARNING,
323 'Non-Recoverable' => $E_CRITICAL,
324 'Other' => $E_CRITICAL,
335 6 => 'Non-Recoverable',
338 # Probe Status via SNMP
341 1 => 'Other', # probe status is not one of the following:
342 2 => 'Unknown', # probe status is unknown (not known or monitored)
343 3 => 'Ok', # probe is reporting a value within the thresholds
344 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
345 5 => 'criticalUpper', # probe has crossed upper critical threshold
346 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
347 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
348 8 => 'criticalLower', # probe has crossed lower critical threshold
349 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
350 10 => 'failed', # probe is not functional
353 # Probe status translated to Nagios alarm levels
356 'Other' => $E_CRITICAL,
357 'Unknown' => $E_CRITICAL,
359 'nonCriticalUpper' => $E_WARNING,
360 'criticalUpper' => $E_CRITICAL,
361 'nonRecoverableUpper' => $E_CRITICAL,
362 'nonCriticalLower' => $E_WARNING,
363 'criticalLower' => $E_CRITICAL,
364 'nonRecoverableLower' => $E_CRITICAL,
365 'failed' => $E_CRITICAL,
368 # System information gathered
371 'bios' => 'N/A', # BIOS version
372 'biosdate' => 'N/A', # BIOS release date
373 'serial' => 'N/A', # serial number (service tag)
374 'model' => 'N/A', # system model
375 'osname' => 'N/A', # OS name
376 'osver' => 'N/A', # OS version
377 'om' => 'N/A', # OMSA version
378 'bmc' => 0, # HAS baseboard management controller (BMC)
379 'rac' => 0, # HAS remote access controller (RAC)
380 'rac_name' => 'N/A', # remote access controller (RAC)
381 'bmc_fw' => 'N/A', # BMC firmware
382 'rac_fw' => 'N/A', # RAC firmware
385 # Adjust which checks to perform
386 adjust_checks() if defined $opt{check};
388 # Blacklisted components
389 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
391 # If blacklisting is in effect, don't check global health status
392 if (scalar keys %blacklist > 0) {
396 # Take into account new hardware and blades
397 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
398 $omopt_system = 'system'; # default "system" option to omreport
399 $blade = 0; # if this is a blade system
401 # Some initializations and checking before we begin
403 snmp_initialize(); # initialize SNMP
404 snmp_check(); # check that SNMP works
405 snmp_detect_blade(); # detect blade via SNMP
408 # Find the omreport binary
410 # Check help output from omreport, see which options are available.
411 # Also detecting blade via omreport.
412 check_omreport_options();
416 #---------------------------------------------------------------------
418 #---------------------------------------------------------------------
421 # Store a message in one of the message arrays
424 my ($type, $msg, $exval, $id) = @_;
425 defined $id or $id = q{};
429 'storage' => \@report_storage,
430 'chassis' => \@report_chassis,
431 'other' => \@report_other,
434 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
439 # Run command, put resulting output lines in an array and return a
440 # pointer to that array
445 open my $CMD, '-|', $command
446 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
450 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
451 and return \@lines };
456 # Run command, put resulting output in a string variable and return it
461 open my $CMD, '-|', $command
462 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
463 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
466 # NOTE: We don't check the return value of close() since omreport
467 # does something weird sometimes.
475 sub snmp_initialize {
476 # Legal SNMP v3 protocols
477 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
478 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
480 # Parameters to Net::SNMP->session()
483 '-port' => $opt{port},
484 '-hostname' => $opt{hostname},
485 '-version' => $opt{protocol},
488 # Parameters for SNMP v3
489 if ($opt{protocol} == 3) {
491 # Username is mandatory
492 if (defined $opt{username}) {
493 $param{'-username'} = $opt{username};
496 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
500 # Authpassword is optional
501 if (defined $opt{authpassword}) {
502 $param{'-authpassword'} = $opt{authpassword};
505 # Authkey is optional
506 if (defined $opt{authkey}) {
507 $param{'-authkey'} = $opt{authkey};
510 # Privpassword is optional
511 if (defined $opt{privpassword}) {
512 $param{'-privpassword'} = $opt{privpassword};
515 # Privkey is optional
516 if (defined $opt{privkey}) {
517 $param{'-privkey'} = $opt{privkey};
520 # Privprotocol is optional
521 if (defined $opt{privprotocol}) {
522 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
523 $param{'-privprotocol'} = $opt{privprotocol};
526 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
527 . "must be one of [des|aes|aes128|3des|3desde]\n";
532 # Authprotocol is optional
533 if (defined $opt{authprotocol}) {
534 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
535 $param{'-authprotocol'} = $opt{authprotocol};
538 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
539 . "must be one of [md5|sha]\n";
544 # Parameters for SNMP v2c or v1
545 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
546 $param{'-community'} = $opt{community};
549 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
553 # Try to initialize the SNMP session
554 if ( eval { require Net::SNMP; 1 } ) {
555 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
556 if (!defined $snmp_session) {
557 printf "SNMP: %s\n", $snmp_error;
562 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
569 # Checking if SNMP works by probing for "chassisModelName", which all
570 # servers should have
573 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
574 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
576 # Typically if remote host isn't responding
577 if (!defined $result) {
578 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
582 # If OpenManage isn't installed or is not working
583 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
584 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
591 # Detecting blade via SNMP
593 sub snmp_detect_blade {
594 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
595 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
597 # Identify blade. Older models (4th and 5th gen models) and/or old
598 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
599 # similar, we assume that this isn't a blade
600 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
607 # Locate the omreport binary
610 # If user has specified path to omreport
611 if (defined $opt{omreport} and -x $opt{omreport}) {
612 $omreport = qq{"$opt{omreport}"};
616 # Possible full paths for omreport
619 '/usr/bin/omreport', # default on Linux
620 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA 6.2.0
621 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
622 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
623 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
624 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
625 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
626 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
629 # Find the one to use
631 foreach my $bin (@omreport_paths) {
633 $omreport = qq{"$bin"};
638 # Exit with status=UNKNOWN if OM is not installed, or we don't
639 # have permission to execute the binary
640 if (!defined $omreport) {
641 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
648 # Checks output from 'omreport -?' and searches for arguments to
649 # omreport, to accommodate deprecated options "chassis" and "system"
650 # (on newer hardware), as well as blade servers.
652 sub check_omreport_options {
653 foreach (@{ run_command("$omreport -? 2>&1") }) {
654 if (m/\A servermodule /xms) {
655 # If "servermodule" argument to omreport exists, use it
656 # instead of argument "system"
657 $omopt_system = 'servermodule';
659 elsif (m/\A mainsystem /xms) {
660 # If "mainsystem" argument to omreport exists, use it
661 # instead of argument "chassis"
662 $omopt_chassis = 'mainsystem';
664 elsif (m/\A modularenclosure /xms) {
665 # If "modularenclusure" argument to omreport exists, assume
666 # that this is a blade
674 # Read the blacklist option and return a hash containing the
675 # blacklisted components
681 if (scalar @{ $opt{blacklist} } >= 0) {
682 foreach my $black (@{ $opt{blacklist} }) {
685 open my $BL, '<', $black
686 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
699 return {} if $#bl < 0;
701 # Parse blacklist string, put in hash
702 foreach my $black (@bl) {
703 my @comps = split m{/}xms, $black;
704 foreach my $c (@comps) {
705 next if $c !~ m/=/xms;
706 my ($key, $val) = split /=/xms, $c;
707 my @vals = split /,/xms, $val;
708 $blacklist{$key} = \@vals;
716 # Read the check option and adjust the hash %check, which is a rough
717 # list of components to be checked
722 # Adjust checking based on the '--all' option
725 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
726 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
729 if (scalar @{ $opt{check} } > 0) {
730 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
734 # set the check hash to check everything
735 map { $_ = 1 } values %check;
740 # Adjust checking based on the '--only' option
741 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
743 if (scalar @{ $opt{check} } > 0) {
744 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
747 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
748 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
752 # reset the check hash
753 map { $_ = 0 } values %check;
755 # adjust the check hash
756 if ($opt{only} eq 'chassis') {
757 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
758 batteries amperage intrusion esmhealth);
761 $check{$opt{only}} = 1;
767 # Adjust checking based on the '--check' option
768 if (scalar @{ $opt{check} } >= 0) {
769 foreach my $check (@{ $opt{check} }) {
772 open my $CL, '<', $check
773 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
786 # Parse checklist string, put in hash
787 foreach my $check (@cl) {
788 my @checks = split /,/xms, $check;
789 foreach my $c (@checks) {
790 next if $c !~ m/=/xms;
791 my ($key, $val) = split /=/xms, $c;
796 # Check if we should check global health status
798 foreach (keys %check) {
799 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
800 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
802 if ($check{$_} == 0) { # found something with checking turned off
812 # Runs omreport and returns an array of anonymous hashes containing
814 # Takes one argument: string containing parameters to omreport
821 # Errors that are OK. Some low-end poweredge (and blades) models
822 # don't have RAID controllers, intrusion detection sensor, or
823 # redundant/instrumented power supplies etc.
826 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
827 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
828 | No\scontrollers\sfound # No RAID controller
829 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
830 | Invalid\scommand:\spwrmonitoring # Older OMSAs lack this command(?)
831 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
834 # Errors that are OK on blade servers
837 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
840 # Run omreport and fetch output
841 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
842 return [] if !defined $rawtext;
844 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
845 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
847 # Openmanage sometimes puts a linebreak between "Error" and the
849 $rawtext =~ s{^Error\s*\n}{Error: }xms;
851 # Parse output, store in array
852 for ((split m{\n}xms, $rawtext)) {
854 next if m{$ok_errors}xms;
855 next if ($blade and m{$ok_blade_errors}xms);
856 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
859 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
860 my @vals = split /;/xms;
861 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed) \z/xms) {
866 push @output, { map { $_ => $vals[$i++] } @keys };
871 # Finally, return the collected information
877 # Checks if a component is blacklisted. Returns 1 if the component is
878 # blacklisted, 0 otherwise. Takes two arguments:
879 # arg1: component name
880 # arg2: component id or index
883 my $name = shift; # component name
884 my $id = shift; # component id
885 my $ret = 0; # return value
887 if (defined $blacklist{$name}) {
888 foreach my $comp (@{ $blacklist{$name} }) {
889 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
898 # Converts the NexusID from SNMP to our version
901 $nexus =~ s{\A \\}{}xms;
902 $nexus =~ s{\\}{:}gxms;
906 # Sets custom temperature thresholds based on user supplied options
907 sub custom_temperature_thresholds {
908 my $type = shift; # type of threshold, either w (warning) or c (critical)
909 my %thres = (); # will contain the thresholds
910 my @limits = (); # holds the input
912 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
914 if (scalar @opt >= 0) {
915 foreach my $t (@opt) {
919 or do { report('other', "Couldn't open temperature threshold file $t: $!",
920 $E_UNKNOWN) and return {} };
931 # Parse checklist string, put in hash
932 foreach my $th (@limits) {
933 my @tmp = split m{,}xms, $th;
934 foreach my $t (@tmp) {
935 next if $t !~ m{=}xms;
936 my ($key, $val) = split m{=}xms, $t;
937 if ($val =~ m{/}xms) {
938 my ($max, $min) = split m{/}xms, $val;
939 $thres{$key}{max} = $max;
940 $thres{$key}{min} = $min;
943 $thres{$key}{max} = $val;
952 # Gets the output from SNMP result according to the OIDs checked
953 sub get_snmp_output {
954 my ($result,$oidref) = @_;
958 foreach my $oid (keys %{ $result }) {
960 $short =~ s{\s}{}gxms; # remove whitespace
961 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
963 if (exists $oidref->{$short}) {
964 $temp[$id]{$oidref->{$short}} = $result->{$oid};
968 # Remove any empty indexes
969 foreach my $out (@temp) {
979 # Map the controller or other item in-place
981 my ($key, $val, $list) = @_;
983 foreach my $lst (@{ $list }) {
984 if (!exists $lst->{$key}) {
991 # Return the URL for official Dell documentation for a specific
993 sub documentation_url {
996 # create model short form, e.g. "r710"
997 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
999 # special case for blades (e.g. M600, M710), they have common
1001 $model =~ s{\A m\d+ \z}{m}xms;
1003 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1006 # Return the URL for warranty information for a server with a given
1007 # serial number (servicetag)
1011 # Dell support sites for different parts of the world
1014 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1015 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1016 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1019 # warranty URLs for different country codes
1023 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1024 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1025 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1026 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1027 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1028 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1029 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1030 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1031 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1032 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1033 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1034 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1035 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1036 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1037 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1038 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1039 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1040 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1041 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1042 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1044 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1045 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1046 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1047 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1049 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1050 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1051 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1053 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1056 if (exists $url{$opt{htmlinfo}}) {
1057 return $url{$opt{htmlinfo}} . $tag;
1060 return $url{XX} . $tag;
1065 # This helper function returns the corresponding value of a hash key,
1066 # but takes into account that the key may not exist
1068 my $key = shift || return undef;
1070 return exists $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1075 #---------------------------------------------------------------------
1077 #---------------------------------------------------------------------
1079 #-----------------------------------------
1080 # Check global health status
1081 #-----------------------------------------
1087 # Checks global status, i.e. both storage and chassis
1089 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1090 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1091 if (!defined $result) {
1092 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1095 $health = $status2nagios{$snmp_status{$result->{$systemStateGlobalSystemStatus}}};
1099 # NB! This does not check storage, only chassis...
1101 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1103 next if m/\A SEVERITY;COMPONENT/xms;
1104 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1105 $health = $status2nagios{$1};
1116 #-----------------------------------------
1117 # STORAGE: Check controllers
1118 #-----------------------------------------
1119 sub check_controllers {
1120 return if blacklisted('ctrl', 'all');
1129 my $firmware = undef;
1131 my $minstdr = undef; # Minimum required Storport driver version
1132 my $stdr = undef; # Storport driver version
1138 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1139 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1140 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1141 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1142 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1143 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1144 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1145 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1146 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1147 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1148 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1151 # We use get_table() here for the odd case where a server has
1152 # two or more controllers, and where some OIDs are missing on
1153 # one of the controllers.
1154 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1155 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1157 # No controllers is OK
1158 return if !defined $result;
1160 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1163 @output = @{ run_omreport('storage controller') };
1177 foreach my $out (@output) {
1179 $id = $out->{controllerNumber} - 1;
1180 $name = $out->{controllerName};
1181 $state = get_hashval($out->{controllerState}, \%ctrl_state);
1182 $status = $snmp_status{$out->{controllerComponentStatus}};
1183 $minfw = exists $out->{controllerMinFWVersion}
1184 ? $out->{controllerMinFWVersion} : undef;
1185 $mindr = exists $out->{controllerMinDriverVersion}
1186 ? $out->{controllerMinDriverVersion} : undef;
1187 $firmware = exists $out->{controllerFWVersion}
1188 ? $out->{controllerFWVersion} : 'N/A';
1189 $driver = exists $out->{controllerDriverVersion}
1190 ? $out->{controllerDriverVersion} : 'N/A';
1191 $minstdr = exists $out->{'controllerMinRequiredStorportVer'}
1192 ? $out->{controllerMinRequiredStorportVer} : undef;
1193 $stdr = exists $out->{controllerStorportDriverVersion}
1194 ? $out->{controllerStorportDriverVersion} : undef;
1195 $nexus = convert_nexus($out->{controllerNexusID});
1199 $name = $out->{Name};
1200 $state = $out->{State};
1201 $status = $out->{Status};
1202 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1203 ? $out->{'Minimum Required Firmware Version'} : undef;
1204 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1205 ? $out->{'Minimum Required Driver Version'} : undef;
1206 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1207 ? $out->{'Firmware Version'} : 'N/A';
1208 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1209 ? $out->{'Driver Version'} : 'N/A';
1210 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1211 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1212 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1213 $stdr = (exists $out->{'Storport Driver Version'}
1214 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1215 ? $out->{'Storport Driver Version'} : undef;
1219 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1220 push @controllers, $id;
1222 # Collecting some storage info
1223 $sysinfo{'controller'}{$id}{'id'} = $nexus;
1224 $sysinfo{'controller'}{$id}{'name'} = $name;
1225 $sysinfo{'controller'}{$id}{'driver'} = $driver;
1226 $sysinfo{'controller'}{$id}{'firmware'} = $firmware;
1227 $sysinfo{'controller'}{$id}{'storport'} = $stdr;
1229 next CTRL if blacklisted('ctrl', $nexus);
1231 # Special case: old firmware
1232 if (!blacklisted('ctrl_fw', $id) && defined $minfw) {
1234 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1235 $id, $name, $firmware;
1236 report('storage', $msg, $E_WARNING, $nexus);
1238 # Special case: old driver
1239 if (!blacklisted('ctrl_driver', $id) && defined $mindr) {
1241 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1242 $id, $name, $driver;
1243 report('storage', $msg, $E_WARNING, $nexus);
1245 # Special case: old storport driver
1246 if (!blacklisted('ctrl_stdr', $id) && defined $minstdr) {
1248 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1250 report('storage', $msg, $E_WARNING, $nexus);
1253 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1254 and (defined $minfw or defined $mindr or defined $minstdr))) {
1255 my $msg = sprintf 'Controller %d [%s] is %s',
1257 report('storage', $msg, $E_OK, $nexus);
1261 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1263 report('storage', $msg, $status2nagios{$status}, $nexus);
1270 #-----------------------------------------
1271 # STORAGE: Check physical drives
1272 #-----------------------------------------
1273 sub check_physical_disks {
1274 return if $#controllers == -1;
1275 return if blacklisted('pdisk', 'all');
1285 my $vendor = undef; # disk vendor
1286 my $product = undef; # product ID
1287 my $capacity = undef; # disk length (size) in bytes
1293 '1.3.6.1.4.1.674.10893.1.20.130.4.1.1' => 'arrayDiskNumber',
1294 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1295 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1296 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1297 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1298 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1299 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1300 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1301 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1302 '1.3.6.1.4.1.674.10893.1.20.130.4.1.16' => 'arrayDiskLunID',
1303 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1304 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1305 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1306 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1307 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1310 if ($opt{use_get_table}) {
1311 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1312 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1313 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1315 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1316 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1317 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1319 if (defined $result) {
1320 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1321 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1325 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1328 if (!defined $result) {
1329 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1330 $snmp_session->close;
1334 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1337 foreach my $c (@controllers) {
1338 # This blacklists disks with broken firmware, which includes
1339 # illegal XML characters that makes openmanage choke on itself
1340 next if blacklisted('ctrl_pdisk', $c);
1342 push @output, @{ run_omreport("storage pdisk controller=$c") };
1343 map_item('ctrl', $c, \@output);
1358 22 => 'Replacing', # FIXME: this one is not defined in the OM 6.2.0.1 MIBs
1362 28 => 'Diagnostics',
1363 34 => 'Predictive failure',
1364 35 => 'Initializing',
1367 41 => 'Unsupported',
1368 53 => 'Incompatible',
1371 # Check physical disks on each of the controllers
1373 foreach my $out (@output) {
1375 $name = $out->{arrayDiskName};
1376 if (exists $out->{arrayDiskEnclosureID}) {
1377 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskEnclosureID},
1378 $out->{arrayDiskTargetID});
1381 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskTargetID});
1383 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state);
1384 $status = $snmp_status{$out->{arrayDiskComponentStatus}};
1385 $fpred = $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1387 $nexus = convert_nexus($out->{arrayDiskNexusID});
1388 $vendor = $out->{arrayDiskVendor};
1389 $product = $out->{arrayDiskProductID};
1390 $capacity = $out->{arrayDiskLengthInMB} * 1024**2;
1391 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1392 $ctrl = $out->{arrayDiskEnclosureConnectionControllerNumber} - 1;
1394 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1395 $ctrl = $out->{arrayDiskChannelConnectionControllerNumber} - 1;
1403 $name = $out->{'Name'};
1404 $state = $out->{'State'};
1405 $status = $out->{'Status'};
1406 $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
1407 $progr = ' [' . $out->{'Progress'} . ']';
1408 $ctrl = $out->{'ctrl'};
1409 $nexus = join q{:}, $out->{ctrl}, $id;
1410 $vendor = $out->{'Vendor ID'};
1411 $product = $out->{'Product ID'};
1412 $capacity = $out->{'Capacity'};
1413 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1416 next PDISK if blacklisted('pdisk', $nexus);
1419 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1420 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1422 # Calculate human readable capacity
1423 $capacity = ceil($capacity / 1000**3) >= 1000
1424 ? sprintf '%.1fTB', ($capacity / 1000**4)
1425 : sprintf '%.0fGB', ($capacity / 1000**3);
1426 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1427 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1428 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1430 # Capitalize only the first letter of the vendor name
1431 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1433 # Remove unnecessary trademark rubbish from vendor name
1434 $vendor =~ s{\(tm\)\z}{}xms;
1436 # Special case: Failure predicted
1438 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1439 $name, $vendor, $product, $capacity, $ctrl;
1440 $msg .= " ($state)" if $state ne 'Predictive failure';
1441 report('storage', $msg,
1442 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1444 # Special case: Rebuilding / Replacing
1445 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1446 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1447 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1448 report('storage', $msg, $E_WARNING, $nexus);
1451 elsif ($status ne 'Ok') {
1452 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1453 $name, $vendor, $product, $capacity, $ctrl, $state;
1454 report('storage', $msg, $status2nagios{$status}, $nexus);
1458 my $msg = sprintf '%s [%s] on ctrl %d is %s',
1459 $name, $capacity, $ctrl, $state;
1460 report('storage', $msg, $E_OK, $nexus);
1467 #-----------------------------------------
1468 # STORAGE: Check logical drives
1469 #-----------------------------------------
1470 sub check_virtual_disks {
1471 return if $#controllers == -1;
1472 return if blacklisted('vdisk', 'all');
1489 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1490 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1491 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1492 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1493 '1.3.6.1.4.1.674.10893.1.20.140.1.1.17' => 'virtualDiskTargetID',
1494 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1495 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1498 if ($opt{use_get_table}) {
1499 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1500 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1503 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1506 # No logical drives is OK
1507 return if !defined $result;
1509 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1512 foreach my $c (@controllers) {
1513 push @output, @{ run_omreport("storage vdisk controller=$c") };
1514 map_item('ctrl', $c, \@output);
1527 16 => 'Regenerating',
1530 32 => 'Reconstructing',
1531 35 => 'Initializing',
1532 36 => 'Background Initialization',
1533 38 => 'Resynching Paused',
1534 52 => 'Permanently Degraded',
1535 54 => 'Degraded Redundancy',
1540 1 => 'Concatenated',
1547 19 => 'Concatenated RAID-1',
1551 # Check virtual disks on each of the controllers
1553 foreach my $out (@output) {
1555 $id = $out->{virtualDiskTargetID};
1556 $dev = $out->{virtualDiskDeviceName};
1557 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state);
1558 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout);
1559 $status = $snmp_status{$out->{virtualDiskComponentStatus}};
1560 $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
1561 $progr = q{}; # can't get this from SNMP(?)
1562 $nexus = convert_nexus($out->{virtualDiskNexusID});
1563 $ctrl = $nexus; # We use the nexus id to get the controller id
1564 $ctrl =~ s{\A (\d+):\d+ \z}{$1}xms;
1568 $dev = $out->{'Device Name'};
1569 $state = $out->{State};
1570 $status = $out->{Status};
1571 $layout = $out->{Layout};
1572 $size = $out->{Size};
1573 $progr = ' [' . $out->{Progress} . ']';
1574 $size =~ s{\A (.*GB).* \z}{$1}xms;
1575 $nexus = join q{:}, $out->{ctrl}, $id;
1576 $ctrl = $out->{ctrl};
1579 next VDISK if blacklisted('vdisk', $nexus);
1582 # The device name is undefined sometimes
1583 $dev = q{} if !defined $dev;
1585 # Special case: Regenerating
1586 if ($state eq 'Regenerating') {
1587 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s%s},
1588 $id, $dev, $layout, $size, $ctrl, $state, $progr;
1589 report('storage', $msg, $E_WARNING, $nexus);
1592 elsif ($status ne 'Ok') {
1593 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d needs attention: %s},
1594 $id, $dev, $layout, $size, $ctrl, $state;
1595 report('storage', $msg, $status2nagios{$status}, $nexus);
1599 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s},
1600 $id, $dev, $layout, $size, $ctrl, $state;
1601 report('storage', $msg, $E_OK, $nexus);
1608 #-----------------------------------------
1609 # STORAGE: Check cache batteries
1610 #-----------------------------------------
1611 sub check_cache_battery {
1612 return if $#controllers == -1;
1613 return if blacklisted('bat', 'all');
1620 my $learn = undef; # learn state
1621 my $pred = undef; # battery's ability to be charged
1627 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1628 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1629 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1630 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1631 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1632 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1635 if ($opt{use_get_table}) {
1636 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1637 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1639 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1640 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1642 if (defined $result) {
1643 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1647 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1650 # No cache battery is OK
1651 return if !defined $result;
1653 @output = @{ get_snmp_output($result, \%bat_oid) };
1656 foreach my $c (@controllers) {
1657 push @output, @{ run_omreport("storage battery controller=$c") };
1658 map_item('ctrl', $c, \@output);
1668 7 => 'Reconditioning',
1676 # Specifies the learn state activity of the battery
1686 # This property displays the battery's ability to be charged
1689 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1690 2 => 'Ready', # The battery can be charged to full capacity
1691 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1692 # battery cannot be determined until the Learn cycle is complete
1695 # Check battery on each of the controllers
1697 foreach my $out (@output) {
1699 $status = $snmp_status{$out->{batteryComponentStatus}};
1700 $state = get_hashval($out->{batteryState}, \%bat_state);
1701 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state);
1702 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap);
1703 $ctrl = $out->{batteryConnectionControllerNumber} - 1;
1704 $nexus = convert_nexus($out->{batteryNexusID});
1706 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1710 $state = $out->{'State'};
1711 $status = $out->{'Status'};
1712 $learn = $out->{'Learn State'};
1713 $pred = $out->{'Predicted Capacity Status'};
1714 $ctrl = $out->{'ctrl'};
1715 $nexus = join q{:}, $out->{ctrl}, $id;
1718 next BATTERY if blacklisted('bat', $nexus);
1720 # Special case: Charging
1721 if ($state eq 'Charging') {
1722 if ($pred eq 'Failed') {
1723 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [replace battery]',
1724 $id, $ctrl, $state, $pred;
1725 report('storage', $msg, $E_CRITICAL, $nexus);
1728 next BATTERY if blacklisted('bat_charge', $nexus);
1729 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1730 $id, $ctrl, $state, $pred;
1731 report('storage', $msg, $E_WARNING, $nexus);
1734 # Special case: Learning (battery learns its capacity)
1735 elsif ($state eq 'Learning') {
1736 if ($learn eq 'Failed') {
1737 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s)',
1738 $id, $ctrl, $state, $learn;
1739 report('storage', $msg, $E_CRITICAL, $nexus);
1742 next BATTERY if blacklisted('bat_charge', $nexus);
1743 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1744 $id, $ctrl, $state, $learn;
1745 report('storage', $msg, $E_WARNING, $nexus);
1748 # Special case: Power Low (first part of recharge cycle)
1749 elsif ($state eq 'Power Low') {
1750 next BATTERY if blacklisted('bat_charge', $nexus);
1751 my $msg = sprintf 'Cache battery %d in controller %d is %s [probably harmless]',
1753 report('storage', $msg, $E_WARNING, $nexus);
1755 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1756 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1757 next BATTERY if blacklisted('bat_charge', $nexus);
1758 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1759 $id, $ctrl, $state, $status;
1760 report('storage', $msg, $E_WARNING, $nexus);
1763 elsif ($status ne 'Ok') {
1764 my $msg = sprintf 'Cache battery %d in controller %d needs attention: %s (%s)',
1765 $id, $ctrl, $state, $status;
1766 report('storage', $msg, $status2nagios{$status}, $nexus);
1770 my $msg = sprintf 'Cache battery %d in controller %d is %s',
1772 report('storage', $msg, $E_OK, $nexus);
1779 #-----------------------------------------
1780 # STORAGE: Check connectors (channels)
1781 #-----------------------------------------
1782 sub check_connectors {
1783 return if $#controllers == -1;
1784 return if blacklisted('conn', 'all');
1798 '1.3.6.1.4.1.674.10893.1.20.130.2.1.1' => 'channelNumber',
1799 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1800 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1801 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1802 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1803 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1806 if ($opt{use_get_table}) {
1807 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1808 $result = $snmp_session->get_table(-baseoid => $channelTable);
1811 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1814 if (!defined $result) {
1815 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1816 $snmp_session->close;
1820 @output = @{ get_snmp_output($result, \%conn_oid) };
1823 foreach my $c (@controllers) {
1824 push @output, @{ run_omreport("storage connector controller=$c") };
1825 map_item('ctrl', $c, \@output);
1843 3 => 'Fibre Channel',
1850 # Check connectors on each of the controllers
1852 foreach my $out (@output) {
1854 $id = $out->{channelNumber} - 1;
1855 $name = $out->{channelName};
1856 $status = $snmp_status{$out->{channelComponentStatus}};
1857 $state = get_hashval($out->{channelState}, \%conn_state);
1858 $type = get_hashval($out->{channelBusType}, \%conn_bustype);
1859 $nexus = convert_nexus($out->{channelNexusID});
1861 $ctrl =~ s{(\d+):\d+}{$1}xms;
1865 $name = $out->{'Name'};
1866 $state = $out->{'State'};
1867 $status = $out->{'Status'};
1868 $type = $out->{'Connector Type'};
1869 $ctrl = $out->{ctrl};
1870 $nexus = join q{:}, $out->{ctrl}, $id;
1873 next CHANNEL if blacklisted('conn', $nexus);
1875 my $msg = sprintf '%s [%s] on controller %d is %s',
1876 $name, $type, $ctrl, $state;
1877 report('storage', $msg, $status2nagios{$status}, $nexus);
1883 #-----------------------------------------
1884 # STORAGE: Check enclosures
1885 #-----------------------------------------
1886 sub check_enclosures {
1887 return if blacklisted('encl', 'all');
1894 my $firmware = undef;
1901 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
1902 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
1903 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
1904 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
1905 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
1906 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
1907 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
1910 if ($opt{use_get_table}) {
1911 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
1912 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
1915 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
1918 # No enclosures is OK
1919 return if !defined $result;
1921 @output = @{ get_snmp_output($result, \%encl_oid) };
1924 foreach my $c (@controllers) {
1925 push @output, @{ run_omreport("storage enclosure controller=$c") };
1926 map_item('ctrl', $c, \@output);
1941 foreach my $out (@output) {
1943 $id = $out->{enclosureNumber} - 1;
1944 $name = $out->{enclosureName};
1945 $state = get_hashval($out->{enclosureState}, \%encl_state);
1946 $status = $snmp_status{$out->{enclosureComponentStatus}};
1947 $firmware = exists $out->{enclosureFirmwareVersion}
1948 ? $out->{enclosureFirmwareVersion} : 'N/A';
1949 $nexus = convert_nexus($out->{enclosureNexusID});
1951 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
1955 $name = $out->{Name};
1956 $state = $out->{State};
1957 $status = $out->{Status};
1958 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1959 ? $out->{'Firmware Version'} : 'N/A';
1960 $nexus = join q{:}, $out->{ctrl}, $id;
1961 $ctrl = $out->{ctrl};
1964 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1965 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
1967 # store enclosure data for future use
1968 push @enclosures, { 'id' => $id,
1969 'ctrl' => $out->{ctrl},
1972 # Collecting some storage info
1973 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
1974 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
1975 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
1977 next ENCLOSURE if blacklisted('encl', $nexus);
1979 my $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
1980 $nexus, $name, $ctrl, $state;
1981 report('storage', $msg, $status2nagios{$status}, $nexus);
1987 #-----------------------------------------
1988 # STORAGE: Check enclosure fans
1989 #-----------------------------------------
1990 sub check_enclosure_fans {
1991 return if $#controllers == -1;
1992 return if blacklisted('encl_fan', 'all');
2000 my $encl_id = undef;
2001 my $encl_name = undef;
2007 '1.3.6.1.4.1.674.10893.1.20.130.7.1.1' => 'fanNumber',
2008 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2009 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2010 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2011 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2012 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2013 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2014 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2017 if ($opt{use_get_table}) {
2018 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2019 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2021 $result = $snmp_session->get_table(-baseoid => $fanTable);
2022 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2024 if (defined $result) {
2025 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2029 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2032 # No enclosure fans is OK
2033 return if !defined $result;
2035 @output = @{ get_snmp_output($result, \%fan_oid) };
2038 foreach my $enc (@enclosures) {
2039 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2040 map_item('ctrl', $enc->{ctrl}, \@output);
2041 map_item('encl_id', $enc->{id}, \@output);
2042 map_item('encl_name', $enc->{name}, \@output);
2057 # Check fans on each of the enclosures
2059 foreach my $out (@output) {
2061 $id = $out->{fanNumber} - 1;
2062 $name = $out->{fanName};
2063 $state = get_hashval($out->{fanState}, \%fan_state);
2064 $status = $snmp_status{$out->{fanComponentStatus}};
2065 $speed = $out->{fanProbeCurrValue};
2066 $encl_id = $out->{fanConnectionEnclosureNumber} - 1;
2067 $encl_name = $out->{fanConnectionEnclosureName};
2068 $nexus = convert_nexus($out->{fanNexusID});
2072 $name = $out->{'Name'};
2073 $state = $out->{'State'};
2074 $status = $out->{'Status'};
2075 $speed = $out->{'Speed'};
2076 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2077 $encl_name = $out->{encl_name};
2078 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2081 next FAN if blacklisted('encl_fan', $nexus);
2084 if ($status ne 'Ok') {
2085 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2086 $name, $encl_id, $encl_name, $state;
2087 report('storage', $msg, $status2nagios{$status}, $nexus);
2091 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2092 $name, $encl_id, $encl_name, $state, $speed;
2093 report('storage', $msg, $E_OK, $nexus);
2100 #-----------------------------------------
2101 # STORAGE: Check enclosure power supplies
2102 #-----------------------------------------
2103 sub check_enclosure_pwr {
2104 return if $#controllers == -1;
2105 return if blacklisted('encl_ps', 'all');
2112 my $encl_id = undef;
2113 my $encl_name = undef;
2119 '1.3.6.1.4.1.674.10893.1.20.130.9.1.1' => 'powerSupplyNumber',
2120 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2121 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2122 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2123 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2124 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2125 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2128 if ($opt{use_get_table}) {
2129 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2130 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2132 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2133 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2135 if (defined $result) {
2136 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2140 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2143 # No enclosure power supplies is OK
2144 return if !defined $result;
2146 @output = @{ get_snmp_output($result, \%ps_oid) };
2149 foreach my $enc (@enclosures) {
2150 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2151 map_item('ctrl', $enc->{ctrl}, \@output);
2152 map_item('encl_id', $enc->{id}, \@output);
2153 map_item('encl_name', $enc->{name}, \@output);
2162 5 => 'Not Installed',
2168 # Check power supplies on each of the enclosures
2170 foreach my $out (@output) {
2172 $id = $out->{powerSupplyNumber};
2173 $name = $out->{powerSupplyName};
2174 $state = get_hashval($out->{powerSupplyState}, \%ps_state);
2175 $status = $snmp_status{$out->{powerSupplyComponentStatus}};
2176 $encl_id = $out->{powerSupplyConnectionEnclosureNumber} - 1;
2177 $encl_name = $out->{powerSupplyConnectionEnclosureName};
2178 $nexus = convert_nexus($out->{powerSupplyNexusID});
2182 $name = $out->{'Name'};
2183 $state = $out->{'State'};
2184 $status = $out->{'Status'};
2185 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2186 $encl_name = $out->{encl_name};
2187 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2190 next PS if blacklisted('encl_ps', $nexus);
2193 if ($status ne 'Ok') {
2194 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2195 $name, $encl_id, $encl_name, $state;
2196 report('storage', $msg, $status2nagios{$status}, $nexus);
2200 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2201 $name, $encl_id, $encl_name, $state;
2202 report('storage', $msg, $E_OK, $nexus);
2209 #-----------------------------------------
2210 # STORAGE: Check enclosure temperatures
2211 #-----------------------------------------
2212 sub check_enclosure_temp {
2213 return if $#controllers == -1;
2214 return if blacklisted('encl_temp', 'all');
2221 my $reading = undef;
2223 my $max_warn = undef;
2224 my $max_crit = undef;
2225 my $encl_id = undef;
2226 my $encl_name = undef;
2232 '1.3.6.1.4.1.674.10893.1.20.130.11.1.1' => 'temperatureProbeNumber',
2233 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2234 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2235 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2236 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2237 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2238 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2239 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2240 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2241 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2242 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2245 if ($opt{use_get_table}) {
2246 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2247 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2249 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2250 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2252 if (defined $result) {
2253 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2257 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2260 # No enclosure temperature probes is OK
2261 return if !defined $result;
2263 @output = @{ get_snmp_output($result, \%temp_oid) };
2266 foreach my $enc (@enclosures) {
2267 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2268 map_item('ctrl', $enc->{ctrl}, \@output);
2269 map_item('encl_id', $enc->{id}, \@output);
2270 map_item('encl_name', $enc->{name}, \@output);
2285 # Check temperature probes on each of the enclosures
2287 foreach my $out (@output) {
2289 $id = $out->{temperatureProbeNumber} - 1;
2290 $name = $out->{temperatureProbeName};
2291 $state = get_hashval($out->{temperatureProbeState}, \%temp_state);
2292 $status = $snmp_status{$out->{temperatureProbeComponentStatus}};
2293 $unit = $out->{temperatureProbeUnit};
2294 $reading = $out->{temperatureProbeCurValue};
2295 $max_warn = $out->{temperatureProbeMaxWarning};
2296 $max_crit = $out->{temperatureProbeMaxCritical};
2297 $encl_id = $out->{temperatureConnectionEnclosureNumber} - 1;
2298 $encl_name = $out->{temperatureConnectionEnclosureName};
2299 $nexus = convert_nexus($out->{temperatureProbeNexusID});
2303 $name = $out->{'Name'};
2304 $state = $out->{'State'};
2305 $status = $out->{'Status'};
2307 $reading = $out->{'Reading'}; $reading =~ s{\s*C}{}xms;
2308 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\s*C}{}xms;
2309 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\s*C}{}xms;
2310 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2311 $encl_name = $out->{encl_name};
2312 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2315 next TEMP if blacklisted('encl_temp', $nexus);
2318 if ($status ne 'Ok') {
2319 my $msg = sprintf '%s in enclosure %s [%s] is %s C at %s (%s max)',
2320 $name, $encl_id, $encl_name, $state, $reading, $max_crit;
2321 report('storage', $msg, $status2nagios{$status}, $nexus);
2325 my $msg = sprintf '%s in enclosure %s [%s]: %s C (%s max)',
2326 $name, $encl_id, $encl_name, $reading, $max_crit;
2327 report('storage', $msg, $E_OK, $nexus);
2330 # Collect performance data
2331 if (defined $opt{perfdata}) {
2332 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2333 my $pkey = "enclosure_${encl_id}_${name}";
2334 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2335 $perfdata{$pkey} = $pval;
2342 #-----------------------------------------
2343 # STORAGE: Check enclosure management modules (EMM)
2344 #-----------------------------------------
2345 sub check_enclosure_emms {
2346 return if $#controllers == -1;
2347 return if blacklisted('encl_emm', 'all');
2354 my $encl_id = undef;
2355 my $encl_name = undef;
2361 '1.3.6.1.4.1.674.10893.1.20.130.13.1.1' => 'enclosureManagementModuleNumber',
2362 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2363 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2364 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2365 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2366 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2367 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2370 if ($opt{use_get_table}) {
2371 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2372 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2374 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2375 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2377 if (defined $result) {
2378 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2382 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2385 # No enclosure EMMs is OK
2386 return if !defined $result;
2388 @output = @{ get_snmp_output($result, \%emms_oid) };
2391 foreach my $enc (@enclosures) {
2392 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2393 map_item('ctrl', $enc->{ctrl}, \@output);
2394 map_item('encl_id', $enc->{id}, \@output);
2395 map_item('encl_name', $enc->{name}, \@output);
2406 5 => 'Not Installed',
2411 # Check temperature probes on each of the enclosures
2413 foreach my $out (@output) {
2415 $id = $out->{enclosureManagementModuleNumber} - 1;
2416 $name = $out->{enclosureManagementModuleName};
2417 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state);
2418 $status = $snmp_status{$out->{enclosureManagementModuleComponentStatus}};
2419 $encl_id = $out->{enclosureManagementModuleConnectionEnclosureNumber} - 1;
2420 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
2421 $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
2425 $name = $out->{'Name'};
2426 $state = $out->{'State'};
2427 $status = $out->{'Status'};
2428 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2429 $encl_name = $out->{encl_name};
2430 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2433 next EMM if blacklisted('encl_emm', $nexus);
2436 if ($status ne 'Ok') {
2437 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2438 $name, $encl_id, $encl_name, $state;
2439 report('storage', $msg, $status2nagios{$status}, $nexus);
2443 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2444 $name, $encl_id, $encl_name, $state;
2445 report('storage', $msg, $E_OK, $nexus);
2452 #-----------------------------------------
2453 # CHASSIS: Check memory modules
2454 #-----------------------------------------
2456 return if blacklisted('dimm', 'all');
2460 my $location = undef;
2469 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2470 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2471 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2472 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2473 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2476 if ($opt{use_get_table}) {
2477 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2478 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2481 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2484 if (!defined $result) {
2485 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2486 $snmp_session->close;
2490 @output = @{ get_snmp_output($result, \%dimm_oid) };
2493 @output = @{ run_omreport("$omopt_chassis memory") };
2496 # Note: These values are bit masks, so combination values are
2497 # possible. If value is 0 (zero), memory device has no faults.
2500 1 => 'ECC single bit correction warning rate exceeded',
2501 2 => 'ECC single bit correction failure rate exceeded',
2502 4 => 'ECC multibit fault encountered',
2503 8 => 'ECC single bit correction logging disabled',
2504 16 => 'device disabled because of spare activation',
2508 foreach my $out (@output) {
2509 @failures = (); # Initialize
2511 $index = $out->{memoryDeviceIndex};
2512 $status = $snmp_status{$out->{memoryDeviceStatus}};
2513 $location = $out->{memoryDeviceLocationName};
2514 $size = sprintf '%d MB', $out->{memoryDeviceSize}/1024;
2515 $modes = $out->{memoryDeviceFailureModes};
2517 foreach my $mask (sort keys %failure_mode) {
2518 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2523 $index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
2524 $status = $out->{'Status'};
2525 $location = $out->{'Connector Name'};
2526 $size = $out->{'Size'};
2527 if (defined $size) {
2528 $size =~ s{\s\s}{ }gxms;
2530 # Run 'omreport chassis memory index=X' to get the failures
2531 if ($status ne 'Ok' && defined $index) {
2532 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2533 if (m/\A Failures; (.+?) \z/xms) {
2534 chop(my $fail = $1);
2535 push @failures, split m{\.}xms, $fail;
2540 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2542 next DIMM if blacklisted('dimm', $index);
2544 # Ignore empty memory slots
2545 next DIMM if !defined $index;
2548 if ($status ne 'Ok') {
2550 if (scalar @failures == 0) {
2551 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2552 $index, $location, $size, $status;
2555 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2556 $index, $location, $size, (join q{, }, @failures);
2559 report('chassis', $msg, $status2nagios{$status}, $index);
2563 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2564 $index, $location, $size, $status;
2565 report('chassis', $msg, $E_OK, $index);
2572 #-----------------------------------------
2573 # CHASSIS: Check fans
2574 #-----------------------------------------
2576 return if blacklisted('fan', 'all');
2580 my $reading = undef;
2581 my $location = undef;
2582 my $max_crit = undef;
2583 my $max_warn = undef;
2589 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2590 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2591 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2592 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2593 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2594 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2597 if ($opt{use_get_table}) {
2598 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2599 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2602 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2605 if ($blade && !defined $result) {
2608 elsif (!$blade && !defined $result) {
2609 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2610 $snmp_session->close;
2614 @output = @{ get_snmp_output($result, \%cool_oid) };
2617 @output = @{ run_omreport("$omopt_chassis fans") };
2621 foreach my $out (@output) {
2623 $index = $out->{coolingDeviceIndex};
2624 $status = $snmp_probestatus{$out->{coolingDeviceStatus}};
2625 $reading = $out->{coolingDeviceReading};
2626 $location = $out->{coolingDeviceLocationName};
2627 $max_crit = exists $out->{coolingDeviceUpperCriticalThreshold}
2628 ? $out->{coolingDeviceUpperCriticalThreshold} : 0;
2629 $max_warn = exists $out->{coolingDeviceUpperNonCriticalThreshold}
2630 ? $out->{coolingDeviceUpperNonCriticalThreshold} : 0;
2633 $index = $out->{'Index'};
2634 $status = $out->{'Status'};
2635 $reading = $out->{'Reading'};
2636 $location = $out->{'Probe Name'};
2637 $max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
2638 ? $out->{'Maximum Failure Threshold'} : 0;
2639 $max_warn = $out->{'Maximum Warning Threshold'} ne '[N/A]'
2640 ? $out->{'Maximum Warning Threshold'} : 0;
2641 $reading =~ s{\A (\d+).* \z}{$1}xms;
2642 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2643 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2646 next FAN if blacklisted('fan', $index);
2649 if ($status ne 'Ok') {
2650 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2651 $index, $location, $status;
2652 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2653 report('chassis', $msg, $err, $index);
2656 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2657 $index, $location, $reading;
2658 report('chassis', $msg, $E_OK, $index);
2661 # Collect performance data
2662 if (defined $opt{perfdata}) {
2663 my $pname = lc $location;
2664 $pname =~ s{\s}{_}gxms;
2665 $pname =~ s{proc_}{cpu#}xms;
2666 my $pkey = join q{_}, 'fan', $index, $pname;
2667 my $pval = join q{;}, "${reading}RPM", $max_warn, $max_crit;
2668 $perfdata{$pkey} = $pval;
2675 #-----------------------------------------
2676 # CHASSIS: Check power supplies
2677 #-----------------------------------------
2678 sub check_powersupplies {
2679 return if blacklisted('ps', 'all');
2684 my $err_type = undef;
2692 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2693 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2694 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2695 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2696 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2699 if ($opt{use_get_table}) {
2700 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2701 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2704 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2707 # No instrumented PSU is OK (blades, low-end servers)
2708 return 0 if !defined $result;
2710 @output = @{ get_snmp_output($result, \%ps_oid) };
2713 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2723 6 => 'Uninterruptible Power Supply',
2733 1 => 'Presence detected',
2734 2 => 'Failure detected',
2735 4 => 'Predictive Failure',
2737 16 => 'AC lost or out-of-range',
2738 32 => 'AC out-of-range but present',
2739 64 => 'Configuration error',
2742 my %ps_config_error_type
2744 1 => 'Vendor mismatch',
2745 2 => 'Revision mismatch',
2746 3 => 'Processor missing',
2750 foreach my $out (@output) {
2752 @states = (); # contains states for the PS
2754 $index = $out->{powerSupplyIndex} - 1;
2755 $status = $snmp_status{$out->{powerSupplyStatus}};
2756 $type = get_hashval($out->{powerSupplyType}, \%ps_type);
2757 $err_type = defined $out->{powerSupplyConfigurationErrorType}
2758 ? $ps_config_error_type{$out->{powerSupplyConfigurationErrorType}} : undef;
2760 # get the combined state from the StatusReading OID
2761 foreach my $mask (sort keys %ps_state) {
2762 if (($out->{powerSupplySensorState} & $mask) != 0) {
2763 push @states, $ps_state{$mask};
2767 # If configuration error, also include the error type
2768 if (defined $err_type) {
2769 push @states, $err_type;
2772 # Finally, construct the state string
2773 $state = join q{, }, @states;
2776 $index = $out->{'Index'};
2777 $status = $out->{'Status'};
2778 $type = $out->{'Type'};
2779 $state = $out->{'Online Status'};
2782 next PS if blacklisted('ps', $index);
2785 if ($status ne 'Ok') {
2786 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2787 $index, $type, $state;
2788 report('chassis', $msg, $status2nagios{$status}, $index);
2791 my $msg = sprintf 'Power Supply %d [%s]: %s',
2792 $index, $type, $state;
2793 report('chassis', $msg, $E_OK, $index);
2800 #-----------------------------------------
2801 # CHASSIS: Check temperatures
2802 #-----------------------------------------
2803 sub check_temperatures {
2804 return if blacklisted('temp', 'all');
2808 my $reading = undef;
2809 my $location = undef;
2810 my $max_crit = undef;
2811 my $max_warn = undef;
2812 my $min_warn = undef;
2813 my $min_crit = undef;
2815 my $discrete = undef;
2818 # Getting custom temperature thresholds (user option)
2819 my %warn_threshold = %{ custom_temperature_thresholds('w') };
2820 my %crit_threshold = %{ custom_temperature_thresholds('c') };
2825 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
2826 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
2827 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
2828 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
2829 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
2830 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
2831 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
2832 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
2833 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
2834 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
2836 # this didn't work well for some reason
2837 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2839 # Getting values using the table
2840 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
2841 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2843 if (!defined $result) {
2844 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
2845 $snmp_session->close;
2849 @output = @{ get_snmp_output($result, \%temp_oid) };
2852 @output = @{ run_omreport("$omopt_chassis temps") };
2857 1 => 'Other', # type is other than following values
2858 2 => 'Unknown', # type is unknown
2859 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
2860 16 => 'Discrete', # type is temperature probe with discrete reading
2864 foreach my $out (@output) {
2866 $index = $out->{temperatureProbeIndex} - 1;
2867 $status = $snmp_probestatus{$out->{temperatureProbeStatus}};
2868 $reading = $out->{temperatureProbeReading} / 10;
2869 $location = $out->{temperatureProbeLocationName};
2870 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} / 10;
2871 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} / 10;
2872 $min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
2873 ? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
2874 $min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
2875 ? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
2876 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
2877 $discrete = exists $out->{temperatureProbeDiscreteReading}
2878 ? $out->{temperatureProbeDiscreteReading} : undef;
2881 $index = $out->{'Index'};
2882 $status = $out->{'Status'};
2883 $reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
2884 $location = $out->{'Probe Name'};
2885 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
2886 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\.0\s+C}{}xms;
2887 $min_crit = $out->{'Minimum Failure Threshold'}; $min_crit =~ s{\.0\s+C}{}xms;
2888 $min_warn = $out->{'Minimum Warning Threshold'}; $min_warn =~ s{\.0\s+C}{}xms;
2889 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
2890 $discrete = $reading;
2893 next TEMP if blacklisted('temp', $index);
2896 if ($type eq 'Discrete') {
2897 my $msg = sprintf 'Temperature probe %d (%s): is %s',
2898 $index, $location, $discrete;
2899 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2900 report('chassis', $msg, $err, $index);
2903 # First check according to custom thresholds
2904 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
2905 # Custom critical MAX
2906 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2907 $index, $location, $reading, $crit_threshold{$index}{max};
2908 report('chassis', $msg, $E_CRITICAL, $index);
2910 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
2911 # Custom warning MAX
2912 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2913 $index, $location, $reading, $warn_threshold{$index}{max};
2914 report('chassis', $msg, $E_WARNING, $index);
2916 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
2917 # Custom critical MIN
2918 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2919 $index, $location, $reading, $crit_threshold{$index}{min};
2920 report('chassis', $msg, $E_CRITICAL, $index);
2922 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
2923 # Custom warning MIN
2924 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2925 $index, $location, $reading, $warn_threshold{$index}{min};
2926 report('chassis', $msg, $E_WARNING, $index);
2928 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2929 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
2930 $index, $location, $reading;
2931 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2932 report('chassis', $msg, $err, $index);
2934 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2935 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
2936 $index, $location, $reading;
2937 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2938 report('chassis', $msg, $err, $index);
2940 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2941 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
2942 $index, $location, $reading;
2943 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2944 report('chassis', $msg, $err, $index);
2946 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2947 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
2948 $index, $location, $reading;
2949 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2950 report('chassis', $msg, $err, $index);
2954 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
2955 $index, $location, $reading;
2956 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
2957 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2960 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2961 $min_warn, $min_crit, $max_warn, $max_crit;
2963 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2964 report('chassis', $msg, $err, $index);
2967 # Collect performance data
2968 if (defined $opt{perfdata}) {
2969 my $pname = lc $location;
2970 $pname =~ s{\s}{_}gxms;
2971 $pname =~ s{_temp\z}{}xms;
2972 $pname =~ s{proc_}{cpu#}xms;
2973 my $pkey = join q{_}, 'temp', $index, $pname;
2974 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2975 $perfdata{$pkey} = $pval;
2983 #-----------------------------------------
2984 # CHASSIS: Check processors
2985 #-----------------------------------------
2986 sub check_processors {
2987 return if blacklisted('cpu', 'all');
3000 # NOTE: For some reason, older models don't have the
3001 # "Processor Device Status" OIDs. We check both the newer
3002 # (preferred) OIDs and the old ones.
3006 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3007 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3008 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3009 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3010 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3011 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3012 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3013 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3014 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3015 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3018 if ($opt{use_get_table}) {
3019 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3020 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3022 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3023 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3025 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3028 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3031 if (!defined $result) {
3032 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3033 $snmp_session->close;
3037 @output = @{ get_snmp_output($result, \%cpu_oid) };
3040 @output = @{ run_omreport("$omopt_chassis processors") };
3045 1 => 'Other', # other than following values
3046 2 => 'Unknown', # unknown
3047 3 => 'Enabled', # enabled
3048 4 => 'User Disabled', # disabled by user via BIOS setup
3049 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3055 1 => 'Internal Error', # Internal Error
3056 2 => 'Thermal Trip', # Thermal Trip
3057 32 => 'Configuration Error', # Configuration Error
3058 128 => 'Present', # Processor Present
3059 256 => 'Disabled', # Processor Disabled
3060 512 => 'Terminator Present', # Terminator Present
3061 1024 => 'Throttled', # Processor Throttled
3064 # Mapping between family numbers from SNMP and actual CPU family
3067 1 => 'Other', 2 => 'Unknown',
3068 3 => '8086', 4 => '80286',
3069 5 => '386', 6 => '486',
3070 7 => '8087', 8 => '80287',
3071 9 => '80387', 10 => '80487',
3072 11 => 'Pentium', 12 => 'Pentium Pro',
3073 13 => 'Pentium II', 14 => 'Pentium with MMX',
3074 15 => 'Celeron', 16 => 'Pentium II Xeon',
3075 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3076 19 => 'Pentium III', 20 => 'Itanium',
3077 21 => 'Xeon', 22 => 'Pentium 4',
3078 23 => 'Xeon MP', 24 => 'Itanium 2',
3079 25 => 'K5', 26 => 'K6',
3080 27 => 'K6-2', 28 => 'K6-3',
3081 29 => 'Athlon', 30 => 'AMD2900',
3082 31 => 'K6-2+', 32 => 'Power PC',
3083 33 => 'Power PC 601', 34 => 'Power PC 603',
3084 35 => 'Power PC 603+', 36 => 'Power PC 604',
3085 37 => 'Power PC 620', 38 => 'Power PC x704',
3086 39 => 'Power PC 750', 40 => 'Core Duo',
3087 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3088 43 => 'Intel Atom', 44 => undef,
3089 45 => undef, 46 => undef,
3090 47 => undef, 48 => 'Alpha',
3091 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3092 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3093 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3094 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3095 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3096 59 => 'Opteron 6100', 60 => undef,
3097 61 => undef, 62 => undef,
3098 63 => undef, 64 => 'MIPS',
3099 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3100 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3101 69 => 'MIPS R10000', 70 => undef,
3102 71 => undef, 72 => undef,
3103 73 => undef, 74 => undef,
3104 75 => undef, 76 => undef,
3105 77 => undef, 78 => undef,
3106 79 => undef, 80 => 'SPARC',
3107 81 => 'SuperSPARC', 82 => 'microSPARC II',
3108 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3109 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3110 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3111 89 => undef, 90 => undef,
3112 91 => undef, 92 => undef,
3113 93 => undef, 94 => undef,
3114 95 => undef, 96 => '68040',
3115 97 => '68xxx', 98 => '68000',
3116 99 => '68010', 100 => '68020',
3117 101 => '68030', 102 => undef,
3118 103 => undef, 104 => undef,
3119 105 => undef, 106 => undef,
3120 107 => undef, 108 => undef,
3121 109 => undef, 110 => undef,
3122 111 => undef, 112 => 'Hobbit',
3123 113 => undef, 114 => undef,
3124 115 => undef, 116 => undef,
3125 117 => undef, 118 => undef,
3126 119 => undef, 120 => 'Crusoe TM5000',
3127 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3128 123 => undef, 124 => undef,
3129 125 => undef, 126 => undef,
3130 127 => undef, 128 => 'Weitek',
3131 129 => undef, 130 => 'Celeron M',
3132 131 => 'Athlon 64', 132 => 'Opteron',
3133 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3134 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3135 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3136 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3137 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3138 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3139 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3140 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3141 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3142 151 => undef, 152 => undef,
3143 153 => undef, 154 => undef,
3144 155 => undef, 156 => undef,
3145 157 => undef, 158 => undef,
3146 159 => undef, 160 => 'V30',
3147 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3148 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3149 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3150 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3151 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3152 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3153 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3154 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3155 177 => 'M2', 178 => undef,
3156 179 => 'Pentium 4 HT', 180 => 'AS400',
3157 181 => undef, 182 => 'Athlon XP',
3158 183 => 'Athlon MP', 184 => 'Duron',
3159 185 => 'Pentium M', 186 => 'Celeron D',
3160 187 => 'Pentium D', 188 => 'Pentium Extreme',
3161 189 => 'Core Solo', 190 => 'Core2',
3162 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3163 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3164 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3165 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3166 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3167 201 => 'G4', 202 => 'G5',
3168 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3169 205 => 'Core i5', 206 => undef,
3170 207 => undef, 208 => undef,
3171 209 => undef, 210 => 'C7-M',
3172 211 => 'C7-D', 212 => 'C7',
3173 213 => 'Eden', 214 => 'Multi-Core Xeon',
3174 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3175 217 => undef, 218 => 'Dual-Core Xeon 5xxx',
3176 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3177 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3178 223 => 'Multi-Core Xeon 7xxx', 224 => undef,
3179 225 => undef, 226 => undef,
3180 227 => undef, 228 => undef,
3181 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3182 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3183 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3184 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3185 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3186 239 => 'AMD Sempron M', 240 => undef,
3187 241 => undef, 242 => undef,
3188 243 => undef, 244 => undef,
3189 245 => undef, 246 => undef,
3190 247 => undef, 248 => undef,
3191 249 => undef, 250 => 'i860',
3196 foreach my $out (@output) {
3198 $index = exists $out->{processorDeviceStatusIndex}
3199 ? $out->{processorDeviceStatusIndex} - 1
3200 : $out->{processorDeviceIndex} - 1;
3201 $status = exists $out->{processorDeviceStatusStatus}
3202 ? $snmp_status{$out->{processorDeviceStatusStatus}}
3203 : $snmp_status{$out->{processorDeviceStatus}};
3204 if (exists $out->{processorDeviceStatusReading}) {
3205 my @states = (); # contains states for the CPU
3207 # get the combined state from the StatusReading OID
3208 foreach my $mask (sort keys %cpu_reading) {
3209 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3210 push @states, $cpu_reading{$mask};
3214 # Finally, create the state string
3215 $state = join q{, }, @states;
3218 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state);
3220 $man = $out->{processorDeviceManufacturerName};
3221 $family = (exists $out->{processorDeviceFamily}
3222 and exists $cpu_family{$out->{processorDeviceFamily}})
3223 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3224 $speed = $out->{processorDeviceCurrentSpeed};
3225 $brand = $out->{processorDeviceBrandName};
3228 $index = $out->{'Index'};
3229 $status = $out->{'Status'};
3230 $state = $out->{'State'};
3231 $brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
3232 $family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
3233 $man = exists $out->{'Processor Manufacturer'} ? $out->{'Processor Manufacturer'} : undef;
3234 $speed = exists $out->{'Current Speed'} ? $out->{'Current Speed'} : undef;
3237 next CPU if blacklisted('cpu', $index);
3239 # Ignore unoccupied CPU slots (omreport)
3240 next CPU if (defined $out->{'Processor Manufacturer'}
3241 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3242 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3244 # Ignore unoccupied CPU slots (snmp)
3245 if ($snmp and exists $out->{processorDeviceStatusReading}
3246 and $out->{processorDeviceStatusReading} == 0) {
3252 if (defined $brand) {
3253 $brand =~ s{\s\s+}{ }gxms;
3254 $brand =~ s{\((R|tm)\)}{}gxms;
3255 $brand =~ s{\s(CPU|Processor)}{}xms;
3256 $brand =~ s{\s\@}{}xms;
3258 elsif (defined $family and defined $man and defined $speed) {
3259 $speed =~ s{\A (\d+) .*}{$1}xms;
3260 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3267 if ($status ne 'Ok') {
3268 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3269 $index, $brand, $state;
3270 report('chassis', $msg, $status2nagios{$status}, $index);
3274 my $msg = sprintf 'Processor %d [%s] is %s',
3275 $index, $brand, $state;
3276 report('chassis', $msg, $E_OK, $index);
3283 #-----------------------------------------
3284 # CHASSIS: Check voltage probes
3285 #-----------------------------------------
3287 return if blacklisted('volt', 'all');
3291 my $reading = undef;
3292 my $location = undef;
3298 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3299 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3300 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3301 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3302 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3305 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3306 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3308 if (!defined $result) {
3309 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3310 $snmp_session->close;
3314 @output = @{ get_snmp_output($result, \%volt_oid) };
3317 @output = @{ run_omreport("$omopt_chassis volts") };
3320 my %volt_discrete_reading
3327 foreach my $out (@output) {
3329 $index = $out->{voltageProbeIndex} - 1;
3330 $status = $snmp_probestatus{$out->{voltageProbeStatus}};
3331 $reading = exists $out->{voltageProbeReading}
3332 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3333 : get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading);
3334 $location = $out->{voltageProbeLocationName};
3337 $index = $out->{'Index'};
3338 $status = $out->{'Status'};
3339 $reading = $out->{'Reading'};
3340 $location = $out->{'Probe Name'};
3343 next VOLT if blacklisted('volt', $index);
3346 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3347 $index, $location, $reading;
3348 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3349 report('chassis', $msg, $err, $index);
3355 #-----------------------------------------
3356 # CHASSIS: Check batteries
3357 #-----------------------------------------
3358 sub check_batteries {
3359 return if blacklisted('bp', 'all');
3363 my $reading = undef;
3364 my $location = undef;
3370 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3371 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3372 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3373 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3376 if ($opt{use_get_table}) {
3377 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3378 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3381 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3384 # No batteries is OK
3385 return 0 if !defined $result;
3387 @output = @{ get_snmp_output($result, \%bat_oid) };
3390 @output = @{ run_omreport("$omopt_chassis batteries") };
3395 1 => 'Predictive Failure',
3397 4 => 'Presence Detected',
3401 foreach my $out (@output) {
3403 $index = $out->{batteryIndex} - 1;
3404 $status = $snmp_status{$out->{batteryStatus}};
3405 $reading = get_hashval($out->{batteryReading}, \%bat_reading);
3406 $location = $out->{batteryLocationName};
3409 $index = $out->{'Index'};
3410 $status = $out->{'Status'};
3411 $reading = $out->{'Reading'};
3412 $location = $out->{'Probe Name'};
3415 next BATTERY if blacklisted('bp', $index);
3418 my $msg = sprintf 'Battery probe %d [%s] is %s',
3419 $index, $location, $reading;
3420 report('chassis', $msg, $status2nagios{$status}, $index);
3426 #-----------------------------------------
3427 # CHASSIS: Check amperage probes (power monitoring)
3428 #-----------------------------------------
3429 sub check_pwrmonitoring {
3430 return if blacklisted('amp', 'all');
3434 my $reading = undef;
3435 my $location = undef;
3436 my $max_crit = undef;
3437 my $max_warn = undef;
3444 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3445 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3446 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3447 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3448 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3449 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3450 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3451 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3454 if ($opt{use_get_table}) {
3455 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3456 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3459 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3462 # No pwrmonitoring is OK
3463 return 0 if !defined $result;
3465 @output = @{ get_snmp_output($result, \%amp_oid) };
3468 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3471 my %amp_type # Amperage probe types
3473 1 => 'amperageProbeTypeIsOther', # other than following values
3474 2 => 'amperageProbeTypeIsUnknown', # unknown
3475 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3476 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3477 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3478 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3479 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3480 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3481 9 => 'amperageProbeTypeIsIO', # I/O probe
3482 10 => 'amperageProbeTypeIsCore', # Core probe
3483 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3484 12 => 'amperageProbeTypeIsBattery', # Battery probe
3485 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3486 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3487 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3488 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3489 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3490 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3491 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3492 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3503 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3504 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3505 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3506 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3507 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3511 foreach my $out (@output) {
3513 $index = $out->{amperageProbeIndex} - 1;
3514 $status = $snmp_status{$out->{amperageProbeStatus}};
3515 $reading = get_hashval($out->{amperageProbeType}, \%amp_type) eq 'amperageProbeTypeIsDiscrete'
3516 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3517 : $out->{amperageProbeReading};
3518 $location = $out->{amperageProbeLocationName};
3519 $max_crit = exists $out->{amperageProbeUpperCriticalThreshold}
3520 ? $out->{amperageProbeUpperCriticalThreshold} : 0;
3521 $max_warn = exists $out->{amperageProbeUpperNonCriticalThreshold}
3522 ? $out->{amperageProbeUpperNonCriticalThreshold} : 0;
3523 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3524 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3525 if ($unit eq 'hA') {
3533 $index = $out->{'Index'};
3534 next AMP if (!defined $index || $index !~ m/^\d+$/x);
3535 $status = $out->{'Status'};
3536 $reading = $out->{'Reading'};
3537 $location = $out->{'Probe Name'};
3538 $max_crit = $out->{'Failure Threshold'} ne '[N/A]'
3539 ? $out->{'Failure Threshold'} : 0;
3540 $max_warn = $out->{'Warning Threshold'} ne '[N/A]'
3541 ? $out->{'Warning Threshold'} : 0;
3542 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3544 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3545 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3548 next AMP if blacklisted('amp', $index);
3549 next AMP if $index !~ m{\A \d+ \z}xms;
3552 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3553 $index, $location, $reading, $unit, $status;
3554 report('chassis', $msg, $status2nagios{$status}, $index);
3556 # Collect performance data
3557 if (defined $opt{perfdata}) {
3558 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3559 my $pname = lc $location;
3560 $pname =~ s{\s}{_}gxms;
3561 my $pkey = join q{_}, 'pwr_mon', $index, $pname;
3562 my $pval = join q{;}, "$reading$unit", $max_warn, $max_crit;
3563 $perfdata{$pkey} = $pval;
3567 # Collect EXTRA performance data not found at first run. This is a
3569 if (defined $opt{perfdata} && !$snmp) {
3575 foreach (keys %perfdata) {
3576 if (m/\A pwr_mon_(\d+)/xms) {
3582 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3584 if ($line eq 'Location;Reading') {
3592 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s ([AW]) \z/xms) {
3596 $aname =~ s{\s}{_}gxms;
3598 # don't use an existing index
3599 while (exists $used{$index}) { ++$index; }
3601 $perfdata{"pwr_mon_${index}_${aname}"} = "$aval$aunit;0;0";
3611 #-----------------------------------------
3612 # CHASSIS: Check intrusion
3613 #-----------------------------------------
3614 sub check_intrusion {
3615 return if blacklisted('intr', 'all');
3619 my $reading = undef;
3625 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3626 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3627 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3630 if ($opt{use_get_table}) {
3631 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3632 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3635 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3638 # No intrusion is OK
3639 return 0 if !defined $result;
3641 @output = @{ get_snmp_output($result, \%int_oid) };
3644 @output = @{ run_omreport("$omopt_chassis intrusion") };
3649 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3650 2 => 'Breached', # chassis currently breached
3651 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3652 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3656 foreach my $out (@output) {
3658 $index = $out->{intrusionIndex} - 1;
3659 $status = $snmp_status{$out->{intrusionStatus}};
3660 $reading = get_hashval($out->{intrusionReading}, \%int_reading);
3663 $index = $out->{'Index'};
3664 $status = $out->{'Status'};
3665 $reading = $out->{'State'};
3668 next INTRUSION if blacklisted('intr', $index);
3671 if ($status ne 'Ok') {
3672 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3674 report('chassis', $msg, $E_WARNING, $index);
3678 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3679 $index, $status, $reading;
3680 report('chassis', $msg, $E_OK, $index);
3687 #-----------------------------------------
3688 # CHASSIS: Check alert log
3689 #-----------------------------------------
3690 sub check_alertlog {
3691 return if $snmp; # Not supported with SNMP
3693 my @output = @{ run_omreport("$omopt_system alertlog") };
3694 foreach my $out (@output) {
3695 ++$count{alert}{$out->{Severity}};
3698 # Create error messages and set exit value if appropriate
3700 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
3701 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3703 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
3704 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
3705 report('other', $msg, $err);
3710 #-----------------------------------------
3711 # CHASSIS: Check ESM log overall health
3712 #-----------------------------------------
3713 sub check_esmlog_health {
3717 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
3718 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
3719 if (!defined $result) {
3720 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
3721 $snmp_session->error;
3722 report('other', $msg, $E_UNKNOWN);
3724 $health = $snmp_status{$result->{$systemStateEventLogStatus}};
3727 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
3728 if (m/\A Health;(.+) \z/xms) {
3736 # If the overall health of the ESM log is other than "Ok", the
3737 # fill grade of the log is more than 80% and the log should be
3739 if ($health eq 'Ok') {
3740 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
3741 report('other', $msg, $E_OK);
3743 elsif ($health eq 'Critical') {
3744 my $msg = sprintf 'ESM log is 100%% full';
3745 report('other', $msg, $status2nagios{$health});
3748 my $msg = sprintf 'ESM log is more than 80%% full';
3749 report('other', $msg, $status2nagios{$health});
3755 #-----------------------------------------
3756 # CHASSIS: Check ESM log
3757 #-----------------------------------------
3764 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
3766 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
3769 return if !defined $result;
3771 @output = @{ get_snmp_output($result, \%esm_oid) };
3772 foreach my $out (@output) {
3773 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
3777 @output = @{ run_omreport("$omopt_system esmlog") };
3778 foreach my $out (@output) {
3779 ++$count{esm}{$out->{Severity}};
3783 # Create error messages and set exit value if appropriate
3785 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
3786 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3788 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
3789 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
3790 report('other', $msg, $err);
3796 # Handy function for checking all storage components
3799 check_controllers();
3800 check_physical_disks();
3801 check_virtual_disks();
3802 check_cache_battery();
3805 check_enclosure_fans();
3806 check_enclosure_pwr();
3807 check_enclosure_temp();
3808 check_enclosure_emms();
3814 #---------------------------------------------------------------------
3816 #---------------------------------------------------------------------
3819 # Fetch output from 'omreport chassis info', put in sysinfo hash
3821 sub get_omreport_chassis_info {
3822 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
3823 my @lines = <$INFO>;
3826 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag)/xms;
3827 my ($key, $val) = split /;/xms;
3828 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3829 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3830 if ($key eq 'Chassis Model' or $key eq 'Model') {
3831 $sysinfo{model} = $val;
3833 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
3834 $sysinfo{serial} = $val;
3842 # Fetch output from 'omreport chassis bios', put in sysinfo hash
3844 sub get_omreport_chassis_bios {
3845 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
3846 my @lines = <$BIOS>;
3850 my ($key, $val) = split /;/xms;
3851 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3852 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3853 $sysinfo{bios} = $val if $key eq 'Version';
3854 $sysinfo{biosdate} = $val if $key eq 'Release Date';
3861 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
3863 sub get_omreport_system_operatingsystem {
3864 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
3869 my ($key, $val) = split /;/xms;
3870 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3871 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3872 if ($key eq 'Operating System') {
3873 $sysinfo{osname} = $val;
3875 elsif ($key eq 'Operating System Version') {
3876 $sysinfo{osver} = $val;
3884 # Fetch output from 'omreport about', put in sysinfo hash
3886 sub get_omreport_about {
3887 if (open my $OM, '-|', "$omreport about -fmt ssv") {
3891 if (m/\A Version;(.+) \z/xms) {
3901 # Fetch chassis info via SNMP, put in sysinfo hash
3903 sub get_snmp_chassis_info {
3906 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
3907 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
3910 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
3911 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
3913 if (defined $result) {
3914 foreach my $oid (keys %{ $result }) {
3915 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
3916 $sysinfo{model} = $result->{$oid};
3917 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
3919 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
3920 $sysinfo{serial} = $result->{$oid};
3925 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
3926 $snmp_session->error;
3927 report('other', $msg, $E_UNKNOWN);
3933 # Fetch BIOS info via SNMP, put in sysinfo hash
3935 sub get_snmp_chassis_bios {
3938 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
3939 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
3942 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
3943 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
3945 if (defined $result) {
3946 foreach my $oid (keys %{ $result }) {
3947 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
3948 $sysinfo{biosdate} = $result->{$oid};
3949 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
3951 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
3952 $sysinfo{bios} = $result->{$oid};
3957 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
3958 $snmp_session->error;
3959 report('other', $msg, $E_UNKNOWN);
3965 # Fetch OS info via SNMP, put in sysinfo hash
3967 sub get_snmp_system_operatingsystem {
3970 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
3971 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
3974 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
3975 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
3977 if (defined $result) {
3978 foreach my $oid (keys %{ $result }) {
3979 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
3980 $sysinfo{osname} = ($result->{$oid});
3982 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
3983 $sysinfo{osver} = $result->{$oid};
3988 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
3989 $snmp_session->error;
3990 report('other', $msg, $E_UNKNOWN);
3996 # Fetch OMSA version via SNMP, put in sysinfo hash
3998 sub get_snmp_about {
4001 '1.3.6.1.4.1.674.10892.1.100.10.0' => 'systemManagementSoftwareGlobalVersionName',
4003 my $systemManagementSoftwareGroup = '1.3.6.1.4.1.674.10892.1.100';
4004 my $result = $snmp_session->get_table(-baseoid => $systemManagementSoftwareGroup);
4005 if (defined $result) {
4006 foreach my $oid (keys %{ $result }) {
4007 if (exists $omsa_oid{$oid} and $omsa_oid{$oid} eq 'systemManagementSoftwareGlobalVersionName') {
4008 $sysinfo{om} = ($result->{$oid});
4013 my $msg = sprintf 'SNMP ERROR getting OMSA info: %s',
4014 $snmp_session->error;
4015 report('other', $msg, $E_UNKNOWN);
4021 # Collects some information about the system
4025 # Get system model and serial number
4026 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4028 # Get BIOS information. Only if needed
4029 if ( $opt{okinfo} >= 1
4031 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4032 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4035 # Get OMSA information. Only if needed
4036 if ($opt{okinfo} >= 3 or $opt{debug}) {
4037 $snmp ? get_snmp_about() : get_omreport_about();
4040 # Return now if debug
4041 return if $opt{debug};
4043 # Get OS information. Only if needed
4044 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4045 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4052 # Helper function for running omreport when the results are strictly
4054 sub run_omreport_info {
4055 my $command = shift;
4059 # Run omreport and fetch output
4060 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4062 # Parse output, store in array
4063 for ((split /\n/xms, $rawtext)) {
4064 if (m/\A Error/xms) {
4065 my $msg = "Problem running 'omreport $command': $_";
4066 report('other', $msg, $E_UNKNOWN);
4068 next if !m/;/xms; # ignore lines with less than two fields
4069 my @vals = split m/;/xms;
4070 $output{$vals[0]} = $vals[1];
4073 # Finally, return the collected information
4077 # Get various firmware information (BMC, RAC)
4078 sub get_firmware_info {
4079 my @snmp_output = ();
4080 my %nrpe_output = ();
4085 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4086 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4087 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4090 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4091 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4093 # Some don't have this OID, this is ok
4094 if (!defined $result) {
4098 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4101 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4104 my %fw_type # Firmware types
4106 1 => 'other', # other than following values
4107 2 => 'unknown', # unknown
4108 3 => 'systemBIOS', # System BIOS
4109 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4110 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4111 6 => 'systemBackPlane', # System (Primary) Backplane
4112 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4113 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4114 9 => 'frontPanel', # Front Panel Controller
4115 10 => 'baseboardManagementController', # Baseboard Management Controller
4116 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4117 12 => 'sensorData', # Sensor Data Records
4118 13 => 'peripheralBay', # Peripheral Bay Backplane
4119 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4120 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4121 16 => 'rac', # Remote Access Controller
4122 17 => 'imc' # Integrated Management Controller
4127 foreach my $out (@snmp_output) {
4128 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4129 $sysinfo{'bmc'} = 1;
4130 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4132 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|imc \z}xms) {
4133 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4134 $sysinfo{'rac'} = 1;
4135 $sysinfo{'rac_name'} = $name;
4136 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4141 foreach my $key (keys %nrpe_output) {
4142 next if !defined $nrpe_output{$key};
4143 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4144 $sysinfo{'bmc'} = 1;
4145 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4147 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4149 $sysinfo{'rac'} = 1;
4150 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4151 $sysinfo{'rac_name'} = $name;
4161 #=====================================================================
4163 #=====================================================================
4165 # Here we do the actual checking of components
4166 # Check global status if applicable
4168 $globalstatus = check_global();
4171 # Do multiple selected checks
4172 if ($check{storage}) { check_storage(); }
4173 if ($check{memory}) { check_memory(); }
4174 if ($check{fans}) { check_fans(); }
4175 if ($check{power}) { check_powersupplies(); }
4176 if ($check{temp}) { check_temperatures(); }
4177 if ($check{cpu}) { check_processors(); }
4178 if ($check{voltage}) { check_volts(); }
4179 if ($check{batteries}) { check_batteries(); }
4180 if ($check{amperage}) { check_pwrmonitoring(); }
4181 if ($check{intrusion}) { check_intrusion(); }
4182 if ($check{alertlog}) { check_alertlog(); }
4183 if ($check{esmlog}) { check_esmlog(); }
4184 if ($check{esmhealth}) { check_esmlog_health(); }
4187 #---------------------------------------------------------------------
4189 #---------------------------------------------------------------------
4200 # Get system information
4203 # Get firmware info if requested via option
4204 if ($opt{okinfo} >= 1) {
4205 get_firmware_info();
4208 # Close SNMP session
4210 $snmp_session->close;
4215 print " System: $sysinfo{model}\n";
4216 print " ServiceTag: $sysinfo{serial}";
4217 print q{ } x (25 - length $sysinfo{serial}), "OMSA version: $sysinfo{om}\n";
4218 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4219 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Plugin version: $VERSION\n";
4220 if ($#report_storage >= 0) {
4221 print "-----------------------------------------------------------------------------\n";
4222 print " Storage Components \n";
4223 print "=============================================================================\n";
4224 print " STATE | ID | MESSAGE TEXT \n";
4225 print "---------+----------+--------------------------------------------------------\n";
4226 foreach (@report_storage) {
4227 my ($msg, $level, $nexus) = @{$_};
4228 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4229 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4230 $nagios_alert_count{$reverse_exitcode{$level}}++;
4233 if ($#report_chassis >= 0) {
4234 print "-----------------------------------------------------------------------------\n";
4235 print " Chassis Components \n";
4236 print "=============================================================================\n";
4237 print " STATE | ID | MESSAGE TEXT \n";
4238 print "---------+------+------------------------------------------------------------\n";
4239 foreach (@report_chassis) {
4240 my ($msg, $level, $nexus) = @{$_};
4241 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4242 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4243 $nagios_alert_count{$reverse_exitcode{$level}}++;
4246 if ($#report_other >= 0) {
4247 print "-----------------------------------------------------------------------------\n";
4248 print " Other messages \n";
4249 print "=============================================================================\n";
4250 print " STATE | MESSAGE TEXT \n";
4251 print "---------+-------------------------------------------------------------------\n";
4252 foreach (@report_other) {
4253 my ($msg, $level, $nexus) = @{$_};
4254 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4255 $nagios_alert_count{$reverse_exitcode{$level}}++;
4260 my $c = 0; # counter to determine linebreaks
4262 # Run through each message, sorted by severity level
4264 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4265 my ($msg, $level, $nexus) = @{ $_ };
4266 next ALERT if $level == $E_OK;
4268 if (defined $opt{only}) {
4269 # If user wants only critical alerts
4270 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4272 # If user wants only warning alerts
4273 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4276 # Prefix with service tag if specified with option '-i|--info'
4278 if (defined $opt{htmlinfo}) {
4279 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4280 . "\">$sysinfo{serial}</a>] " . $msg;
4283 $msg = "[$sysinfo{serial}] " . $msg;
4287 # Prefix with nagios level if specified with option '--state'
4288 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4290 # Prefix with one-letter nagios level if specified with option '--short-state'
4291 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4293 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4295 $nagios_alert_count{$reverse_exitcode{$level}}++;
4299 # Determine our exit code
4301 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4302 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4303 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4305 # Global status via SNMP.. extra safety check
4306 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4307 print "OOPS! Something is wrong with this server, but I don't know what. ";
4308 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4309 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4310 print "please file a bug report.\n";
4315 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4317 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4318 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4319 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4320 'memory' => "MEMORY OK - $count{dimm} memory modules checked",
4321 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4322 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4323 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4324 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4325 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4326 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4327 '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",
4328 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4329 'esmhealth' => "ESM LOG OK - less than 80% used",
4332 print $okmsg{$opt{only}};
4334 elsif ($exit_code == $E_OK && !$opt{debug}) {
4335 if (defined $opt{htmlinfo}) {
4336 printf q{OK - System: '<a href="%s">%s</a>', SN: '<a href="%s">%s</a>', hardware working fine},
4337 documentation_url($sysinfo{model}), $sysinfo{model},
4338 warranty_url($sysinfo{serial}), $sysinfo{serial};
4341 printf q{OK - System: '%s', SN: '%s', hardware working fine},
4342 $sysinfo{model}, $sysinfo{serial};
4345 if ($check{storage}) {
4346 printf ', %d logical drives, %d physical drives',
4347 $count{vdisk}, $count{pdisk};
4350 print ', not checking storage';
4353 if ($opt{okinfo} >= 1) {
4355 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4357 if ($sysinfo{rac}) {
4358 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4360 if ($sysinfo{bmc}) {
4361 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4365 if ($opt{okinfo} >= 2) {
4366 if ($check{storage}) {
4367 my @storageprint = ();
4368 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4369 chomp $sysinfo{controller}{$id}{driver};
4370 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4371 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4372 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4373 if (defined $sysinfo{controller}{$id}{storport}) {
4374 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4376 push @storageprint, $msg;
4378 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4379 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4380 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4381 $sysinfo{enclosure}{$id}->{firmware};
4385 foreach my $line (@storageprint) {
4386 print $linebreak, $line;
4391 if ($opt{okinfo} >= 3) {
4392 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4397 if ($opt{extinfo}) {
4399 if (defined $opt{htmlinfo}) {
4400 printf '------ SYSTEM: <a href="%s">%s</a>, SN: <a href="%s">%s</a>',
4401 documentation_url($sysinfo{model}), $sysinfo{model},
4402 warranty_url($sysinfo{serial}), $sysinfo{serial};
4405 printf '------ SYSTEM: %s, SN: %s',
4406 $sysinfo{model}, $sysinfo{serial};
4409 if (defined $opt{postmsg}) {
4411 if (-f $opt{postmsg}) {
4412 open my $POST, '<', $opt{postmsg}
4413 or ( print $linebreak
4414 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4415 and exit $E_UNKNOWN );
4421 $post = $opt{postmsg};
4423 if (defined $post) {
4425 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4426 $post =~ s{[%]m}{$sysinfo{model}}gxms;
4427 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4428 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4429 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4430 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4431 $post =~ s{[%]p}{$count{pdisk}}gxms;
4432 $post =~ s{[%]l}{$count{vdisk}}gxms;
4433 $post =~ s{[%]n}{$linebreak}gxms;
4434 $post =~ s{[%]{2}}{%}gxms;
4440 # Reset the WARN signal
4441 $SIG{__WARN__} = 'DEFAULT';
4443 # Print any perl warnings that have occured
4444 if (@perl_warnings) {
4445 foreach (@perl_warnings) {
4447 print "${linebreak}INTERNAL ERROR: @$_";
4449 $exit_code = $E_UNKNOWN;
4452 # Print performance data
4453 if (defined $opt{perfdata} && !$opt{debug} && %perfdata) {
4454 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4465 return ($order{(split /_/, $a, 2)[0]} cmp $order{(split /_/, $b, 2)[0]}) || $a cmp $b;
4468 print join $lb, map { "'$_'=$perfdata{$_}" } sort perfdata keys %perfdata;
4471 # Print a linebreak at the end
4472 print "\n" if !$opt{debug};
4474 # Exit with proper exit code