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 %reverse_exitcode %status2nagios
39 %snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
40 %blacklist %nagios_alert_count %count
41 @perl_warnings @controllers @enclosures @perfdata
42 @report_storage @report_chassis @report_other
45 #---------------------------------------------------------------------
46 # Initialization and global variables
47 #---------------------------------------------------------------------
49 # Collect perl warnings in an array
50 $SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
52 # Version and similar info
53 $NAME = 'check_openmanage';
54 $VERSION = '3.5.8-beta4';
55 $AUTHOR = 'Trond H. Amundsen';
56 $CONTACT = 't.h.amundsen@usit.uio.no';
64 # Firmware update lock file [FIXME: location on Windows?]
65 $FW_LOCK = '/var/lock/.spsetup'; # default on Linux
68 $USAGE = <<"END_USAGE";
69 Usage: $NAME [OPTION]...
77 -p, --perfdata Output performance data
78 -t, --timeout Plugin timeout in seconds
79 -c, --critical Customise temperature critical limits
80 -w, --warning Customise temperature warning limits
81 -d, --debug Debug output, reports everything
82 -h, --help Display this help text
83 -V, --version Display version info
87 -H, --hostname Hostname or IP (required for SNMP)
88 -C, --community SNMP community string
89 -P, --protocol SNMP protocol version
90 --port SNMP port number
94 -i, --info Prefix any alerts with the service tag
95 -e, --extinfo Append system info to alerts
96 -s, --state Prefix alerts with alert state
97 -S, --short-state Prefix alerts with alert state (abbreviated)
98 -o, --okinfo Verbosity when check result is OK
99 -I, --htmlinfo HTML output with clickable links
101 CHECK CONTROL AND BLACKLISTING:
103 -a, --all Check everything, even log content
104 -b, --blacklist Blacklist missing and/or failed components
105 --only Only check a certain component or alert type
106 --check Fine-tune which components are checked
108 For more information and advanced options, see the manual page or URL:
109 http://folk.uio.no/trondham/software/check_openmanage.html
112 # Version and license text
113 $LICENSE = <<"END_LICENSE";
115 Copyright (C) 2010 $AUTHOR
116 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
117 This is free software: you are free to change and redistribute it.
118 There is NO WARRANTY, to the extent permitted by law.
120 Written by $AUTHOR <$CONTACT>
123 # Options with default values
124 %opt = ( 'blacklist' => [], # blacklisting
125 'check' => [], # check control
126 'critical' => [], # temperature critical limits
127 'warning' => [], # temperature warning limits
128 'timeout' => 30, # default timeout is 30 seconds
129 'debug' => 0, # debugging / verbose output
130 'help' => 0, # display help output
131 'perfdata' => undef, # output performance data
132 'info' => 0, # display servicetag
133 'extinfo' => 0, # display extra info
134 'htmlinfo' => undef, # html tags in output
135 'postmsg' => undef, # post message
136 'state' => 0, # display alert type
137 'short-state' => 0, # display alert type (short)
138 'okinfo' => 0, # default "ok" output level
139 'linebreak' => undef, # specify linebreak
140 'version' => 0, # plugin version info
141 'all' => 0, # check everything
142 'only' => undef, # only one component
143 'omreport' => undef, # omreport path
144 'port' => 161, # default SNMP port
145 'hostname' => undef, # hostname or IP
146 'community' => 'public', # SMNP v1 or v2c
147 'protocol' => 2, # default SNMP protocol 2c
148 'username' => undef, # SMNP v3
149 'authpassword' => undef, # SMNP v3
150 'authkey' => undef, # SMNP v3
151 'authprotocol' => undef, # SMNP v3
152 'privpassword' => undef, # SMNP v3
153 'privkey' => undef, # SMNP v3
154 'privprotocol' => undef, # SMNP v3
155 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
159 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
160 'check=s' => \@{ $opt{check} },
161 'c|critical=s' => \@{ $opt{critical} },
162 'w|warning=s' => \@{ $opt{warning} },
163 't|timeout=i' => \$opt{timeout},
164 'd|debug' => \$opt{debug},
165 'h|help' => \$opt{help},
166 'V|version' => \$opt{version},
167 'p|perfdata:s' => \$opt{perfdata},
168 'i|info' => \$opt{info},
169 'e|extinfo' => \$opt{extinfo},
170 'I|htmlinfo:s' => \$opt{htmlinfo},
171 'postmsg=s' => \$opt{postmsg},
172 's|state' => \$opt{state},
173 'S|short-state' => \$opt{shortstate},
174 'o|ok-info=i' => \$opt{okinfo},
175 'linebreak=s' => \$opt{linebreak},
176 'a|all' => \$opt{all},
177 'only=s' => \$opt{only},
178 'omreport=s' => \$opt{omreport},
179 'port=i' => \$opt{port},
180 'H|hostname=s' => \$opt{hostname},
181 'C|community=s' => \$opt{community},
182 'P|protocol=i' => \$opt{protocol},
183 'U|username=s' => \$opt{username},
184 'authpassword=s' => \$opt{authpassword},
185 'authkey=s' => \$opt{authkey},
186 'authprotocol=s' => \$opt{authprotocol},
187 'privpassword=s' => \$opt{privpassword},
188 'privkey=s' => \$opt{privkey},
189 'privprotocol=s' => \$opt{privprotocol},
190 'use-get_table' => \$opt{use_get_table},
191 ) or do { print $USAGE; exit $E_UNKNOWN };
193 # If user requested help
199 # If user requested version info
207 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
212 # If we're using SNMP
213 $snmp = defined $opt{hostname} ? 1 : 0;
215 # SNMP session variables
216 $snmp_session = undef;
219 # The omreport command
222 # Check flags, override available with the --check option
223 %check = ( 'storage' => 1, # check storage subsystem
224 'memory' => 1, # check memory (dimms)
225 'fans' => 1, # check fan status
226 'power' => 1, # check power supplies
227 'temp' => 1, # check temperature
228 'cpu' => 1, # check processors
229 'voltage' => 1, # check voltage
230 'batteries' => 1, # check battery probes
231 'amperage' => 1, # check power consumption
232 'intrusion' => 1, # check intrusion detection
233 'alertlog' => 0, # check the alert log
234 'esmlog' => 0, # check the ESM log (hardware log)
235 'esmhealth' => 1, # check the ESM log overall health
239 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
241 # Line break from option
242 if (defined $opt{linebreak}) {
243 if ($opt{linebreak} eq 'REG') {
246 elsif ($opt{linebreak} eq 'HTML') {
247 $linebreak = '<br/>';
250 $linebreak = $opt{linebreak};
254 # Exit with status=UNKNOWN if there is firmware upgrade in progress
255 if (!$snmp && -f $FW_LOCK) {
256 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
260 # List of controllers and enclosures
261 @controllers = (); # controllers
262 @enclosures = (); # enclosures
265 @report_storage = (); # messages with associated nagios level (storage)
266 @report_chassis = (); # messages with associated nagios level (chassis)
267 @report_other = (); # messages with associated nagios level (other)
269 # Counters for everything
272 'pdisk' => 0, # number of physical disks
273 'vdisk' => 0, # number of logical drives (virtual disks)
274 'temp' => 0, # number of temperature probes
275 'volt' => 0, # number of voltage probes
276 'amp' => 0, # number of amperage probes
277 'intr' => 0, # number of intrusion probes
278 'dimm' => 0, # number of memory modules
279 'fan' => 0, # number of fan probes
280 'cpu' => 0, # number of CPUs
281 'bat' => 0, # number of batteries
282 'power' => 0, # number of power supplies
284 'Critical' => 0, # critical entries in ESM log
285 'Non-Critical' => 0, # warning entries in ESM log
286 'Ok' => 0, # ok entries in ESM log
289 'Critical' => 0, # critical entries in alert log
290 'Non-Critical' => 0, # warning entries in alert log
291 'Ok' => 0, # ok entries in alert log
298 # Global health status
299 $global = 1; # default is to check global status
300 $globalstatus = $E_OK; # default global health status is "OK"
302 # Nagios error levels reversed
306 $E_WARNING => 'WARNING',
307 $E_CRITICAL => 'CRITICAL',
308 $E_UNKNOWN => 'UNKNOWN',
311 # OpenManage (omreport) and SNMP error levels
314 'Unknown' => $E_CRITICAL,
315 'Critical' => $E_CRITICAL,
316 'Non-Critical' => $E_WARNING,
318 'Non-Recoverable' => $E_CRITICAL,
319 'Other' => $E_CRITICAL,
330 6 => 'Non-Recoverable',
333 # Probe Status via SNMP
336 1 => 'Other', # probe status is not one of the following:
337 2 => 'Unknown', # probe status is unknown (not known or monitored)
338 3 => 'Ok', # probe is reporting a value within the thresholds
339 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
340 5 => 'criticalUpper', # probe has crossed upper critical threshold
341 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
342 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
343 8 => 'criticalLower', # probe has crossed lower critical threshold
344 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
345 10 => 'failed', # probe is not functional
348 # Probe status translated to Nagios alarm levels
351 'Other' => $E_CRITICAL,
352 'Unknown' => $E_CRITICAL,
354 'nonCriticalUpper' => $E_WARNING,
355 'criticalUpper' => $E_CRITICAL,
356 'nonRecoverableUpper' => $E_CRITICAL,
357 'nonCriticalLower' => $E_WARNING,
358 'criticalLower' => $E_CRITICAL,
359 'nonRecoverableLower' => $E_CRITICAL,
360 'failed' => $E_CRITICAL,
363 # System information gathered
366 'bios' => 'N/A', # BIOS version
367 'biosdate' => 'N/A', # BIOS release date
368 'serial' => 'N/A', # serial number (service tag)
369 'model' => 'N/A', # system model
370 'osname' => 'N/A', # OS name
371 'osver' => 'N/A', # OS version
372 'om' => 'N/A', # OMSA version
373 'bmc' => 0, # HAS baseboard management controller (BMC)
374 'rac' => 0, # HAS remote access controller (RAC)
375 'rac_name' => 'N/A', # remote access controller (RAC)
376 'bmc_fw' => 'N/A', # BMC firmware
377 'rac_fw' => 'N/A', # RAC firmware
380 # Adjust which checks to perform
381 adjust_checks() if defined $opt{check};
383 # Blacklisted components
384 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
386 # If blacklisting is in effect, don't check global health status
387 if (scalar keys %blacklist > 0) {
391 # Take into account new hardware and blades
392 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
393 $omopt_system = 'system'; # default "system" option to omreport
394 $blade = 0; # if this is a blade system
396 # Some initializations and checking before we begin
398 snmp_initialize(); # initialize SNMP
399 snmp_check(); # check that SNMP works
400 snmp_detect_blade(); # detect blade via SNMP
403 # Find the omreport binary
405 # Check help output from omreport, see which options are available.
406 # Also detecting blade via omreport.
407 check_omreport_options();
411 #---------------------------------------------------------------------
413 #---------------------------------------------------------------------
416 # Store a message in one of the message arrays
419 my ($type, $msg, $exval, $id) = @_;
420 defined $id or $id = q{};
424 'storage' => \@report_storage,
425 'chassis' => \@report_chassis,
426 'other' => \@report_other,
429 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
434 # Run command, put resulting output lines in an array and return a
435 # pointer to that array
440 open my $CMD, '-|', $command
441 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
445 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
446 and return \@lines };
451 # Run command, put resulting output in a string variable and return it
456 open my $CMD, '-|', $command
457 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
458 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
461 # NOTE: We don't check the return value of close() since omreport
462 # does something weird sometimes.
470 sub snmp_initialize {
471 # Legal SNMP v3 protocols
472 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
473 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
475 # Parameters to Net::SNMP->session()
478 '-port' => $opt{port},
479 '-hostname' => $opt{hostname},
480 '-version' => $opt{protocol},
483 # Parameters for SNMP v3
484 if ($opt{protocol} == 3) {
486 # Username is mandatory
487 if (defined $opt{username}) {
488 $param{'-username'} = $opt{username};
491 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
495 # Authpassword is optional
496 if (defined $opt{authpassword}) {
497 $param{'-authpassword'} = $opt{authpassword};
500 # Authkey is optional
501 if (defined $opt{authkey}) {
502 $param{'-authkey'} = $opt{authkey};
505 # Privpassword is optional
506 if (defined $opt{privpassword}) {
507 $param{'-privpassword'} = $opt{privpassword};
510 # Privkey is optional
511 if (defined $opt{privkey}) {
512 $param{'-privkey'} = $opt{privkey};
515 # Privprotocol is optional
516 if (defined $opt{privprotocol}) {
517 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
518 $param{'-privprotocol'} = $opt{privprotocol};
521 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
522 . "must be one of [des|aes|aes128|3des|3desde]\n";
527 # Authprotocol is optional
528 if (defined $opt{authprotocol}) {
529 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
530 $param{'-authprotocol'} = $opt{authprotocol};
533 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
534 . "must be one of [md5|sha]\n";
539 # Parameters for SNMP v2c or v1
540 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
541 $param{'-community'} = $opt{community};
544 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
548 # Try to initialize the SNMP session
549 if ( eval { require Net::SNMP; 1 } ) {
550 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
551 if (!defined $snmp_session) {
552 printf "SNMP: %s\n", $snmp_error;
557 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
564 # Checking if SNMP works by probing for "chassisModelName", which all
565 # servers should have
568 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
569 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
571 # Typically if remote host isn't responding
572 if (!defined $result) {
573 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
577 # If OpenManage isn't installed or is not working
578 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
579 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
586 # Detecting blade via SNMP
588 sub snmp_detect_blade {
589 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
590 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
592 # Identify blade. Older models (4th and 5th gen models) and/or old
593 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
594 # similar, we assume that this isn't a blade
595 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
602 # Locate the omreport binary
605 # If user has specified path to omreport
606 if (defined $opt{omreport} and -x $opt{omreport}) {
607 $omreport = qq{"$opt{omreport}"};
611 # Possible full paths for omreport
614 '/usr/bin/omreport', # default on Linux
615 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA 6.2.0
616 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
617 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
618 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
619 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
620 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
621 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
624 # Find the one to use
626 foreach my $bin (@omreport_paths) {
628 $omreport = qq{"$bin"};
633 # Exit with status=UNKNOWN if OM is not installed, or we don't
634 # have permission to execute the binary
635 if (!defined $omreport) {
636 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
643 # Checks output from 'omreport -?' and searches for arguments to
644 # omreport, to accommodate deprecated options "chassis" and "system"
645 # (on newer hardware), as well as blade servers.
647 sub check_omreport_options {
648 foreach (@{ run_command("$omreport -? 2>&1") }) {
649 if (m/\A servermodule /xms) {
650 # If "servermodule" argument to omreport exists, use it
651 # instead of argument "system"
652 $omopt_system = 'servermodule';
654 elsif (m/\A mainsystem /xms) {
655 # If "mainsystem" argument to omreport exists, use it
656 # instead of argument "chassis"
657 $omopt_chassis = 'mainsystem';
659 elsif (m/\A modularenclosure /xms) {
660 # If "modularenclusure" argument to omreport exists, assume
661 # that this is a blade
669 # Read the blacklist option and return a hash containing the
670 # blacklisted components
676 if (scalar @{ $opt{blacklist} } >= 0) {
677 foreach my $black (@{ $opt{blacklist} }) {
680 open my $BL, '<', $black
681 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
694 return {} if $#bl < 0;
696 # Parse blacklist string, put in hash
697 foreach my $black (@bl) {
698 my @comps = split m{/}xms, $black;
699 foreach my $c (@comps) {
700 next if $c !~ m/=/xms;
701 my ($key, $val) = split /=/xms, $c;
702 my @vals = split /,/xms, $val;
703 $blacklist{$key} = \@vals;
711 # Read the check option and adjust the hash %check, which is a rough
712 # list of components to be checked
717 # Adjust checking based on the '--all' option
720 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
721 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
724 if (scalar @{ $opt{check} } > 0) {
725 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
729 # set the check hash to check everything
730 map { $_ = 1 } values %check;
735 # Adjust checking based on the '--only' option
736 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
738 if (scalar @{ $opt{check} } > 0) {
739 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
742 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
743 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
747 # reset the check hash
748 map { $_ = 0 } values %check;
750 # adjust the check hash
751 if ($opt{only} eq 'chassis') {
752 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
753 batteries amperage intrusion esmhealth);
756 $check{$opt{only}} = 1;
762 # Adjust checking based on the '--check' option
763 if (scalar @{ $opt{check} } >= 0) {
764 foreach my $check (@{ $opt{check} }) {
767 open my $CL, '<', $check
768 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
781 # Parse checklist string, put in hash
782 foreach my $check (@cl) {
783 my @checks = split /,/xms, $check;
784 foreach my $c (@checks) {
785 next if $c !~ m/=/xms;
786 my ($key, $val) = split /=/xms, $c;
791 # Check if we should check global health status
793 foreach (keys %check) {
794 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
795 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
797 if ($check{$_} == 0) { # found something with checking turned off
807 # Runs omreport and returns an array of anonymous hashes containing
809 # Takes one argument: string containing parameters to omreport
816 # Errors that are OK. Some low-end poweredge (and blades) models
817 # don't have RAID controllers, intrusion detection sensor, or
818 # redundant/instrumented power supplies etc.
821 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
822 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
823 | No\scontrollers\sfound # No RAID controller
824 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
825 | Invalid\scommand:\spwrmonitoring # Older OMSAs lack this command(?)
826 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
829 # Errors that are OK on blade servers
832 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
835 # Run omreport and fetch output
836 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
837 return [] if !defined $rawtext;
839 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
840 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
842 # Openmanage sometimes puts a linebreak between "Error" and the
844 $rawtext =~ s{^Error\s*\n}{Error: }xms;
846 # Parse output, store in array
847 for ((split m{\n}xms, $rawtext)) {
849 next if m{$ok_errors}xms;
850 next if ($blade and m{$ok_blade_errors}xms);
851 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
854 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
855 my @vals = split /;/xms;
856 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed) \z/xms) {
861 push @output, { map { $_ => $vals[$i++] } @keys };
866 # Finally, return the collected information
872 # Checks if a component is blacklisted. Returns 1 if the component is
873 # blacklisted, 0 otherwise. Takes two arguments:
874 # arg1: component name
875 # arg2: component id or index
878 my $name = shift; # component name
879 my $id = shift; # component id
880 my $ret = 0; # return value
882 if (defined $blacklist{$name}) {
883 foreach my $comp (@{ $blacklist{$name} }) {
884 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
893 # Converts the NexusID from SNMP to our version
896 $nexus =~ s{\A \\}{}xms;
897 $nexus =~ s{\\}{:}gxms;
901 # Sets custom temperature thresholds based on user supplied options
902 sub custom_temperature_thresholds {
903 my $type = shift; # type of threshold, either w (warning) or c (critical)
904 my %thres = (); # will contain the thresholds
905 my @limits = (); # holds the input
907 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
909 if (scalar @opt >= 0) {
910 foreach my $t (@opt) {
914 or do { report('other', "Couldn't open temperature threshold file $t: $!",
915 $E_UNKNOWN) and return {} };
926 # Parse checklist string, put in hash
927 foreach my $th (@limits) {
928 my @tmp = split m{,}xms, $th;
929 foreach my $t (@tmp) {
930 next if $t !~ m{=}xms;
931 my ($key, $val) = split m{=}xms, $t;
932 if ($val =~ m{/}xms) {
933 my ($max, $min) = split m{/}xms, $val;
934 $thres{$key}{max} = $max;
935 $thres{$key}{min} = $min;
938 $thres{$key}{max} = $val;
947 # Gets the output from SNMP result according to the OIDs checked
948 sub get_snmp_output {
949 my ($result,$oidref) = @_;
953 foreach my $oid (keys %{ $result }) {
955 $short =~ s{\s}{}gxms; # remove whitespace
956 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
958 if (exists $oidref->{$short}) {
959 $temp[$id]{$oidref->{$short}} = $result->{$oid};
963 # Remove any empty indexes
964 foreach my $out (@temp) {
974 # Map the controller or other item in-place
976 my ($key, $val, $list) = @_;
978 foreach my $lst (@{ $list }) {
979 if (!exists $lst->{$key}) {
986 # Return the URL for official Dell documentation for a specific
988 sub documentation_url {
991 # create model short form, e.g. "r710"
992 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
994 # special case for blades (e.g. M600, M710), they have common
996 $model =~ s{\A m\d+ \z}{m}xms;
998 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1001 # Return the URL for warranty information for a server with a given
1002 # serial number (servicetag)
1006 # Dell support sites for different parts of the world
1009 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1010 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1011 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1014 # warranty URLs for different country codes
1018 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1019 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1020 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1021 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1022 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1023 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1024 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1025 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1026 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1027 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1028 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1029 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1030 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1031 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1032 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1033 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1034 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1035 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1036 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1037 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1039 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1040 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1041 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1042 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1044 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1045 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1046 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1048 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1051 if (exists $url{$opt{htmlinfo}}) {
1052 return $url{$opt{htmlinfo}} . $tag;
1055 return $url{XX} . $tag;
1060 # This helper function returns the corresponding value of a hash key,
1061 # but takes into account that the key may not exist
1063 my $key = shift || return undef;
1065 return exists $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1070 #---------------------------------------------------------------------
1072 #---------------------------------------------------------------------
1074 #-----------------------------------------
1075 # Check global health status
1076 #-----------------------------------------
1082 # Checks global status, i.e. both storage and chassis
1084 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1085 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1086 if (!defined $result) {
1087 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1090 $health = $status2nagios{$snmp_status{$result->{$systemStateGlobalSystemStatus}}};
1094 # NB! This does not check storage, only chassis...
1096 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1098 next if m/\A SEVERITY;COMPONENT/xms;
1099 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1100 $health = $status2nagios{$1};
1111 #-----------------------------------------
1112 # STORAGE: Check controllers
1113 #-----------------------------------------
1114 sub check_controllers {
1115 return if blacklisted('ctrl', 'all');
1124 my $firmware = undef;
1126 my $minstdr = undef; # Minimum required Storport driver version
1127 my $stdr = undef; # Storport driver version
1133 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1134 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1135 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1136 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1137 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1138 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1139 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1140 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1141 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1142 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1143 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1146 # We use get_table() here for the odd case where a server has
1147 # two or more controllers, and where some OIDs are missing on
1148 # one of the controllers.
1149 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1150 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1152 # No controllers is OK
1153 return if !defined $result;
1155 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1158 @output = @{ run_omreport('storage controller') };
1172 foreach my $out (@output) {
1174 $id = $out->{controllerNumber} - 1;
1175 $name = $out->{controllerName};
1176 $state = get_hashval($out->{controllerState}, \%ctrl_state);
1177 $status = $snmp_status{$out->{controllerComponentStatus}};
1178 $minfw = exists $out->{controllerMinFWVersion}
1179 ? $out->{controllerMinFWVersion} : undef;
1180 $mindr = exists $out->{controllerMinDriverVersion}
1181 ? $out->{controllerMinDriverVersion} : undef;
1182 $firmware = exists $out->{controllerFWVersion}
1183 ? $out->{controllerFWVersion} : 'N/A';
1184 $driver = exists $out->{controllerDriverVersion}
1185 ? $out->{controllerDriverVersion} : 'N/A';
1186 $minstdr = exists $out->{'controllerMinRequiredStorportVer'}
1187 ? $out->{controllerMinRequiredStorportVer} : undef;
1188 $stdr = exists $out->{controllerStorportDriverVersion}
1189 ? $out->{controllerStorportDriverVersion} : undef;
1190 $nexus = convert_nexus($out->{controllerNexusID});
1194 $name = $out->{Name};
1195 $state = $out->{State};
1196 $status = $out->{Status};
1197 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1198 ? $out->{'Minimum Required Firmware Version'} : undef;
1199 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1200 ? $out->{'Minimum Required Driver Version'} : undef;
1201 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1202 ? $out->{'Firmware Version'} : 'N/A';
1203 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1204 ? $out->{'Driver Version'} : 'N/A';
1205 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1206 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1207 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1208 $stdr = (exists $out->{'Storport Driver Version'}
1209 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1210 ? $out->{'Storport Driver Version'} : undef;
1214 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1215 push @controllers, $id;
1217 # Collecting some storage info
1218 $sysinfo{'controller'}{$id}{'id'} = $nexus;
1219 $sysinfo{'controller'}{$id}{'name'} = $name;
1220 $sysinfo{'controller'}{$id}{'driver'} = $driver;
1221 $sysinfo{'controller'}{$id}{'firmware'} = $firmware;
1222 $sysinfo{'controller'}{$id}{'storport'} = $stdr;
1224 next CTRL if blacklisted('ctrl', $nexus);
1226 # Special case: old firmware
1227 if (!blacklisted('ctrl_fw', $id) && defined $minfw) {
1229 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1230 $id, $name, $firmware;
1231 report('storage', $msg, $E_WARNING, $nexus);
1233 # Special case: old driver
1234 if (!blacklisted('ctrl_driver', $id) && defined $mindr) {
1236 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1237 $id, $name, $driver;
1238 report('storage', $msg, $E_WARNING, $nexus);
1240 # Special case: old storport driver
1241 if (!blacklisted('ctrl_stdr', $id) && defined $minstdr) {
1243 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1245 report('storage', $msg, $E_WARNING, $nexus);
1248 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1249 and (defined $minfw or defined $mindr or defined $minstdr))) {
1250 my $msg = sprintf 'Controller %d [%s] is %s',
1252 report('storage', $msg, $E_OK, $nexus);
1256 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1258 report('storage', $msg, $status2nagios{$status}, $nexus);
1265 #-----------------------------------------
1266 # STORAGE: Check physical drives
1267 #-----------------------------------------
1268 sub check_physical_disks {
1269 return if $#controllers == -1;
1270 return if blacklisted('pdisk', 'all');
1280 my $vendor = undef; # disk vendor
1281 my $product = undef; # product ID
1282 my $capacity = undef; # disk length (size) in bytes
1288 '1.3.6.1.4.1.674.10893.1.20.130.4.1.1' => 'arrayDiskNumber',
1289 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1290 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1291 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1292 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1293 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1294 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1295 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1296 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1297 '1.3.6.1.4.1.674.10893.1.20.130.4.1.16' => 'arrayDiskLunID',
1298 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1299 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1300 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1301 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1302 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1305 if ($opt{use_get_table}) {
1306 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1307 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1308 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1310 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1311 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1312 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1314 if (defined $result) {
1315 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1316 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1320 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1323 if (!defined $result) {
1324 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1325 $snmp_session->close;
1329 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1332 foreach my $c (@controllers) {
1333 # This blacklists disks with broken firmware, which includes
1334 # illegal XML characters that makes openmanage choke on itself
1335 next if blacklisted('ctrl_pdisk', $c);
1337 push @output, @{ run_omreport("storage pdisk controller=$c") };
1338 map_item('ctrl', $c, \@output);
1353 22 => 'Replacing', # FIXME: this one is not defined in the OM 6.2.0.1 MIBs
1357 28 => 'Diagnostics',
1358 34 => 'Predictive failure',
1359 35 => 'Initializing',
1362 41 => 'Unsupported',
1363 53 => 'Incompatible',
1366 # Check physical disks on each of the controllers
1368 foreach my $out (@output) {
1370 $name = $out->{arrayDiskName};
1371 if (exists $out->{arrayDiskEnclosureID}) {
1372 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskEnclosureID},
1373 $out->{arrayDiskTargetID});
1376 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskTargetID});
1378 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state);
1379 $status = $snmp_status{$out->{arrayDiskComponentStatus}};
1380 $fpred = $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1382 $nexus = convert_nexus($out->{arrayDiskNexusID});
1383 $vendor = $out->{arrayDiskVendor};
1384 $product = $out->{arrayDiskProductID};
1385 $capacity = $out->{arrayDiskLengthInMB} * 1024**2;
1386 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1387 $ctrl = $out->{arrayDiskEnclosureConnectionControllerNumber} - 1;
1389 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1390 $ctrl = $out->{arrayDiskChannelConnectionControllerNumber} - 1;
1398 $name = $out->{'Name'};
1399 $state = $out->{'State'};
1400 $status = $out->{'Status'};
1401 $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
1402 $progr = ' [' . $out->{'Progress'} . ']';
1403 $ctrl = $out->{'ctrl'};
1404 $nexus = join q{:}, $out->{ctrl}, $id;
1405 $vendor = $out->{'Vendor ID'};
1406 $product = $out->{'Product ID'};
1407 $capacity = $out->{'Capacity'};
1408 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1411 next PDISK if blacklisted('pdisk', $nexus);
1414 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1415 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1417 # Calculate human readable capacity
1418 $capacity = ceil($capacity / 1000**3) >= 1000
1419 ? sprintf '%.1fTB', ($capacity / 1000**4)
1420 : sprintf '%.0fGB', ($capacity / 1000**3);
1421 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1422 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1423 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1425 # Capitalize only the first letter of the vendor name
1426 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1428 # Remove unnecessary trademark rubbish from vendor name
1429 $vendor =~ s{\(tm\)\z}{}xms;
1431 # Special case: Failure predicted
1433 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1434 $name, $vendor, $product, $capacity, $ctrl;
1435 $msg .= " ($state)" if $state ne 'Predictive failure';
1436 report('storage', $msg,
1437 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1439 # Special case: Rebuilding / Replacing
1440 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1441 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1442 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1443 report('storage', $msg, $E_WARNING, $nexus);
1446 elsif ($status ne 'Ok') {
1447 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1448 $name, $vendor, $product, $capacity, $ctrl, $state;
1449 report('storage', $msg, $status2nagios{$status}, $nexus);
1453 my $msg = sprintf '%s [%s] on ctrl %d is %s',
1454 $name, $capacity, $ctrl, $state;
1455 report('storage', $msg, $E_OK, $nexus);
1462 #-----------------------------------------
1463 # STORAGE: Check logical drives
1464 #-----------------------------------------
1465 sub check_virtual_disks {
1466 return if $#controllers == -1;
1467 return if blacklisted('vdisk', 'all');
1484 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1485 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1486 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1487 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1488 '1.3.6.1.4.1.674.10893.1.20.140.1.1.17' => 'virtualDiskTargetID',
1489 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1490 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1493 if ($opt{use_get_table}) {
1494 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1495 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1498 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1501 # No logical drives is OK
1502 return if !defined $result;
1504 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1507 foreach my $c (@controllers) {
1508 push @output, @{ run_omreport("storage vdisk controller=$c") };
1509 map_item('ctrl', $c, \@output);
1522 16 => 'Regenerating',
1525 32 => 'Reconstructing',
1526 35 => 'Initializing',
1527 36 => 'Background Initialization',
1528 38 => 'Resynching Paused',
1529 52 => 'Permanently Degraded',
1530 54 => 'Degraded Redundancy',
1535 1 => 'Concatenated',
1542 19 => 'Concatenated RAID-1',
1546 # Check virtual disks on each of the controllers
1548 foreach my $out (@output) {
1550 $id = $out->{virtualDiskTargetID};
1551 $dev = $out->{virtualDiskDeviceName};
1552 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state);
1553 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout);
1554 $status = $snmp_status{$out->{virtualDiskComponentStatus}};
1555 $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
1556 $progr = q{}; # can't get this from SNMP(?)
1557 $nexus = convert_nexus($out->{virtualDiskNexusID});
1558 $ctrl = $nexus; # We use the nexus id to get the controller id
1559 $ctrl =~ s{\A (\d+):\d+ \z}{$1}xms;
1563 $dev = $out->{'Device Name'};
1564 $state = $out->{State};
1565 $status = $out->{Status};
1566 $layout = $out->{Layout};
1567 $size = $out->{Size};
1568 $progr = ' [' . $out->{Progress} . ']';
1569 $size =~ s{\A (.*GB).* \z}{$1}xms;
1570 $nexus = join q{:}, $out->{ctrl}, $id;
1571 $ctrl = $out->{ctrl};
1574 next VDISK if blacklisted('vdisk', $nexus);
1577 # The device name is undefined sometimes
1578 $dev = q{} if !defined $dev;
1580 # Special case: Regenerating
1581 if ($state eq 'Regenerating') {
1582 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s%s},
1583 $id, $dev, $layout, $size, $ctrl, $state, $progr;
1584 report('storage', $msg, $E_WARNING, $nexus);
1587 elsif ($status ne 'Ok') {
1588 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d needs attention: %s},
1589 $id, $dev, $layout, $size, $ctrl, $state;
1590 report('storage', $msg, $status2nagios{$status}, $nexus);
1594 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s},
1595 $id, $dev, $layout, $size, $ctrl, $state;
1596 report('storage', $msg, $E_OK, $nexus);
1603 #-----------------------------------------
1604 # STORAGE: Check cache batteries
1605 #-----------------------------------------
1606 sub check_cache_battery {
1607 return if $#controllers == -1;
1608 return if blacklisted('bat', 'all');
1615 my $learn = undef; # learn state
1616 my $pred = undef; # battery's ability to be charged
1622 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1623 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1624 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1625 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1626 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1627 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1630 if ($opt{use_get_table}) {
1631 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1632 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1634 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1635 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1637 if (defined $result) {
1638 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1642 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1645 # No cache battery is OK
1646 return if !defined $result;
1648 @output = @{ get_snmp_output($result, \%bat_oid) };
1651 foreach my $c (@controllers) {
1652 push @output, @{ run_omreport("storage battery controller=$c") };
1653 map_item('ctrl', $c, \@output);
1663 7 => 'Reconditioning',
1671 # Specifies the learn state activity of the battery
1681 # This property displays the battery's ability to be charged
1684 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1685 2 => 'Ready', # The battery can be charged to full capacity
1686 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1687 # battery cannot be determined until the Learn cycle is complete
1690 # Check battery on each of the controllers
1692 foreach my $out (@output) {
1694 $status = $snmp_status{$out->{batteryComponentStatus}};
1695 $state = get_hashval($out->{batteryState}, \%bat_state);
1696 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state);
1697 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap);
1698 $ctrl = $out->{batteryConnectionControllerNumber} - 1;
1699 $nexus = convert_nexus($out->{batteryNexusID});
1701 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1705 $state = $out->{'State'};
1706 $status = $out->{'Status'};
1707 $learn = $out->{'Learn State'};
1708 $pred = $out->{'Predicted Capacity Status'};
1709 $ctrl = $out->{'ctrl'};
1710 $nexus = join q{:}, $out->{ctrl}, $id;
1713 next BATTERY if blacklisted('bat', $nexus);
1715 # Special case: Charging
1716 if ($state eq 'Charging') {
1717 if ($pred eq 'Failed') {
1718 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [replace battery]',
1719 $id, $ctrl, $state, $pred;
1720 report('storage', $msg, $E_CRITICAL, $nexus);
1723 next BATTERY if blacklisted('bat_charge', $nexus);
1724 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1725 $id, $ctrl, $state, $pred;
1726 report('storage', $msg, $E_WARNING, $nexus);
1729 # Special case: Learning (battery learns its capacity)
1730 elsif ($state eq 'Learning') {
1731 if ($learn eq 'Failed') {
1732 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s)',
1733 $id, $ctrl, $state, $learn;
1734 report('storage', $msg, $E_CRITICAL, $nexus);
1737 next BATTERY if blacklisted('bat_charge', $nexus);
1738 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1739 $id, $ctrl, $state, $learn;
1740 report('storage', $msg, $E_WARNING, $nexus);
1743 # Special case: Power Low (first part of recharge cycle)
1744 elsif ($state eq 'Power Low') {
1745 next BATTERY if blacklisted('bat_charge', $nexus);
1746 my $msg = sprintf 'Cache battery %d in controller %d is %s [probably harmless]',
1748 report('storage', $msg, $E_WARNING, $nexus);
1750 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1751 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1752 next BATTERY if blacklisted('bat_charge', $nexus);
1753 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1754 $id, $ctrl, $state, $status;
1755 report('storage', $msg, $E_WARNING, $nexus);
1758 elsif ($status ne 'Ok') {
1759 my $msg = sprintf 'Cache battery %d in controller %d needs attention: %s (%s)',
1760 $id, $ctrl, $state, $status;
1761 report('storage', $msg, $status2nagios{$status}, $nexus);
1765 my $msg = sprintf 'Cache battery %d in controller %d is %s',
1767 report('storage', $msg, $E_OK, $nexus);
1774 #-----------------------------------------
1775 # STORAGE: Check connectors (channels)
1776 #-----------------------------------------
1777 sub check_connectors {
1778 return if $#controllers == -1;
1779 return if blacklisted('conn', 'all');
1793 '1.3.6.1.4.1.674.10893.1.20.130.2.1.1' => 'channelNumber',
1794 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1795 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1796 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1797 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1798 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1801 if ($opt{use_get_table}) {
1802 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1803 $result = $snmp_session->get_table(-baseoid => $channelTable);
1806 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1809 if (!defined $result) {
1810 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1811 $snmp_session->close;
1815 @output = @{ get_snmp_output($result, \%conn_oid) };
1818 foreach my $c (@controllers) {
1819 push @output, @{ run_omreport("storage connector controller=$c") };
1820 map_item('ctrl', $c, \@output);
1838 3 => 'Fibre Channel',
1845 # Check connectors on each of the controllers
1847 foreach my $out (@output) {
1849 $id = $out->{channelNumber} - 1;
1850 $name = $out->{channelName};
1851 $status = $snmp_status{$out->{channelComponentStatus}};
1852 $state = get_hashval($out->{channelState}, \%conn_state);
1853 $type = get_hashval($out->{channelBusType}, \%conn_bustype);
1854 $nexus = convert_nexus($out->{channelNexusID});
1856 $ctrl =~ s{(\d+):\d+}{$1}xms;
1860 $name = $out->{'Name'};
1861 $state = $out->{'State'};
1862 $status = $out->{'Status'};
1863 $type = $out->{'Connector Type'};
1864 $ctrl = $out->{ctrl};
1865 $nexus = join q{:}, $out->{ctrl}, $id;
1868 next CHANNEL if blacklisted('conn', $nexus);
1870 my $msg = sprintf '%s [%s] on controller %d is %s',
1871 $name, $type, $ctrl, $state;
1872 report('storage', $msg, $status2nagios{$status}, $nexus);
1878 #-----------------------------------------
1879 # STORAGE: Check enclosures
1880 #-----------------------------------------
1881 sub check_enclosures {
1882 return if blacklisted('encl', 'all');
1889 my $firmware = undef;
1896 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
1897 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
1898 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
1899 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
1900 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
1901 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
1902 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
1905 if ($opt{use_get_table}) {
1906 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
1907 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
1910 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
1913 # No enclosures is OK
1914 return if !defined $result;
1916 @output = @{ get_snmp_output($result, \%encl_oid) };
1919 foreach my $c (@controllers) {
1920 push @output, @{ run_omreport("storage enclosure controller=$c") };
1921 map_item('ctrl', $c, \@output);
1936 foreach my $out (@output) {
1938 $id = $out->{enclosureNumber} - 1;
1939 $name = $out->{enclosureName};
1940 $state = get_hashval($out->{enclosureState}, \%encl_state);
1941 $status = $snmp_status{$out->{enclosureComponentStatus}};
1942 $firmware = exists $out->{enclosureFirmwareVersion}
1943 ? $out->{enclosureFirmwareVersion} : 'N/A';
1944 $nexus = convert_nexus($out->{enclosureNexusID});
1946 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
1950 $name = $out->{Name};
1951 $state = $out->{State};
1952 $status = $out->{Status};
1953 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1954 ? $out->{'Firmware Version'} : 'N/A';
1955 $nexus = join q{:}, $out->{ctrl}, $id;
1956 $ctrl = $out->{ctrl};
1959 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1960 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
1962 # store enclosure data for future use
1963 push @enclosures, { 'id' => $id,
1964 'ctrl' => $out->{ctrl},
1967 # Collecting some storage info
1968 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
1969 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
1970 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
1972 next ENCLOSURE if blacklisted('encl', $nexus);
1974 my $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
1975 $nexus, $name, $ctrl, $state;
1976 report('storage', $msg, $status2nagios{$status}, $nexus);
1982 #-----------------------------------------
1983 # STORAGE: Check enclosure fans
1984 #-----------------------------------------
1985 sub check_enclosure_fans {
1986 return if $#controllers == -1;
1987 return if blacklisted('encl_fan', 'all');
1995 my $encl_id = undef;
1996 my $encl_name = undef;
2002 '1.3.6.1.4.1.674.10893.1.20.130.7.1.1' => 'fanNumber',
2003 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2004 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2005 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2006 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2007 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2008 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2009 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2012 if ($opt{use_get_table}) {
2013 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2014 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2016 $result = $snmp_session->get_table(-baseoid => $fanTable);
2017 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2019 if (defined $result) {
2020 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2024 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2027 # No enclosure fans is OK
2028 return if !defined $result;
2030 @output = @{ get_snmp_output($result, \%fan_oid) };
2033 foreach my $enc (@enclosures) {
2034 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2035 map_item('ctrl', $enc->{ctrl}, \@output);
2036 map_item('encl_id', $enc->{id}, \@output);
2037 map_item('encl_name', $enc->{name}, \@output);
2052 # Check fans on each of the enclosures
2054 foreach my $out (@output) {
2056 $id = $out->{fanNumber} - 1;
2057 $name = $out->{fanName};
2058 $state = get_hashval($out->{fanState}, \%fan_state);
2059 $status = $snmp_status{$out->{fanComponentStatus}};
2060 $speed = $out->{fanProbeCurrValue};
2061 $encl_id = $out->{fanConnectionEnclosureNumber} - 1;
2062 $encl_name = $out->{fanConnectionEnclosureName};
2063 $nexus = convert_nexus($out->{fanNexusID});
2067 $name = $out->{'Name'};
2068 $state = $out->{'State'};
2069 $status = $out->{'Status'};
2070 $speed = $out->{'Speed'};
2071 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2072 $encl_name = $out->{encl_name};
2073 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2076 next FAN if blacklisted('encl_fan', $nexus);
2079 if ($status ne 'Ok') {
2080 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2081 $name, $encl_id, $encl_name, $state;
2082 report('storage', $msg, $status2nagios{$status}, $nexus);
2086 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2087 $name, $encl_id, $encl_name, $state, $speed;
2088 report('storage', $msg, $E_OK, $nexus);
2095 #-----------------------------------------
2096 # STORAGE: Check enclosure power supplies
2097 #-----------------------------------------
2098 sub check_enclosure_pwr {
2099 return if $#controllers == -1;
2100 return if blacklisted('encl_ps', 'all');
2107 my $encl_id = undef;
2108 my $encl_name = undef;
2114 '1.3.6.1.4.1.674.10893.1.20.130.9.1.1' => 'powerSupplyNumber',
2115 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2116 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2117 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2118 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2119 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2120 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2123 if ($opt{use_get_table}) {
2124 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2125 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2127 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2128 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2130 if (defined $result) {
2131 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2135 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2138 # No enclosure power supplies is OK
2139 return if !defined $result;
2141 @output = @{ get_snmp_output($result, \%ps_oid) };
2144 foreach my $enc (@enclosures) {
2145 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2146 map_item('ctrl', $enc->{ctrl}, \@output);
2147 map_item('encl_id', $enc->{id}, \@output);
2148 map_item('encl_name', $enc->{name}, \@output);
2157 5 => 'Not Installed',
2163 # Check power supplies on each of the enclosures
2165 foreach my $out (@output) {
2167 $id = $out->{powerSupplyNumber};
2168 $name = $out->{powerSupplyName};
2169 $state = get_hashval($out->{powerSupplyState}, \%ps_state);
2170 $status = $snmp_status{$out->{powerSupplyComponentStatus}};
2171 $encl_id = $out->{powerSupplyConnectionEnclosureNumber} - 1;
2172 $encl_name = $out->{powerSupplyConnectionEnclosureName};
2173 $nexus = convert_nexus($out->{powerSupplyNexusID});
2177 $name = $out->{'Name'};
2178 $state = $out->{'State'};
2179 $status = $out->{'Status'};
2180 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2181 $encl_name = $out->{encl_name};
2182 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2185 next PS if blacklisted('encl_ps', $nexus);
2188 if ($status ne 'Ok') {
2189 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2190 $name, $encl_id, $encl_name, $state;
2191 report('storage', $msg, $status2nagios{$status}, $nexus);
2195 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2196 $name, $encl_id, $encl_name, $state;
2197 report('storage', $msg, $E_OK, $nexus);
2204 #-----------------------------------------
2205 # STORAGE: Check enclosure temperatures
2206 #-----------------------------------------
2207 sub check_enclosure_temp {
2208 return if $#controllers == -1;
2209 return if blacklisted('encl_temp', 'all');
2216 my $reading = undef;
2218 my $max_warn = undef;
2219 my $max_crit = undef;
2220 my $encl_id = undef;
2221 my $encl_name = undef;
2227 '1.3.6.1.4.1.674.10893.1.20.130.11.1.1' => 'temperatureProbeNumber',
2228 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2229 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2230 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2231 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2232 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2233 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2234 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2235 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2236 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2237 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2240 if ($opt{use_get_table}) {
2241 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2242 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2244 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2245 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2247 if (defined $result) {
2248 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2252 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2255 # No enclosure temperature probes is OK
2256 return if !defined $result;
2258 @output = @{ get_snmp_output($result, \%temp_oid) };
2261 foreach my $enc (@enclosures) {
2262 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2263 map_item('ctrl', $enc->{ctrl}, \@output);
2264 map_item('encl_id', $enc->{id}, \@output);
2265 map_item('encl_name', $enc->{name}, \@output);
2280 # Check temperature probes on each of the enclosures
2282 foreach my $out (@output) {
2284 $id = $out->{temperatureProbeNumber} - 1;
2285 $name = $out->{temperatureProbeName};
2286 $state = get_hashval($out->{temperatureProbeState}, \%temp_state);
2287 $status = $snmp_status{$out->{temperatureProbeComponentStatus}};
2288 $unit = $out->{temperatureProbeUnit};
2289 $reading = $out->{temperatureProbeCurValue};
2290 $max_warn = $out->{temperatureProbeMaxWarning};
2291 $max_crit = $out->{temperatureProbeMaxCritical};
2292 $encl_id = $out->{temperatureConnectionEnclosureNumber} - 1;
2293 $encl_name = $out->{temperatureConnectionEnclosureName};
2294 $nexus = convert_nexus($out->{temperatureProbeNexusID});
2298 $name = $out->{'Name'};
2299 $state = $out->{'State'};
2300 $status = $out->{'Status'};
2302 $reading = $out->{'Reading'}; $reading =~ s{\s*C}{}xms;
2303 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\s*C}{}xms;
2304 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\s*C}{}xms;
2305 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2306 $encl_name = $out->{encl_name};
2307 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2310 next TEMP if blacklisted('encl_temp', $nexus);
2313 if ($status ne 'Ok') {
2314 my $msg = sprintf '%s in enclosure %s [%s] is %s C at %s (%s max)',
2315 $name, $encl_id, $encl_name, $state, $reading, $max_crit;
2316 report('storage', $msg, $status2nagios{$status}, $nexus);
2320 my $msg = sprintf '%s in enclosure %s [%s]: %s C (%s max)',
2321 $name, $encl_id, $encl_name, $reading, $max_crit;
2322 report('storage', $msg, $E_OK, $nexus);
2325 # Collect performance data
2326 if (defined $opt{perfdata}) {
2327 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2328 my $label = "enclosure_${encl_id}_${name}";
2330 $mini =~ s{enclosure_(.+?)_temp_(.+?)}{e$1t$2}xms;
2344 #-----------------------------------------
2345 # STORAGE: Check enclosure management modules (EMM)
2346 #-----------------------------------------
2347 sub check_enclosure_emms {
2348 return if $#controllers == -1;
2349 return if blacklisted('encl_emm', 'all');
2356 my $encl_id = undef;
2357 my $encl_name = undef;
2363 '1.3.6.1.4.1.674.10893.1.20.130.13.1.1' => 'enclosureManagementModuleNumber',
2364 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2365 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2366 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2367 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2368 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2369 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2372 if ($opt{use_get_table}) {
2373 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2374 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2376 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2377 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2379 if (defined $result) {
2380 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2384 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2387 # No enclosure EMMs is OK
2388 return if !defined $result;
2390 @output = @{ get_snmp_output($result, \%emms_oid) };
2393 foreach my $enc (@enclosures) {
2394 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2395 map_item('ctrl', $enc->{ctrl}, \@output);
2396 map_item('encl_id', $enc->{id}, \@output);
2397 map_item('encl_name', $enc->{name}, \@output);
2408 5 => 'Not Installed',
2413 # Check temperature probes on each of the enclosures
2415 foreach my $out (@output) {
2417 $id = $out->{enclosureManagementModuleNumber} - 1;
2418 $name = $out->{enclosureManagementModuleName};
2419 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state);
2420 $status = $snmp_status{$out->{enclosureManagementModuleComponentStatus}};
2421 $encl_id = $out->{enclosureManagementModuleConnectionEnclosureNumber} - 1;
2422 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
2423 $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
2427 $name = $out->{'Name'};
2428 $state = $out->{'State'};
2429 $status = $out->{'Status'};
2430 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2431 $encl_name = $out->{encl_name};
2432 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2435 next EMM if blacklisted('encl_emm', $nexus);
2438 if ($status ne 'Ok') {
2439 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2440 $name, $encl_id, $encl_name, $state;
2441 report('storage', $msg, $status2nagios{$status}, $nexus);
2445 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2446 $name, $encl_id, $encl_name, $state;
2447 report('storage', $msg, $E_OK, $nexus);
2454 #-----------------------------------------
2455 # CHASSIS: Check memory modules
2456 #-----------------------------------------
2458 return if blacklisted('dimm', 'all');
2462 my $location = undef;
2471 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2472 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2473 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2474 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2475 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2478 if ($opt{use_get_table}) {
2479 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2480 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2483 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2486 if (!defined $result) {
2487 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2488 $snmp_session->close;
2492 @output = @{ get_snmp_output($result, \%dimm_oid) };
2495 @output = @{ run_omreport("$omopt_chassis memory") };
2498 # Note: These values are bit masks, so combination values are
2499 # possible. If value is 0 (zero), memory device has no faults.
2502 1 => 'ECC single bit correction warning rate exceeded',
2503 2 => 'ECC single bit correction failure rate exceeded',
2504 4 => 'ECC multibit fault encountered',
2505 8 => 'ECC single bit correction logging disabled',
2506 16 => 'device disabled because of spare activation',
2510 foreach my $out (@output) {
2511 @failures = (); # Initialize
2513 $index = $out->{memoryDeviceIndex};
2514 $status = $snmp_status{$out->{memoryDeviceStatus}};
2515 $location = $out->{memoryDeviceLocationName};
2516 $size = sprintf '%d MB', $out->{memoryDeviceSize}/1024;
2517 $modes = $out->{memoryDeviceFailureModes};
2519 foreach my $mask (sort keys %failure_mode) {
2520 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2525 $index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
2526 $status = $out->{'Status'};
2527 $location = $out->{'Connector Name'};
2528 $size = $out->{'Size'};
2529 if (defined $size) {
2530 $size =~ s{\s\s}{ }gxms;
2532 # Run 'omreport chassis memory index=X' to get the failures
2533 if ($status ne 'Ok' && defined $index) {
2534 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2535 if (m/\A Failures; (.+?) \z/xms) {
2536 chop(my $fail = $1);
2537 push @failures, split m{\.}xms, $fail;
2542 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2544 next DIMM if blacklisted('dimm', $index);
2546 # Ignore empty memory slots
2547 next DIMM if !defined $index;
2550 if ($status ne 'Ok') {
2552 if (scalar @failures == 0) {
2553 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2554 $index, $location, $size, $status;
2557 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2558 $index, $location, $size, (join q{, }, @failures);
2561 report('chassis', $msg, $status2nagios{$status}, $index);
2565 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2566 $index, $location, $size, $status;
2567 report('chassis', $msg, $E_OK, $index);
2574 #-----------------------------------------
2575 # CHASSIS: Check fans
2576 #-----------------------------------------
2578 return if blacklisted('fan', 'all');
2582 my $reading = undef;
2583 my $location = undef;
2584 my $max_crit = undef;
2585 my $max_warn = undef;
2591 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2592 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2593 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2594 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2595 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2596 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2599 if ($opt{use_get_table}) {
2600 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2601 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2604 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2607 if ($blade && !defined $result) {
2610 elsif (!$blade && !defined $result) {
2611 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2612 $snmp_session->close;
2616 @output = @{ get_snmp_output($result, \%cool_oid) };
2619 @output = @{ run_omreport("$omopt_chassis fans") };
2623 foreach my $out (@output) {
2625 $index = $out->{coolingDeviceIndex};
2626 $status = $snmp_probestatus{$out->{coolingDeviceStatus}};
2627 $reading = $out->{coolingDeviceReading};
2628 $location = $out->{coolingDeviceLocationName};
2629 $max_crit = exists $out->{coolingDeviceUpperCriticalThreshold}
2630 ? $out->{coolingDeviceUpperCriticalThreshold} : 0;
2631 $max_warn = exists $out->{coolingDeviceUpperNonCriticalThreshold}
2632 ? $out->{coolingDeviceUpperNonCriticalThreshold} : 0;
2635 $index = $out->{'Index'};
2636 $status = $out->{'Status'};
2637 $reading = $out->{'Reading'};
2638 $location = $out->{'Probe Name'};
2639 $max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
2640 ? $out->{'Maximum Failure Threshold'} : 0;
2641 $max_warn = $out->{'Maximum Warning Threshold'} ne '[N/A]'
2642 ? $out->{'Maximum Warning Threshold'} : 0;
2643 $reading =~ s{\A (\d+).* \z}{$1}xms;
2644 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2645 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2648 next FAN if blacklisted('fan', $index);
2651 if ($status ne 'Ok') {
2652 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2653 $index, $location, $status;
2654 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2655 report('chassis', $msg, $err, $index);
2658 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2659 $index, $location, $reading;
2660 report('chassis', $msg, $E_OK, $index);
2663 # Collect performance data
2664 if (defined $opt{perfdata}) {
2665 my $pname = lc $location;
2666 $pname =~ s{\s}{_}gxms;
2667 $pname =~ s{proc_}{cpu#}xms;
2669 label => "fan_${index}_${pname}",
2681 #-----------------------------------------
2682 # CHASSIS: Check power supplies
2683 #-----------------------------------------
2684 sub check_powersupplies {
2685 return if blacklisted('ps', 'all');
2690 my $err_type = undef;
2698 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2699 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2700 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2701 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2702 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2705 if ($opt{use_get_table}) {
2706 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2707 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2710 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2713 # No instrumented PSU is OK (blades, low-end servers)
2714 return 0 if !defined $result;
2716 @output = @{ get_snmp_output($result, \%ps_oid) };
2719 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2729 6 => 'Uninterruptible Power Supply',
2739 1 => 'Presence detected',
2740 2 => 'Failure detected',
2741 4 => 'Predictive Failure',
2743 16 => 'AC lost or out-of-range',
2744 32 => 'AC out-of-range but present',
2745 64 => 'Configuration error',
2748 my %ps_config_error_type
2750 1 => 'Vendor mismatch',
2751 2 => 'Revision mismatch',
2752 3 => 'Processor missing',
2756 foreach my $out (@output) {
2758 @states = (); # contains states for the PS
2760 $index = $out->{powerSupplyIndex} - 1;
2761 $status = $snmp_status{$out->{powerSupplyStatus}};
2762 $type = get_hashval($out->{powerSupplyType}, \%ps_type);
2763 $err_type = defined $out->{powerSupplyConfigurationErrorType}
2764 ? $ps_config_error_type{$out->{powerSupplyConfigurationErrorType}} : undef;
2766 # get the combined state from the StatusReading OID
2767 foreach my $mask (sort keys %ps_state) {
2768 if (($out->{powerSupplySensorState} & $mask) != 0) {
2769 push @states, $ps_state{$mask};
2773 # If configuration error, also include the error type
2774 if (defined $err_type) {
2775 push @states, $err_type;
2778 # Finally, construct the state string
2779 $state = join q{, }, @states;
2782 $index = $out->{'Index'};
2783 $status = $out->{'Status'};
2784 $type = $out->{'Type'};
2785 $state = $out->{'Online Status'};
2788 next PS if blacklisted('ps', $index);
2791 if ($status ne 'Ok') {
2792 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2793 $index, $type, $state;
2794 report('chassis', $msg, $status2nagios{$status}, $index);
2797 my $msg = sprintf 'Power Supply %d [%s]: %s',
2798 $index, $type, $state;
2799 report('chassis', $msg, $E_OK, $index);
2806 #-----------------------------------------
2807 # CHASSIS: Check temperatures
2808 #-----------------------------------------
2809 sub check_temperatures {
2810 return if blacklisted('temp', 'all');
2814 my $reading = undef;
2815 my $location = undef;
2816 my $max_crit = undef;
2817 my $max_warn = undef;
2818 my $min_warn = undef;
2819 my $min_crit = undef;
2821 my $discrete = undef;
2824 # Getting custom temperature thresholds (user option)
2825 my %warn_threshold = %{ custom_temperature_thresholds('w') };
2826 my %crit_threshold = %{ custom_temperature_thresholds('c') };
2831 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
2832 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
2833 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
2834 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
2835 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
2836 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
2837 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
2838 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
2839 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
2840 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
2842 # this didn't work well for some reason
2843 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2845 # Getting values using the table
2846 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
2847 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2849 if (!defined $result) {
2850 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
2851 $snmp_session->close;
2855 @output = @{ get_snmp_output($result, \%temp_oid) };
2858 @output = @{ run_omreport("$omopt_chassis temps") };
2863 1 => 'Other', # type is other than following values
2864 2 => 'Unknown', # type is unknown
2865 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
2866 16 => 'Discrete', # type is temperature probe with discrete reading
2870 foreach my $out (@output) {
2872 $index = $out->{temperatureProbeIndex} - 1;
2873 $status = $snmp_probestatus{$out->{temperatureProbeStatus}};
2874 $location = $out->{temperatureProbeLocationName};
2875 $reading = exists $out->{temperatureProbeReading}
2876 ? $out->{temperatureProbeReading} / 10 : '[N/A]';
2877 $max_crit = exists $out->{temperatureProbeUpperCriticalThreshold}
2878 ? $out->{temperatureProbeUpperCriticalThreshold} / 10 : '[N/A]';
2879 $max_warn = exists $out->{temperatureProbeUpperNonCriticalThreshold}
2880 ? $out->{temperatureProbeUpperNonCriticalThreshold} / 10 : '[N/A]';
2881 $min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
2882 ? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
2883 $min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
2884 ? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
2885 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
2886 $discrete = exists $out->{temperatureProbeDiscreteReading}
2887 ? $out->{temperatureProbeDiscreteReading} : '[N/A]';
2888 # workaround for bad temp probes
2889 if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
2894 $index = $out->{'Index'};
2895 $status = $out->{'Status'};
2896 $reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
2897 $location = $out->{'Probe Name'};
2898 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
2899 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\.0\s+C}{}xms;
2900 $min_crit = $out->{'Minimum Failure Threshold'}; $min_crit =~ s{\.0\s+C}{}xms;
2901 $min_warn = $out->{'Minimum Warning Threshold'}; $min_warn =~ s{\.0\s+C}{}xms;
2902 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
2903 $discrete = $reading;
2906 next TEMP if blacklisted('temp', $index);
2909 if ($type eq 'Discrete') {
2910 my $msg = sprintf 'Temperature probe %d [%s] is %s',
2911 $index, $location, $discrete;
2912 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2913 report('chassis', $msg, $err, $index);
2916 # First check according to custom thresholds
2917 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
2918 # Custom critical MAX
2919 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2920 $index, $location, $reading, $crit_threshold{$index}{max};
2921 report('chassis', $msg, $E_CRITICAL, $index);
2923 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
2924 # Custom warning MAX
2925 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2926 $index, $location, $reading, $warn_threshold{$index}{max};
2927 report('chassis', $msg, $E_WARNING, $index);
2929 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
2930 # Custom critical MIN
2931 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2932 $index, $location, $reading, $crit_threshold{$index}{min};
2933 report('chassis', $msg, $E_CRITICAL, $index);
2935 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
2936 # Custom warning MIN
2937 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2938 $index, $location, $reading, $warn_threshold{$index}{min};
2939 report('chassis', $msg, $E_WARNING, $index);
2941 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2942 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
2943 $index, $location, $reading;
2944 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2945 report('chassis', $msg, $err, $index);
2947 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2948 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
2949 $index, $location, $reading;
2950 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2951 report('chassis', $msg, $err, $index);
2953 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2954 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
2955 $index, $location, $reading;
2956 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2957 report('chassis', $msg, $err, $index);
2959 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2960 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
2961 $index, $location, $reading;
2962 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2963 report('chassis', $msg, $err, $index);
2967 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
2968 $index, $location, $reading;
2969 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
2970 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2973 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2974 $min_warn, $min_crit, $max_warn, $max_crit;
2976 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2977 report('chassis', $msg, $err, $index);
2980 # Collect performance data
2981 if (defined $opt{perfdata}) {
2982 my $pname = lc $location;
2983 $pname =~ s{\s}{_}gxms;
2984 $pname =~ s{_temp\z}{}xms;
2985 $pname =~ s{proc_}{cpu#}xms;
2987 label => "temp_${index}_${pname}",
3000 #-----------------------------------------
3001 # CHASSIS: Check processors
3002 #-----------------------------------------
3003 sub check_processors {
3004 return if blacklisted('cpu', 'all');
3017 # NOTE: For some reason, older models don't have the
3018 # "Processor Device Status" OIDs. We check both the newer
3019 # (preferred) OIDs and the old ones.
3023 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3024 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3025 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3026 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3027 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3028 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3029 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3030 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3031 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3032 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3035 if ($opt{use_get_table}) {
3036 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3037 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3039 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3040 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3042 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3045 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3048 if (!defined $result) {
3049 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3050 $snmp_session->close;
3054 @output = @{ get_snmp_output($result, \%cpu_oid) };
3057 @output = @{ run_omreport("$omopt_chassis processors") };
3062 1 => 'Other', # other than following values
3063 2 => 'Unknown', # unknown
3064 3 => 'Enabled', # enabled
3065 4 => 'User Disabled', # disabled by user via BIOS setup
3066 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3072 1 => 'Internal Error', # Internal Error
3073 2 => 'Thermal Trip', # Thermal Trip
3074 32 => 'Configuration Error', # Configuration Error
3075 128 => 'Present', # Processor Present
3076 256 => 'Disabled', # Processor Disabled
3077 512 => 'Terminator Present', # Terminator Present
3078 1024 => 'Throttled', # Processor Throttled
3081 # Mapping between family numbers from SNMP and actual CPU family
3084 1 => 'Other', 2 => 'Unknown',
3085 3 => '8086', 4 => '80286',
3086 5 => '386', 6 => '486',
3087 7 => '8087', 8 => '80287',
3088 9 => '80387', 10 => '80487',
3089 11 => 'Pentium', 12 => 'Pentium Pro',
3090 13 => 'Pentium II', 14 => 'Pentium with MMX',
3091 15 => 'Celeron', 16 => 'Pentium II Xeon',
3092 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3093 19 => 'Pentium III', 20 => 'Itanium',
3094 21 => 'Xeon', 22 => 'Pentium 4',
3095 23 => 'Xeon MP', 24 => 'Itanium 2',
3096 25 => 'K5', 26 => 'K6',
3097 27 => 'K6-2', 28 => 'K6-3',
3098 29 => 'Athlon', 30 => 'AMD2900',
3099 31 => 'K6-2+', 32 => 'Power PC',
3100 33 => 'Power PC 601', 34 => 'Power PC 603',
3101 35 => 'Power PC 603+', 36 => 'Power PC 604',
3102 37 => 'Power PC 620', 38 => 'Power PC x704',
3103 39 => 'Power PC 750', 40 => 'Core Duo',
3104 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3105 43 => 'Intel Atom', 44 => undef,
3106 45 => undef, 46 => undef,
3107 47 => undef, 48 => 'Alpha',
3108 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3109 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3110 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3111 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3112 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3113 59 => 'Opteron 6100', 60 => undef,
3114 61 => undef, 62 => undef,
3115 63 => undef, 64 => 'MIPS',
3116 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3117 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3118 69 => 'MIPS R10000', 70 => undef,
3119 71 => undef, 72 => undef,
3120 73 => undef, 74 => undef,
3121 75 => undef, 76 => undef,
3122 77 => undef, 78 => undef,
3123 79 => undef, 80 => 'SPARC',
3124 81 => 'SuperSPARC', 82 => 'microSPARC II',
3125 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3126 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3127 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3128 89 => undef, 90 => undef,
3129 91 => undef, 92 => undef,
3130 93 => undef, 94 => undef,
3131 95 => undef, 96 => '68040',
3132 97 => '68xxx', 98 => '68000',
3133 99 => '68010', 100 => '68020',
3134 101 => '68030', 102 => undef,
3135 103 => undef, 104 => undef,
3136 105 => undef, 106 => undef,
3137 107 => undef, 108 => undef,
3138 109 => undef, 110 => undef,
3139 111 => undef, 112 => 'Hobbit',
3140 113 => undef, 114 => undef,
3141 115 => undef, 116 => undef,
3142 117 => undef, 118 => undef,
3143 119 => undef, 120 => 'Crusoe TM5000',
3144 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3145 123 => undef, 124 => undef,
3146 125 => undef, 126 => undef,
3147 127 => undef, 128 => 'Weitek',
3148 129 => undef, 130 => 'Celeron M',
3149 131 => 'Athlon 64', 132 => 'Opteron',
3150 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3151 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3152 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3153 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3154 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3155 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3156 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3157 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3158 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3159 151 => undef, 152 => undef,
3160 153 => undef, 154 => undef,
3161 155 => undef, 156 => undef,
3162 157 => undef, 158 => undef,
3163 159 => undef, 160 => 'V30',
3164 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3165 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3166 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3167 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3168 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3169 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3170 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3171 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3172 177 => 'M2', 178 => undef,
3173 179 => 'Pentium 4 HT', 180 => 'AS400',
3174 181 => undef, 182 => 'Athlon XP',
3175 183 => 'Athlon MP', 184 => 'Duron',
3176 185 => 'Pentium M', 186 => 'Celeron D',
3177 187 => 'Pentium D', 188 => 'Pentium Extreme',
3178 189 => 'Core Solo', 190 => 'Core2',
3179 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3180 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3181 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3182 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3183 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3184 201 => 'G4', 202 => 'G5',
3185 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3186 205 => 'Core i5', 206 => undef,
3187 207 => undef, 208 => undef,
3188 209 => undef, 210 => 'C7-M',
3189 211 => 'C7-D', 212 => 'C7',
3190 213 => 'Eden', 214 => 'Multi-Core Xeon',
3191 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3192 217 => undef, 218 => 'Dual-Core Xeon 5xxx',
3193 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3194 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3195 223 => 'Multi-Core Xeon 7xxx', 224 => undef,
3196 225 => undef, 226 => undef,
3197 227 => undef, 228 => undef,
3198 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3199 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3200 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3201 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3202 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3203 239 => 'AMD Sempron M', 240 => undef,
3204 241 => undef, 242 => undef,
3205 243 => undef, 244 => undef,
3206 245 => undef, 246 => undef,
3207 247 => undef, 248 => undef,
3208 249 => undef, 250 => 'i860',
3213 foreach my $out (@output) {
3215 $index = exists $out->{processorDeviceStatusIndex}
3216 ? $out->{processorDeviceStatusIndex} - 1
3217 : $out->{processorDeviceIndex} - 1;
3218 $status = exists $out->{processorDeviceStatusStatus}
3219 ? $snmp_status{$out->{processorDeviceStatusStatus}}
3220 : $snmp_status{$out->{processorDeviceStatus}};
3221 if (exists $out->{processorDeviceStatusReading}) {
3222 my @states = (); # contains states for the CPU
3224 # get the combined state from the StatusReading OID
3225 foreach my $mask (sort keys %cpu_reading) {
3226 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3227 push @states, $cpu_reading{$mask};
3231 # Finally, create the state string
3232 $state = join q{, }, @states;
3235 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state);
3237 $man = $out->{processorDeviceManufacturerName};
3238 $family = (exists $out->{processorDeviceFamily}
3239 and exists $cpu_family{$out->{processorDeviceFamily}})
3240 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3241 $speed = $out->{processorDeviceCurrentSpeed};
3242 $brand = $out->{processorDeviceBrandName};
3245 $index = $out->{'Index'};
3246 $status = $out->{'Status'};
3247 $state = $out->{'State'};
3248 $brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
3249 $family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
3250 $man = exists $out->{'Processor Manufacturer'} ? $out->{'Processor Manufacturer'} : undef;
3251 $speed = exists $out->{'Current Speed'} ? $out->{'Current Speed'} : undef;
3254 next CPU if blacklisted('cpu', $index);
3256 # Ignore unoccupied CPU slots (omreport)
3257 next CPU if (defined $out->{'Processor Manufacturer'}
3258 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3259 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3261 # Ignore unoccupied CPU slots (snmp)
3262 if ($snmp and exists $out->{processorDeviceStatusReading}
3263 and $out->{processorDeviceStatusReading} == 0) {
3269 if (defined $brand) {
3270 $brand =~ s{\s\s+}{ }gxms;
3271 $brand =~ s{\((R|tm)\)}{}gxms;
3272 $brand =~ s{\s(CPU|Processor)}{}xms;
3273 $brand =~ s{\s\@}{}xms;
3275 elsif (defined $family and defined $man and defined $speed) {
3276 $speed =~ s{\A (\d+) .*}{$1}xms;
3277 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3284 if ($status ne 'Ok') {
3285 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3286 $index, $brand, $state;
3287 report('chassis', $msg, $status2nagios{$status}, $index);
3291 my $msg = sprintf 'Processor %d [%s] is %s',
3292 $index, $brand, $state;
3293 report('chassis', $msg, $E_OK, $index);
3300 #-----------------------------------------
3301 # CHASSIS: Check voltage probes
3302 #-----------------------------------------
3304 return if blacklisted('volt', 'all');
3308 my $reading = undef;
3309 my $location = undef;
3315 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3316 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3317 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3318 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3319 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3322 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3323 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3325 if (!defined $result) {
3326 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3327 $snmp_session->close;
3331 @output = @{ get_snmp_output($result, \%volt_oid) };
3334 @output = @{ run_omreport("$omopt_chassis volts") };
3337 my %volt_discrete_reading
3344 foreach my $out (@output) {
3346 $index = $out->{voltageProbeIndex} - 1;
3347 $status = $snmp_probestatus{$out->{voltageProbeStatus}};
3348 $reading = exists $out->{voltageProbeReading}
3349 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3350 : get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading);
3351 $location = $out->{voltageProbeLocationName};
3354 $index = $out->{'Index'};
3355 $status = $out->{'Status'};
3356 $reading = $out->{'Reading'};
3357 $location = $out->{'Probe Name'};
3360 next VOLT if blacklisted('volt', $index);
3363 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3364 $index, $location, $reading;
3365 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3366 report('chassis', $msg, $err, $index);
3372 #-----------------------------------------
3373 # CHASSIS: Check batteries
3374 #-----------------------------------------
3375 sub check_batteries {
3376 return if blacklisted('bp', 'all');
3380 my $reading = undef;
3381 my $location = undef;
3387 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3388 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3389 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3390 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3393 if ($opt{use_get_table}) {
3394 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3395 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3398 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3401 # No batteries is OK
3402 return 0 if !defined $result;
3404 @output = @{ get_snmp_output($result, \%bat_oid) };
3407 @output = @{ run_omreport("$omopt_chassis batteries") };
3412 1 => 'Predictive Failure',
3414 4 => 'Presence Detected',
3418 foreach my $out (@output) {
3420 $index = $out->{batteryIndex} - 1;
3421 $status = $snmp_status{$out->{batteryStatus}};
3422 $reading = get_hashval($out->{batteryReading}, \%bat_reading);
3423 $location = $out->{batteryLocationName};
3426 $index = $out->{'Index'};
3427 $status = $out->{'Status'};
3428 $reading = $out->{'Reading'};
3429 $location = $out->{'Probe Name'};
3432 next BATTERY if blacklisted('bp', $index);
3435 my $msg = sprintf 'Battery probe %d [%s] is %s',
3436 $index, $location, $reading;
3437 report('chassis', $msg, $status2nagios{$status}, $index);
3443 #-----------------------------------------
3444 # CHASSIS: Check amperage probes (power monitoring)
3445 #-----------------------------------------
3446 sub check_pwrmonitoring {
3447 return if blacklisted('amp', 'all');
3451 my $reading = undef;
3452 my $location = undef;
3453 my $max_crit = undef;
3454 my $max_warn = undef;
3462 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3463 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3464 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3465 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3466 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3467 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3468 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3469 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3472 if ($opt{use_get_table}) {
3473 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3474 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3477 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3480 # No pwrmonitoring is OK
3481 return 0 if !defined $result;
3483 @output = @{ get_snmp_output($result, \%amp_oid) };
3486 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3489 my %amp_type # Amperage probe types
3491 1 => 'amperageProbeTypeIsOther', # other than following values
3492 2 => 'amperageProbeTypeIsUnknown', # unknown
3493 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3494 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3495 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3496 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3497 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3498 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3499 9 => 'amperageProbeTypeIsIO', # I/O probe
3500 10 => 'amperageProbeTypeIsCore', # Core probe
3501 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3502 12 => 'amperageProbeTypeIsBattery', # Battery probe
3503 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3504 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3505 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3506 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3507 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3508 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3509 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3510 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3521 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3522 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3523 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3524 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3525 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3529 foreach my $out (@output) {
3531 $index = $out->{amperageProbeIndex} - 1;
3532 $status = $snmp_status{$out->{amperageProbeStatus}};
3533 $type = get_hashval($out->{amperageProbeType}, \%amp_type);
3534 $reading = $type eq 'amperageProbeTypeIsDiscrete'
3535 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3536 : $out->{amperageProbeReading};
3537 $location = $out->{amperageProbeLocationName};
3538 $max_crit = exists $out->{amperageProbeUpperCriticalThreshold}
3539 ? $out->{amperageProbeUpperCriticalThreshold} : 0;
3540 $max_warn = exists $out->{amperageProbeUpperNonCriticalThreshold}
3541 ? $out->{amperageProbeUpperNonCriticalThreshold} : 0;
3542 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3543 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3545 # workaround for broken probes
3546 if (!defined $reading) {
3547 $type = 'amperageProbeTypeIsDiscrete';
3552 # calculate proper values and set unit for ampere probes
3553 if ($unit eq 'hA' and $type ne 'amperageProbeTypeIsDiscrete') {
3561 $index = $out->{'Index'};
3562 next AMP if (!defined $index || $index !~ m/^\d+$/x);
3563 $status = $out->{'Status'};
3564 $reading = $out->{'Reading'};
3565 $location = $out->{'Probe Name'};
3566 $max_crit = $out->{'Failure Threshold'} ne '[N/A]'
3567 ? $out->{'Failure Threshold'} : 0;
3568 $max_warn = $out->{'Warning Threshold'} ne '[N/A]'
3569 ? $out->{'Warning Threshold'} : 0;
3570 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3572 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3573 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3576 next AMP if blacklisted('amp', $index);
3577 next AMP if $index !~ m{\A \d+ \z}xms;
3580 if ($type eq 'amperageProbeTypeIsDiscrete') {
3581 my $msg = sprintf 'Amperage probe %d [%s] is %s',
3582 $index, $location, $reading;
3583 report('chassis', $msg, $status2nagios{$status}, $index);
3586 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3587 $index, $location, $reading, $unit;
3588 report('chassis', $msg, $status2nagios{$status}, $index);
3591 # Collect performance data
3592 if (defined $opt{perfdata}) {
3593 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3594 #next AMP if $type eq 'amperageProbeTypeIsDiscrete';
3595 my $label = join q{_}, 'pwr_mon', $index, lc $location;
3596 $label =~ s{\s}{_}gxms;
3599 mini => "p${index}" . lc $unit,
3607 # Collect EXTRA performance data not found at first run. This is a
3609 if (defined $opt{perfdata} && !$snmp) {
3615 foreach (@perfdata) {
3616 if ($_->{label} =~ m/\A pwr_mon_(\d+)/xms) {
3622 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3624 if ($line eq 'Location;Reading') {
3632 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s [AW] \z/xms) {
3635 $aname =~ s{\s}{_}gxms;
3637 # don't use an existing index
3638 while (exists $used{$index}) { ++$index; }
3641 label => "pwr_mon_${index}_${aname}",
3642 mini => "p${index}a",
3656 #-----------------------------------------
3657 # CHASSIS: Check intrusion
3658 #-----------------------------------------
3659 sub check_intrusion {
3660 return if blacklisted('intr', 'all');
3664 my $reading = undef;
3670 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3671 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3672 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3675 if ($opt{use_get_table}) {
3676 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3677 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3680 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3683 # No intrusion is OK
3684 return 0 if !defined $result;
3686 @output = @{ get_snmp_output($result, \%int_oid) };
3689 @output = @{ run_omreport("$omopt_chassis intrusion") };
3694 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3695 2 => 'Breached', # chassis currently breached
3696 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3697 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3701 foreach my $out (@output) {
3703 $index = $out->{intrusionIndex} - 1;
3704 $status = $snmp_status{$out->{intrusionStatus}};
3705 $reading = get_hashval($out->{intrusionReading}, \%int_reading);
3708 $index = $out->{'Index'};
3709 $status = $out->{'Status'};
3710 $reading = $out->{'State'};
3713 next INTRUSION if blacklisted('intr', $index);
3716 if ($status ne 'Ok') {
3717 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3719 report('chassis', $msg, $E_WARNING, $index);
3723 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3724 $index, $status, $reading;
3725 report('chassis', $msg, $E_OK, $index);
3732 #-----------------------------------------
3733 # CHASSIS: Check alert log
3734 #-----------------------------------------
3735 sub check_alertlog {
3736 return if $snmp; # Not supported with SNMP
3738 my @output = @{ run_omreport("$omopt_system alertlog") };
3739 foreach my $out (@output) {
3740 ++$count{alert}{$out->{Severity}};
3743 # Create error messages and set exit value if appropriate
3745 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
3746 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3748 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
3749 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
3750 report('other', $msg, $err);
3755 #-----------------------------------------
3756 # CHASSIS: Check ESM log overall health
3757 #-----------------------------------------
3758 sub check_esmlog_health {
3762 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
3763 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
3764 if (!defined $result) {
3765 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
3766 $snmp_session->error;
3767 report('other', $msg, $E_UNKNOWN);
3769 $health = $snmp_status{$result->{$systemStateEventLogStatus}};
3772 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
3773 if (m/\A Health;(.+) \z/xms) {
3781 # If the overall health of the ESM log is other than "Ok", the
3782 # fill grade of the log is more than 80% and the log should be
3784 if ($health eq 'Ok') {
3785 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
3786 report('other', $msg, $E_OK);
3788 elsif ($health eq 'Critical') {
3789 my $msg = sprintf 'ESM log is 100%% full';
3790 report('other', $msg, $status2nagios{$health});
3793 my $msg = sprintf 'ESM log is more than 80%% full';
3794 report('other', $msg, $status2nagios{$health});
3800 #-----------------------------------------
3801 # CHASSIS: Check ESM log
3802 #-----------------------------------------
3809 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
3811 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
3814 return if !defined $result;
3816 @output = @{ get_snmp_output($result, \%esm_oid) };
3817 foreach my $out (@output) {
3818 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
3822 @output = @{ run_omreport("$omopt_system esmlog") };
3823 foreach my $out (@output) {
3824 ++$count{esm}{$out->{Severity}};
3828 # Create error messages and set exit value if appropriate
3830 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
3831 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3833 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
3834 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
3835 report('other', $msg, $err);
3841 # Handy function for checking all storage components
3844 check_controllers();
3845 check_physical_disks();
3846 check_virtual_disks();
3847 check_cache_battery();
3850 check_enclosure_fans();
3851 check_enclosure_pwr();
3852 check_enclosure_temp();
3853 check_enclosure_emms();
3859 #---------------------------------------------------------------------
3861 #---------------------------------------------------------------------
3864 # Fetch output from 'omreport chassis info', put in sysinfo hash
3866 sub get_omreport_chassis_info {
3867 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
3868 my @lines = <$INFO>;
3871 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag)/xms;
3872 my ($key, $val) = split /;/xms;
3873 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3874 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3875 if ($key eq 'Chassis Model' or $key eq 'Model') {
3876 $sysinfo{model} = $val;
3878 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
3879 $sysinfo{serial} = $val;
3887 # Fetch output from 'omreport chassis bios', put in sysinfo hash
3889 sub get_omreport_chassis_bios {
3890 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
3891 my @lines = <$BIOS>;
3895 my ($key, $val) = split /;/xms;
3896 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3897 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3898 $sysinfo{bios} = $val if $key eq 'Version';
3899 $sysinfo{biosdate} = $val if $key eq 'Release Date';
3906 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
3908 sub get_omreport_system_operatingsystem {
3909 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
3914 my ($key, $val) = split /;/xms;
3915 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3916 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3917 if ($key eq 'Operating System') {
3918 $sysinfo{osname} = $val;
3920 elsif ($key eq 'Operating System Version') {
3921 $sysinfo{osver} = $val;
3929 # Fetch output from 'omreport about', put in sysinfo hash
3931 sub get_omreport_about {
3932 if (open my $OM, '-|', "$omreport about -fmt ssv") {
3936 if (m/\A Version;(.+) \z/xms) {
3946 # Fetch chassis info via SNMP, put in sysinfo hash
3948 sub get_snmp_chassis_info {
3951 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
3952 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
3955 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
3956 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
3958 if (defined $result) {
3959 foreach my $oid (keys %{ $result }) {
3960 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
3961 $sysinfo{model} = $result->{$oid};
3962 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
3964 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
3965 $sysinfo{serial} = $result->{$oid};
3970 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
3971 $snmp_session->error;
3972 report('other', $msg, $E_UNKNOWN);
3978 # Fetch BIOS info via SNMP, put in sysinfo hash
3980 sub get_snmp_chassis_bios {
3983 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
3984 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
3987 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
3988 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
3990 if (defined $result) {
3991 foreach my $oid (keys %{ $result }) {
3992 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
3993 $sysinfo{biosdate} = $result->{$oid};
3994 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
3996 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
3997 $sysinfo{bios} = $result->{$oid};
4002 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
4003 $snmp_session->error;
4004 report('other', $msg, $E_UNKNOWN);
4010 # Fetch OS info via SNMP, put in sysinfo hash
4012 sub get_snmp_system_operatingsystem {
4015 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
4016 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
4019 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
4020 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
4022 if (defined $result) {
4023 foreach my $oid (keys %{ $result }) {
4024 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
4025 $sysinfo{osname} = ($result->{$oid});
4027 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
4028 $sysinfo{osver} = $result->{$oid};
4033 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
4034 $snmp_session->error;
4035 report('other', $msg, $E_UNKNOWN);
4041 # Fetch OMSA version via SNMP, put in sysinfo hash
4043 sub get_snmp_about {
4044 # systemManagementSoftwareGlobalVersionName
4045 my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
4046 my $result = $snmp_session->get_request(-varbindlist => [$oid]);
4048 if (defined $result) {
4049 $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
4050 ? $result->{$oid} : 'unknown';
4053 my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
4054 report('other', $msg, $E_UNKNOWN);
4060 # Collects some information about the system
4064 # Get system model and serial number
4065 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4067 # Get BIOS information. Only if needed
4068 if ( $opt{okinfo} >= 1
4070 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4071 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4074 # Get OMSA information. Only if needed
4075 if ($opt{okinfo} >= 3 or $opt{debug}) {
4076 $snmp ? get_snmp_about() : get_omreport_about();
4079 # Return now if debug
4080 return if $opt{debug};
4082 # Get OS information. Only if needed
4083 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4084 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4091 # Helper function for running omreport when the results are strictly
4093 sub run_omreport_info {
4094 my $command = shift;
4098 # Run omreport and fetch output
4099 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4101 # Parse output, store in array
4102 for ((split /\n/xms, $rawtext)) {
4103 if (m/\A Error/xms) {
4104 my $msg = "Problem running 'omreport $command': $_";
4105 report('other', $msg, $E_UNKNOWN);
4107 next if !m/;/xms; # ignore lines with less than two fields
4108 my @vals = split m/;/xms;
4109 $output{$vals[0]} = $vals[1];
4112 # Finally, return the collected information
4116 # Get various firmware information (BMC, RAC)
4117 sub get_firmware_info {
4118 my @snmp_output = ();
4119 my %nrpe_output = ();
4124 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4125 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4126 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4129 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4130 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4132 # Some don't have this OID, this is ok
4133 if (!defined $result) {
4137 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4140 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4143 my %fw_type # Firmware types
4145 1 => 'other', # other than following values
4146 2 => 'unknown', # unknown
4147 3 => 'systemBIOS', # System BIOS
4148 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4149 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4150 6 => 'systemBackPlane', # System (Primary) Backplane
4151 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4152 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4153 9 => 'frontPanel', # Front Panel Controller
4154 10 => 'baseboardManagementController', # Baseboard Management Controller
4155 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4156 12 => 'sensorData', # Sensor Data Records
4157 13 => 'peripheralBay', # Peripheral Bay Backplane
4158 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4159 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4160 16 => 'rac', # Remote Access Controller
4161 17 => 'imc' # Integrated Management Controller
4166 foreach my $out (@snmp_output) {
4167 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4168 $sysinfo{'bmc'} = 1;
4169 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4171 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|imc \z}xms) {
4172 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4173 $sysinfo{'rac'} = 1;
4174 $sysinfo{'rac_name'} = $name;
4175 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4180 foreach my $key (keys %nrpe_output) {
4181 next if !defined $nrpe_output{$key};
4182 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4183 $sysinfo{'bmc'} = 1;
4184 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4186 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4188 $sysinfo{'rac'} = 1;
4189 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4190 $sysinfo{'rac_name'} = $name;
4200 #=====================================================================
4202 #=====================================================================
4204 # Here we do the actual checking of components
4205 # Check global status if applicable
4207 $globalstatus = check_global();
4210 # Do multiple selected checks
4211 if ($check{storage}) { check_storage(); }
4212 if ($check{memory}) { check_memory(); }
4213 if ($check{fans}) { check_fans(); }
4214 if ($check{power}) { check_powersupplies(); }
4215 if ($check{temp}) { check_temperatures(); }
4216 if ($check{cpu}) { check_processors(); }
4217 if ($check{voltage}) { check_volts(); }
4218 if ($check{batteries}) { check_batteries(); }
4219 if ($check{amperage}) { check_pwrmonitoring(); }
4220 if ($check{intrusion}) { check_intrusion(); }
4221 if ($check{alertlog}) { check_alertlog(); }
4222 if ($check{esmlog}) { check_esmlog(); }
4223 if ($check{esmhealth}) { check_esmlog_health(); }
4226 #---------------------------------------------------------------------
4228 #---------------------------------------------------------------------
4239 # Get system information
4242 # Get firmware info if requested via option
4243 if ($opt{okinfo} >= 1) {
4244 get_firmware_info();
4247 # Close SNMP session
4249 $snmp_session->close;
4254 print " System: $sysinfo{model}\n";
4255 print " ServiceTag: $sysinfo{serial}";
4256 print q{ } x (25 - length $sysinfo{serial}), "OMSA version: $sysinfo{om}\n";
4257 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4258 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Plugin version: $VERSION\n";
4259 if ($#report_storage >= 0) {
4260 print "-----------------------------------------------------------------------------\n";
4261 print " Storage Components \n";
4262 print "=============================================================================\n";
4263 print " STATE | ID | MESSAGE TEXT \n";
4264 print "---------+----------+--------------------------------------------------------\n";
4265 foreach (@report_storage) {
4266 my ($msg, $level, $nexus) = @{$_};
4267 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4268 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4269 $nagios_alert_count{$reverse_exitcode{$level}}++;
4272 if ($#report_chassis >= 0) {
4273 print "-----------------------------------------------------------------------------\n";
4274 print " Chassis Components \n";
4275 print "=============================================================================\n";
4276 print " STATE | ID | MESSAGE TEXT \n";
4277 print "---------+------+------------------------------------------------------------\n";
4278 foreach (@report_chassis) {
4279 my ($msg, $level, $nexus) = @{$_};
4280 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4281 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4282 $nagios_alert_count{$reverse_exitcode{$level}}++;
4285 if ($#report_other >= 0) {
4286 print "-----------------------------------------------------------------------------\n";
4287 print " Other messages \n";
4288 print "=============================================================================\n";
4289 print " STATE | MESSAGE TEXT \n";
4290 print "---------+-------------------------------------------------------------------\n";
4291 foreach (@report_other) {
4292 my ($msg, $level, $nexus) = @{$_};
4293 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4294 $nagios_alert_count{$reverse_exitcode{$level}}++;
4299 my $c = 0; # counter to determine linebreaks
4301 # Run through each message, sorted by severity level
4303 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4304 my ($msg, $level, $nexus) = @{ $_ };
4305 next ALERT if $level == $E_OK;
4307 if (defined $opt{only}) {
4308 # If user wants only critical alerts
4309 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4311 # If user wants only warning alerts
4312 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4315 # Prefix with service tag if specified with option '-i|--info'
4317 if (defined $opt{htmlinfo}) {
4318 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4319 . "\">$sysinfo{serial}</a>] " . $msg;
4322 $msg = "[$sysinfo{serial}] " . $msg;
4326 # Prefix with nagios level if specified with option '--state'
4327 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4329 # Prefix with one-letter nagios level if specified with option '--short-state'
4330 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4332 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4334 $nagios_alert_count{$reverse_exitcode{$level}}++;
4338 # Determine our exit code
4340 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4341 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4342 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4344 # Global status via SNMP.. extra safety check
4345 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4346 print "OOPS! Something is wrong with this server, but I don't know what. ";
4347 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4348 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4349 print "please file a bug report.\n";
4354 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4356 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4357 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4358 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4359 'memory' => "MEMORY OK - $count{dimm} memory modules checked",
4360 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4361 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4362 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4363 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4364 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4365 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4366 '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",
4367 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4368 'esmhealth' => "ESM LOG OK - less than 80% used",
4371 print $okmsg{$opt{only}};
4373 elsif ($exit_code == $E_OK && !$opt{debug}) {
4374 if (defined $opt{htmlinfo}) {
4375 printf q{OK - System: '<a href="%s">%s</a>', SN: '<a href="%s">%s</a>', hardware working fine},
4376 documentation_url($sysinfo{model}), $sysinfo{model},
4377 warranty_url($sysinfo{serial}), $sysinfo{serial};
4380 printf q{OK - System: '%s', SN: '%s', hardware working fine},
4381 $sysinfo{model}, $sysinfo{serial};
4384 if ($check{storage}) {
4385 printf ', %d logical drives, %d physical drives',
4386 $count{vdisk}, $count{pdisk};
4389 print ', not checking storage';
4392 if ($opt{okinfo} >= 1) {
4394 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4396 if ($sysinfo{rac}) {
4397 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4399 if ($sysinfo{bmc}) {
4400 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4404 if ($opt{okinfo} >= 2) {
4405 if ($check{storage}) {
4406 my @storageprint = ();
4407 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4408 chomp $sysinfo{controller}{$id}{driver};
4409 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4410 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4411 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4412 if (defined $sysinfo{controller}{$id}{storport}) {
4413 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4415 push @storageprint, $msg;
4417 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4418 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4419 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4420 $sysinfo{enclosure}{$id}->{firmware};
4424 foreach my $line (@storageprint) {
4425 print $linebreak, $line;
4430 if ($opt{okinfo} >= 3) {
4431 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4436 if ($opt{extinfo}) {
4438 if (defined $opt{htmlinfo}) {
4439 printf '------ SYSTEM: <a href="%s">%s</a>, SN: <a href="%s">%s</a>',
4440 documentation_url($sysinfo{model}), $sysinfo{model},
4441 warranty_url($sysinfo{serial}), $sysinfo{serial};
4444 printf '------ SYSTEM: %s, SN: %s',
4445 $sysinfo{model}, $sysinfo{serial};
4448 if (defined $opt{postmsg}) {
4450 if (-f $opt{postmsg}) {
4451 open my $POST, '<', $opt{postmsg}
4452 or ( print $linebreak
4453 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4454 and exit $E_UNKNOWN );
4460 $post = $opt{postmsg};
4462 if (defined $post) {
4464 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4465 $post =~ s{[%]m}{$sysinfo{model}}gxms;
4466 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4467 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4468 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4469 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4470 $post =~ s{[%]p}{$count{pdisk}}gxms;
4471 $post =~ s{[%]l}{$count{vdisk}}gxms;
4472 $post =~ s{[%]n}{$linebreak}gxms;
4473 $post =~ s{[%]{2}}{%}gxms;
4479 # Reset the WARN signal
4480 $SIG{__WARN__} = 'DEFAULT';
4482 # Print any perl warnings that have occured
4483 if (@perl_warnings) {
4484 foreach (@perl_warnings) {
4486 print "${linebreak}INTERNAL ERROR: @$_";
4488 $exit_code = $E_UNKNOWN;
4491 # Print performance data
4492 if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
4493 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4496 # Sort routine for performance data
4498 my %order = ( fan => 0, pwr => 1, tem => 2, enc => 3, );
4499 return ($order{(substr $a->{label}, 0, 3)} cmp $order{(substr $b->{label}, 0, 3)}) ||
4500 $a->{label} cmp $b->{label};
4503 # Print performance data sorted
4504 my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
4505 print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
4508 # Print a linebreak at the end
4509 print "\n" if !$opt{debug};
4511 # Exit with proper exit code