5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2008-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 %snmp_enclosure %snmp_controller
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.6.4-beta2';
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 [default=no]
78 -t, --timeout Plugin timeout in seconds [default=30]
79 -c, --critical Custom temperature critical limits
80 -w, --warning Custom 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 [default=public]
89 -P, --protocol SNMP protocol version [default=2]
90 --port SNMP port number [default=161]
91 -6, --ipv6 Use IPv6 instead of IPv4 [default=no]
92 --tcp Use TCP instead of UDP [default=no]
96 -i, --info Prefix any alerts with the service tag
97 -e, --extinfo Append system info to alerts
98 -s, --state Prefix alerts with alert state
99 -S, --short-state Prefix alerts with alert state abbreviated
100 -o, --okinfo Verbosity when check result is OK
101 -I, --htmlinfo HTML output with clickable links
103 CHECK CONTROL AND BLACKLISTING:
105 -a, --all Check everything, even log content
106 -b, --blacklist Blacklist missing and/or failed components
107 --only Only check a certain component or alert type
108 --check Fine-tune which components are checked
109 --no-storage Don't check storage
111 For more information and advanced options, see the manual page or URL:
112 http://folk.uio.no/trondham/software/check_openmanage.html
115 # Version and license text
116 $LICENSE = <<"END_LICENSE";
118 Copyright (C) 2008-2010 $AUTHOR
119 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
120 This is free software: you are free to change and redistribute it.
121 There is NO WARRANTY, to the extent permitted by law.
123 Written by $AUTHOR <$CONTACT>
126 # Options with default values
127 %opt = ( 'blacklist' => [], # blacklisting
128 'check' => [], # check control
129 'critical' => [], # temperature critical limits
130 'warning' => [], # temperature warning limits
131 'timeout' => 30, # default timeout is 30 seconds
132 'debug' => 0, # debugging / verbose output
133 'help' => 0, # display help output
134 'perfdata' => undef, # output performance data
135 'info' => 0, # display servicetag
136 'extinfo' => 0, # display extra info
137 'htmlinfo' => undef, # html tags in output
138 'postmsg' => undef, # post message
139 'state' => 0, # display alert type
140 'short-state' => 0, # display alert type (short)
141 'okinfo' => 0, # default "ok" output level
142 'linebreak' => undef, # specify linebreak
143 'version' => 0, # plugin version info
144 'all' => 0, # check everything
145 'only' => undef, # only one component
146 'no_storage' => 0, # don't check storage
147 'omreport' => undef, # omreport path
148 'port' => 161, # default SNMP port
149 'hostname' => undef, # hostname or IP
150 'community' => 'public', # SMNP v1 or v2c
151 'protocol' => 2, # default SNMP protocol 2c
152 'ipv6' => 0, # default is IPv4
153 'tcp' => 0, # default is UDP
154 'username' => undef, # SMNP v3
155 'authpassword' => undef, # SMNP v3
156 'authkey' => undef, # SMNP v3
157 'authprotocol' => undef, # SMNP v3
158 'privpassword' => undef, # SMNP v3
159 'privkey' => undef, # SMNP v3
160 'privprotocol' => undef, # SMNP v3
161 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
165 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
166 'check=s' => \@{ $opt{check} },
167 'c|critical=s' => \@{ $opt{critical} },
168 'w|warning=s' => \@{ $opt{warning} },
169 't|timeout=i' => \$opt{timeout},
170 'd|debug' => \$opt{debug},
171 'h|help' => \$opt{help},
172 'V|version' => \$opt{version},
173 'p|perfdata:s' => \$opt{perfdata},
174 'i|info' => \$opt{info},
175 'e|extinfo' => \$opt{extinfo},
176 'I|htmlinfo:s' => \$opt{htmlinfo},
177 'postmsg=s' => \$opt{postmsg},
178 's|state' => \$opt{state},
179 'S|short-state' => \$opt{shortstate},
180 'o|ok-info=i' => \$opt{okinfo},
181 'linebreak=s' => \$opt{linebreak},
182 'a|all' => \$opt{all},
183 'only=s' => \$opt{only},
184 'no-storage' => \$opt{no_storage},
185 'omreport=s' => \$opt{omreport},
186 'port=i' => \$opt{port},
187 'H|hostname=s' => \$opt{hostname},
188 'C|community=s' => \$opt{community},
189 'P|protocol=i' => \$opt{protocol},
190 '6|ipv6' => \$opt{ipv6},
192 'U|username=s' => \$opt{username},
193 'authpassword=s' => \$opt{authpassword},
194 'authkey=s' => \$opt{authkey},
195 'authprotocol=s' => \$opt{authprotocol},
196 'privpassword=s' => \$opt{privpassword},
197 'privkey=s' => \$opt{privkey},
198 'privprotocol=s' => \$opt{privprotocol},
199 'use-get_table' => \$opt{use_get_table},
200 ) or do { print $USAGE; exit $E_UNKNOWN };
202 # If user requested help
208 # If user requested version info
216 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
221 # If we're using SNMP
222 $snmp = defined $opt{hostname} ? 1 : 0;
224 # SNMP session variables
225 $snmp_session = undef;
228 # The omreport command
231 # Check flags, override available with the --check option
232 %check = ( 'storage' => 1, # check storage subsystem
233 'memory' => 1, # check memory (dimms)
234 'fans' => 1, # check fan status
235 'power' => 1, # check power supplies
236 'temp' => 1, # check temperature
237 'cpu' => 1, # check processors
238 'voltage' => 1, # check voltage
239 'batteries' => 1, # check battery probes
240 'amperage' => 1, # check power consumption
241 'intrusion' => 1, # check intrusion detection
242 'sdcard' => 1, # check removable flash media (SD cards)
243 'alertlog' => 0, # check the alert log
244 'esmlog' => 0, # check the ESM log (hardware log)
245 'esmhealth' => 1, # check the ESM log overall health
249 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
251 # Line break from option
252 if (defined $opt{linebreak}) {
253 if ($opt{linebreak} eq 'REG') {
256 elsif ($opt{linebreak} eq 'HTML') {
257 $linebreak = '<br/>';
260 $linebreak = $opt{linebreak};
264 # Exit with status=UNKNOWN if there is firmware upgrade in progress
265 if (!$snmp && -f $FW_LOCK) {
266 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
270 # List of controllers and enclosures
271 @controllers = (); # controllers
272 @enclosures = (); # enclosures
273 %snmp_enclosure = (); # enclosures
276 @report_storage = (); # messages with associated nagios level (storage)
277 @report_chassis = (); # messages with associated nagios level (chassis)
278 @report_other = (); # messages with associated nagios level (other)
280 # Counters for everything
283 'pdisk' => 0, # number of physical disks
284 'vdisk' => 0, # number of logical drives (virtual disks)
285 'temp' => 0, # number of temperature probes
286 'volt' => 0, # number of voltage probes
287 'amp' => 0, # number of amperage probes
288 'intr' => 0, # number of intrusion probes
289 'dimm' => 0, # number of memory modules
290 'mem' => 0, # total memory
291 'fan' => 0, # number of fan probes
292 'cpu' => 0, # number of CPUs
293 'bat' => 0, # number of batteries
294 'power' => 0, # number of power supplies
295 'sd' => 0, # number of SD cards
297 'Critical' => 0, # critical entries in ESM log
298 'Non-Critical' => 0, # warning entries in ESM log
299 'Ok' => 0, # ok entries in ESM log
302 'Critical' => 0, # critical entries in alert log
303 'Non-Critical' => 0, # warning entries in alert log
304 'Ok' => 0, # ok entries in alert log
311 # Global health status
312 $global = 1; # default is to check global status
313 $globalstatus = $E_OK; # default global health status is "OK"
315 # Nagios error levels reversed
319 $E_WARNING => 'WARNING',
320 $E_CRITICAL => 'CRITICAL',
321 $E_UNKNOWN => 'UNKNOWN',
324 # OpenManage (omreport) and SNMP error levels
327 'Unknown' => $E_CRITICAL,
328 'Critical' => $E_CRITICAL,
329 'Non-Critical' => $E_WARNING,
331 'Non-Recoverable' => $E_CRITICAL,
332 'Other' => $E_CRITICAL,
343 6 => 'Non-Recoverable',
346 # Probe Status via SNMP
349 1 => 'Other', # probe status is not one of the following:
350 2 => 'Unknown', # probe status is unknown (not known or monitored)
351 3 => 'Ok', # probe is reporting a value within the thresholds
352 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
353 5 => 'criticalUpper', # probe has crossed upper critical threshold
354 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
355 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
356 8 => 'criticalLower', # probe has crossed lower critical threshold
357 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
358 10 => 'failed', # probe is not functional
361 # Probe status translated to Nagios alarm levels
364 'Other' => $E_CRITICAL,
365 'Unknown' => $E_CRITICAL,
367 'nonCriticalUpper' => $E_WARNING,
368 'criticalUpper' => $E_CRITICAL,
369 'nonRecoverableUpper' => $E_CRITICAL,
370 'nonCriticalLower' => $E_WARNING,
371 'criticalLower' => $E_CRITICAL,
372 'nonRecoverableLower' => $E_CRITICAL,
373 'failed' => $E_CRITICAL,
376 # System information gathered
379 'bios' => 'N/A', # BIOS version
380 'biosdate' => 'N/A', # BIOS release date
381 'serial' => 'N/A', # serial number (service tag)
382 'model' => 'N/A', # system model
383 'rev' => q{}, # system revision
384 'osname' => 'N/A', # OS name
385 'osver' => 'N/A', # OS version
386 'om' => 'N/A', # OMSA version
387 'bmc' => 0, # HAS baseboard management controller (BMC)
388 'rac' => 0, # HAS remote access controller (RAC)
389 'rac_name' => 'N/A', # remote access controller (RAC)
390 'bmc_fw' => 'N/A', # BMC firmware
391 'rac_fw' => 'N/A', # RAC firmware
394 # Adjust which checks to perform
395 adjust_checks() if defined $opt{check};
397 # Blacklisted components
398 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
400 # If blacklisting is in effect, don't check global health status
401 if (scalar keys %blacklist > 0) {
405 # Take into account new hardware and blades
406 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
407 $omopt_system = 'system'; # default "system" option to omreport
408 $blade = 0; # if this is a blade system
410 # Some initializations and checking before we begin
412 snmp_initialize(); # initialize SNMP
413 snmp_check(); # check that SNMP works
414 snmp_detect_blade(); # detect blade via SNMP
417 # Find the omreport binary
419 # Check help output from omreport, see which options are available.
420 # Also detecting blade via omreport.
421 check_omreport_options();
425 #---------------------------------------------------------------------
427 #---------------------------------------------------------------------
430 # Store a message in one of the message arrays
433 my ($type, $msg, $exval, $id) = @_;
434 defined $id or $id = q{};
438 'storage' => \@report_storage,
439 'chassis' => \@report_chassis,
440 'other' => \@report_other,
443 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
448 # Run command, put resulting output lines in an array and return a
449 # pointer to that array
454 open my $CMD, '-|', $command
455 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
459 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
460 and return \@lines };
465 # Run command, put resulting output in a string variable and return it
470 open my $CMD, '-|', $command
471 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
472 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
475 # NOTE: We don't check the return value of close() since omreport
476 # does something weird sometimes.
484 sub snmp_initialize {
485 # Legal SNMP v3 protocols
486 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
487 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
489 # Parameters to Net::SNMP->session()
492 '-port' => $opt{port},
493 '-hostname' => $opt{hostname},
494 '-version' => $opt{protocol},
497 # Setting the domain (IP version and transport protocol)
498 my $transport = $opt{tcp} ? 'tcp' : 'udp';
499 my $ipversion = $opt{ipv6} ? 'ipv6' : 'ipv4';
500 $param{'-domain'} = "$transport/$ipversion";
502 # Parameters for SNMP v3
503 if ($opt{protocol} == 3) {
505 # Username is mandatory
506 if (defined $opt{username}) {
507 $param{'-username'} = $opt{username};
510 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
514 # Authpassword is optional
515 if (defined $opt{authpassword}) {
516 $param{'-authpassword'} = $opt{authpassword};
519 # Authkey is optional
520 if (defined $opt{authkey}) {
521 $param{'-authkey'} = $opt{authkey};
524 # Privpassword is optional
525 if (defined $opt{privpassword}) {
526 $param{'-privpassword'} = $opt{privpassword};
529 # Privkey is optional
530 if (defined $opt{privkey}) {
531 $param{'-privkey'} = $opt{privkey};
534 # Privprotocol is optional
535 if (defined $opt{privprotocol}) {
536 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
537 $param{'-privprotocol'} = $opt{privprotocol};
540 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
541 . "must be one of [des|aes|aes128|3des|3desde]\n";
546 # Authprotocol is optional
547 if (defined $opt{authprotocol}) {
548 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
549 $param{'-authprotocol'} = $opt{authprotocol};
552 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
553 . "must be one of [md5|sha]\n";
558 # Parameters for SNMP v2c or v1
559 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
560 $param{'-community'} = $opt{community};
563 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
567 # Try to initialize the SNMP session
568 if ( eval { require Net::SNMP; 1 } ) {
569 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
570 if (!defined $snmp_session) {
571 printf "SNMP: %s\n", $snmp_error;
576 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
583 # Checking if SNMP works by probing for "chassisModelName", which all
584 # servers should have
587 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
588 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
590 # Typically if remote host isn't responding
591 if (!defined $result) {
592 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
596 # If OpenManage isn't installed or is not working
597 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
598 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
605 # Detecting blade via SNMP
607 sub snmp_detect_blade {
608 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
609 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
611 # Identify blade. Older models (4th and 5th gen models) and/or old
612 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
613 # similar, we assume that this isn't a blade
614 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
621 # Locate the omreport binary
624 # If user has specified path to omreport
625 if (defined $opt{omreport} and -x $opt{omreport}) {
626 $omreport = qq{"$opt{omreport}"};
630 # Possible full paths for omreport
633 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA >= 6.2.0
634 '/usr/bin/omreport', # default on Linux with OMSA < 6.2.0
635 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
636 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
637 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
638 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
639 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
640 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
643 # Find the one to use
645 foreach my $bin (@omreport_paths) {
647 $omreport = qq{"$bin"};
652 # Exit with status=UNKNOWN if OM is not installed, or we don't
653 # have permission to execute the binary
654 if (!defined $omreport) {
655 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
662 # Checks output from 'omreport -?' and searches for arguments to
663 # omreport, to accommodate deprecated options "chassis" and "system"
664 # (on newer hardware), as well as blade servers.
666 sub check_omreport_options {
667 foreach (@{ run_command("$omreport -? 2>&1") }) {
668 if (m/\A servermodule /xms) {
669 # If "servermodule" argument to omreport exists, use it
670 # instead of argument "system"
671 $omopt_system = 'servermodule';
673 elsif (m/\A mainsystem /xms) {
674 # If "mainsystem" argument to omreport exists, use it
675 # instead of argument "chassis"
676 $omopt_chassis = 'mainsystem';
678 elsif (m/\A modularenclosure /xms) {
679 # If "modularenclusure" argument to omreport exists, assume
680 # that this is a blade
688 # Read the blacklist option and return a hash containing the
689 # blacklisted components
695 if (scalar @{ $opt{blacklist} } >= 0) {
696 foreach my $black (@{ $opt{blacklist} }) {
699 open my $BL, '<', $black
700 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
712 return {} if $#bl < 0;
714 # Parse blacklist string, put in hash
715 foreach my $black (@bl) {
716 my @comps = split m{/}xms, $black;
717 foreach my $c (@comps) {
718 next if $c !~ m/=/xms;
719 my ($key, $val) = split /=/xms, $c;
720 my @vals = split /,/xms, $val;
721 $blacklist{$key} = \@vals;
729 # Read the check option and adjust the hash %check, which is a rough
730 # list of components to be checked
735 # First, take the '--no-storage' option
736 if ($opt{no_storage}) {
740 # Adjust checking based on the '--all' option
743 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
744 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
747 if (scalar @{ $opt{check} } > 0) {
748 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
752 # set the check hash to check everything
753 map { $_ = 1 } values %check;
758 # Adjust checking based on the '--only' option
759 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
761 if (scalar @{ $opt{check} } > 0) {
762 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
765 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
766 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
770 # reset the check hash
771 map { $_ = 0 } values %check;
773 # adjust the check hash
774 if ($opt{only} eq 'chassis') {
775 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
776 batteries amperage intrusion esmhealth);
779 $check{$opt{only}} = 1;
785 # Adjust checking based on the '--check' option
786 if (scalar @{ $opt{check} } >= 0) {
787 foreach my $check (@{ $opt{check} }) {
790 open my $CL, '<', $check
791 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
804 # Parse checklist string, put in hash
805 foreach my $check (@cl) {
806 my @checks = split /,/xms, $check;
807 foreach my $c (@checks) {
808 next if $c !~ m/=/xms;
809 my ($key, $val) = split /=/xms, $c;
814 # Check if we should check global health status
816 foreach (keys %check) {
817 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
818 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
820 if ($check{$_} == 0) { # found something with checking turned off
830 # Runs omreport and returns an array of anonymous hashes containing
832 # Takes one argument: string containing parameters to omreport
839 # Errors that are OK. Some low-end poweredge (and blades) models
840 # don't have RAID controllers, intrusion detection sensor, or
841 # redundant/instrumented power supplies etc.
844 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
845 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
846 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
847 | Invalid\scommand:\spwrmonitoring # Old hardware
848 | Hardware\sor\sfeature\snot\spresent\. # SD cards
849 | Invalid\scommand:\sremovableflashmedia # SD cards with old OMSA
850 | Error\sCorrection; # Memory stuff. Not really an error (new in OMSA 6.4)
851 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
852 # | No\scontrollers\sfound # No RAID controller
855 # Errors that are OK on blade servers
858 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
861 # Run omreport and fetch output
862 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
863 return [] if !defined $rawtext;
865 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
866 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
868 # Report if no controllers found
869 if ($command eq 'storage controller' and $rawtext =~ m{No\scontrollers\sfound}xms) {
870 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
873 # Openmanage sometimes puts a linebreak between "Error" and the
875 $rawtext =~ s{^Error\s*\n}{Error: }xms;
877 # Parse output, store in array
878 for ((split m{\n}xms, $rawtext)) {
880 next if m{$ok_errors}xms;
881 next if ($blade and m{$ok_blade_errors}xms);
882 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
885 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
886 my @vals = split /;/xms;
887 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed|Connector\sName) \z/xms) {
892 push @output, { map { $_ => $vals[$i++] } @keys };
897 # Finally, return the collected information
902 # Checks if a component is blacklisted. Returns 1 if the component is
903 # blacklisted, 0 otherwise. Takes two arguments:
904 # arg1: component name
905 # arg2: component id or index
908 my $name = shift; # component name
909 my $id = shift; # component id
910 my $ret = 0; # return value
912 if (defined $blacklist{$name}) {
913 foreach my $comp (@{ $blacklist{$name} }) {
914 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
923 # Converts the NexusID from SNMP to our version
926 $nexus =~ s{\A \\}{}xms;
927 $nexus =~ s{\\}{:}gxms;
931 # Sets custom temperature thresholds based on user supplied options
932 sub custom_temperature_thresholds {
933 my $type = shift; # type of threshold, either w (warning) or c (critical)
934 my %thres = (); # will contain the thresholds
935 my @limits = (); # holds the input
937 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
939 if (scalar @opt >= 0) {
940 foreach my $t (@opt) {
944 or do { report('other', "Couldn't open temperature threshold file $t: $!",
945 $E_UNKNOWN) and return {} };
956 # Parse checklist string, put in hash
957 foreach my $th (@limits) {
958 my @tmp = split m{,}xms, $th;
959 foreach my $t (@tmp) {
960 next if $t !~ m{=}xms;
961 my ($key, $val) = split m{=}xms, $t;
962 if ($val =~ m{/}xms) {
963 my ($max, $min) = split m{/}xms, $val;
964 $thres{$key}{max} = $max;
965 $thres{$key}{min} = $min;
968 $thres{$key}{max} = $val;
977 # Gets the output from SNMP result according to the OIDs checked
978 sub get_snmp_output {
979 my ($result,$oidref) = @_;
983 foreach my $oid (keys %{ $result }) {
985 $short =~ s{\s}{}gxms; # remove whitespace
986 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
988 if (exists $oidref->{$short}) {
989 $temp[$id]{$oidref->{$short}} = $result->{$oid};
993 # Remove any empty indexes
994 foreach my $out (@temp) {
1004 # Map the controller or other item in-place
1006 my ($key, $val, $list) = @_;
1008 foreach my $lst (@{ $list }) {
1009 if (!exists $lst->{$key}) {
1010 $lst->{$key} = $val;
1016 # Return the URL for official Dell documentation for a specific
1018 sub documentation_url {
1021 # create model short form, e.g. "r710"
1022 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
1024 # special case for blades (e.g. M600, M710), they have common
1026 $model =~ s{\A m\d+ \z}{m}xms;
1028 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1031 # Return the URL for warranty information for a server with a given
1032 # serial number (servicetag)
1036 # Dell support sites for different parts of the world
1039 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1040 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1041 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1044 # warranty URLs for different country codes
1048 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1049 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1050 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1051 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1052 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1053 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1054 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1055 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1056 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1057 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1058 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1059 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1060 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1061 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1062 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1063 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1064 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1065 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1066 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1067 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1069 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1070 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1071 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1072 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1074 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1075 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1076 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1078 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1081 if (exists $url{$opt{htmlinfo}}) {
1082 return $url{$opt{htmlinfo}} . $tag;
1085 return $url{XX} . $tag;
1090 # This helper function returns the corresponding value of a hash key,
1091 # but takes into account that the key may not exist
1093 my $key = shift || return undef;
1095 return defined $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1098 # Find component status from hash
1099 sub get_snmp_status {
1100 my $key = shift || return 'Unknown';
1101 return exists $snmp_status{$key} ? $snmp_status{$key} : 'Unknown';
1104 # Find component status from hash
1105 sub get_snmp_probestatus {
1106 my $key = shift || return 'Unknown';
1107 return exists $snmp_probestatus{$key} ? $snmp_probestatus{$key} : 'Unknown';
1110 # Check that a hash entry is defined and not an empty string. Return a
1111 # chosen string (parameter) if these conditions are not met
1112 sub get_nonempty_string {
1113 my $key = shift; # key to check
1114 my $hash = shift; # hash where the key belongs
1115 my $alt = shift; # alternate return value
1116 if (defined $hash->{$key} and $hash->{$key} ne q{}) {
1117 return $hash->{$key};
1123 #---------------------------------------------------------------------
1125 #---------------------------------------------------------------------
1127 #-----------------------------------------
1128 # Check global health status
1129 #-----------------------------------------
1135 # Checks global status, i.e. both storage and chassis
1137 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1138 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1139 if (!defined $result) {
1140 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1143 $health = $status2nagios{get_snmp_status($result->{$systemStateGlobalSystemStatus})};
1147 # NB! This does not check storage, only chassis...
1149 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1151 next if m/\A SEVERITY;COMPONENT/xms;
1152 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1153 $health = $status2nagios{$1};
1164 #-----------------------------------------
1165 # STORAGE: Check controllers
1166 #-----------------------------------------
1167 sub check_controllers {
1168 return if blacklisted('ctrl', 'all');
1176 my $firmware = undef;
1178 my $minstdr = undef; # Minimum required Storport driver version
1179 my $stdr = undef; # Storport driver version
1185 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1186 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1187 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1188 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1189 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1190 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1191 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1192 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1193 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1194 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1195 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1198 # We use get_table() here for the odd case where a server has
1199 # two or more controllers, and where some OIDs are missing on
1200 # one of the controllers.
1201 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1202 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1204 if (!defined $result) {
1205 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
1209 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1212 @output = @{ run_omreport('storage controller') };
1226 foreach my $out (@output) {
1228 $name = $out->{controllerName} || 'Unknown controller';
1229 $state = get_hashval($out->{controllerState}, \%ctrl_state) || 'Unknown state';
1230 $status = get_snmp_status($out->{controllerComponentStatus});
1231 $minfw = $out->{controllerMinFWVersion} || undef;
1232 $mindr = $out->{controllerMinDriverVersion} || undef;
1233 $firmware = $out->{controllerFWVersion} || 'N/A';
1234 $driver = $out->{controllerDriverVersion} || 'N/A';
1235 $minstdr = $out->{'controllerMinRequiredStorportVer'} || undef;
1236 $stdr = $out->{controllerStorportDriverVersion} || undef;
1237 $nexus = convert_nexus(($out->{controllerNexusID} || 9999));
1240 $nexus = get_nonempty_string('ID', $out, '9999');
1241 $name = get_nonempty_string('Name', $out, 'Unknown controller');
1242 $state = get_nonempty_string('State', $out, 'Unknown state');
1243 $status = get_nonempty_string('Status', $out, 'Unknown');
1244 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1245 ? $out->{'Minimum Required Firmware Version'} : undef;
1246 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1247 ? $out->{'Minimum Required Driver Version'} : undef;
1248 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1249 ? $out->{'Firmware Version'} : 'N/A';
1250 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1251 ? $out->{'Driver Version'} : 'N/A';
1252 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1253 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1254 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1255 $stdr = (exists $out->{'Storport Driver Version'}
1256 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1257 ? $out->{'Storport Driver Version'} : undef;
1260 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1261 push @controllers, $nexus;
1263 # Collecting some storage info
1264 $sysinfo{'controller'}{$nexus}{'id'} = $nexus;
1265 $sysinfo{'controller'}{$nexus}{'name'} = $name;
1266 $sysinfo{'controller'}{$nexus}{'driver'} = $driver;
1267 $sysinfo{'controller'}{$nexus}{'firmware'} = $firmware;
1268 $sysinfo{'controller'}{$nexus}{'storport'} = $stdr;
1270 # Store controller info for future use (SNMP)
1272 $snmp_controller{$out->{controllerNumber}} = $nexus;
1275 next CTRL if blacklisted('ctrl', $nexus);
1277 # Special case: old firmware
1278 if (!blacklisted('ctrl_fw', $nexus) && defined $minfw) {
1280 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1281 $nexus, $name, $firmware;
1282 report('storage', $msg, $E_WARNING, $nexus);
1284 # Special case: old driver
1285 if (!blacklisted('ctrl_driver', $nexus) && defined $mindr) {
1287 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1288 $nexus, $name, $driver;
1289 report('storage', $msg, $E_WARNING, $nexus);
1291 # Special case: old storport driver
1292 if (!blacklisted('ctrl_stdr', $nexus) && defined $minstdr) {
1294 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1295 $nexus, $name, $stdr;
1296 report('storage', $msg, $E_WARNING, $nexus);
1299 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1300 and (defined $minfw or defined $mindr or defined $minstdr))) {
1301 my $msg = sprintf 'Controller %d [%s] is %s',
1302 $nexus, $name, $state;
1303 report('storage', $msg, $E_OK, $nexus);
1307 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1308 $nexus, $name, $state;
1309 report('storage', $msg, $status2nagios{$status}, $nexus);
1316 #-----------------------------------------
1317 # STORAGE: Check physical drives
1318 #-----------------------------------------
1319 sub check_physical_disks {
1320 return if $#controllers == -1;
1321 return if blacklisted('pdisk', 'all');
1330 my $vendor = undef; # disk vendor
1331 my $product = undef; # product ID
1332 my $capacity = undef; # disk length (size) in bytes
1333 my $media = undef; # media type (e.g. HDD, SSD)
1334 my $bus = undef; # bus protocol (e.g. SAS, SATA)
1335 my $spare = undef; # spare state (e.g. global hotspare)
1341 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1342 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1343 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1344 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1345 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1346 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1347 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1348 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1349 '1.3.6.1.4.1.674.10893.1.20.130.4.1.21' => 'arrayDiskBusType',
1350 '1.3.6.1.4.1.674.10893.1.20.130.4.1.22' => 'arrayDiskSpareState',
1351 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1352 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1353 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1354 '1.3.6.1.4.1.674.10893.1.20.130.4.1.35' => 'arrayDiskMediaType',
1355 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1356 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1359 if ($opt{use_get_table}) {
1360 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1361 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1362 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1364 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1365 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1366 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1368 if (defined $result) {
1369 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1370 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1374 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1377 if (!defined $result) {
1378 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1379 $snmp_session->close;
1383 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1386 foreach my $c (@controllers) {
1387 # This blacklists disks with broken firmware, which includes
1388 # illegal XML characters that makes openmanage choke on itself
1389 next if blacklisted('ctrl_pdisk', $c);
1391 push @output, @{ run_omreport("storage pdisk controller=$c") };
1392 map_item('ctrl', $c, \@output);
1398 1 => 'VD member', # disk is a member of a virtual disk
1399 2 => 'DG member', # disk is a member of a disk group
1400 3 => 'Global HS', # disk is a global hot spare
1401 4 => 'Dedicated HS', # disk is a dedicated hot spare
1402 5 => 'no', # not a spare
1403 99 => 'n/a', # not applicable
1417 3 => 'Fibre Channel',
1435 22 => 'Replacing', # FIXME: this one is not defined in the OMSA MIBs
1439 28 => 'Diagnostics',
1440 34 => 'Predictive failure',
1441 35 => 'Initializing',
1444 41 => 'Unsupported',
1445 53 => 'Incompatible',
1448 # Check physical disks on each of the controllers
1450 foreach my $out (@output) {
1452 $name = $out->{arrayDiskName} || 'Unknown disk';
1453 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state) || 'Unknown state';
1454 $status = get_snmp_status($out->{arrayDiskComponentStatus});
1455 $fpred = defined $out->{arrayDiskSmartAlertIndication}
1456 && $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1458 $nexus = convert_nexus(($out->{arrayDiskNexusID} || 9999));
1459 $vendor = $out->{arrayDiskVendor} || 'Unknown vendor';
1460 $product = $out->{arrayDiskProductID} || 'Unknown product ID';
1461 $spare = get_hashval($out->{arrayDiskSpareState}, \%spare_state) || q{};
1462 $bus = get_hashval($out->{arrayDiskBusType}, \%bus_type);
1463 $media = get_hashval($out->{arrayDiskMediaType}, \%media_type);
1464 $capacity = exists $out->{arrayDiskLengthInMB}
1465 ? $out->{arrayDiskLengthInMB} * 1024**2 : -1;
1467 # try to find the controller where the disk belongs
1468 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1469 # for disks that are attached to an enclosure
1470 $ctrl = $snmp_controller{$out->{arrayDiskEnclosureConnectionControllerNumber}};
1472 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1473 # for disks that are not attached to an enclosure
1474 $ctrl = $snmp_controller{$out->{arrayDiskChannelConnectionControllerNumber}};
1477 # last resort... use the nexus id (old/broken hardware)
1479 $ctrl =~ s{\A (\d+) : .* \z}{$1}xms;
1483 $name = get_nonempty_string('Name', $out, 'Unknown disk');
1484 $state = get_nonempty_string('State', $out, 'Unknown state');
1485 $status = get_nonempty_string('Status', $out, 'Unknown');
1486 $fpred = lc(get_nonempty_string('Failure Predicted', $out, q{})) eq 'yes' ? 1 : 0;
1487 $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
1488 $nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
1489 $vendor = get_nonempty_string('Vendor ID', $out, 'Unknown Vendor');
1490 $product = get_nonempty_string('Product ID', $out, 'Unknown Product ID');
1491 $media = get_nonempty_string('Media', $out, undef);
1492 $bus = get_nonempty_string('Bus Protocol', $out, undef);
1493 $spare = get_nonempty_string('Hot Spare', $out, q{});
1494 $ctrl = $out->{ctrl};
1495 $capacity = get_nonempty_string('Capacity', $out, q{});
1496 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1497 if ($capacity eq 'Unavailable') {
1502 next PDISK if blacklisted('pdisk', $nexus);
1505 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1506 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1508 # If the disk is bad, the vendor field may be empty
1509 if ($vendor eq q{}) { $vendor = 'Unknown Vendor'; }
1512 if ($spare eq 'Global') { $spare = 'Global HS'; }
1513 elsif ($spare eq 'Dedicated') { $spare = 'Dedicated HS'; }
1514 elsif ($spare !~ m{\A Global|Dedicated}xms) { $spare = undef; }
1516 # Calculate human readable capacity
1517 if ($capacity == -1) {
1518 # capacity is unknown
1519 $capacity = 'Unknown Size';
1522 $capacity = ceil($capacity / 1000**3) >= 1000
1523 ? sprintf '%.1fTB', ($capacity / 1000**4)
1524 : sprintf '%.0fGB', ($capacity / 1000**3);
1525 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1526 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1527 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1528 $capacity = '100GB' if $capacity eq '99GB'; # quick fix for 100GB disks
1531 # Capitalize only the first letter of the vendor name
1532 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1534 # Remove unnecessary trademark rubbish from vendor name
1535 $vendor =~ s{\(tm\)\z}{}xms;
1537 # bus and media aren't always defined
1539 if (defined $bus && defined $media) { $busmedia = "$bus-$media "; }
1540 elsif (defined $bus && ! defined $media) { $busmedia = "$bus "; }
1541 elsif (! defined $bus && defined $media) { $busmedia = "$media "; }
1543 # Special case: Failure predicted
1545 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1546 $name, $vendor, $product, $capacity, $ctrl;
1547 $msg .= " ($state)" if $state ne 'Predictive failure';
1548 report('storage', $msg,
1549 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1551 # Special case: Rebuilding / Replacing
1552 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1553 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1554 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1555 report('storage', $msg, $E_WARNING, $nexus);
1558 elsif ($status ne 'Ok') {
1559 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1560 $name, $vendor, $product, $capacity, $ctrl, $state;
1561 report('storage', $msg, $status2nagios{$status}, $nexus);
1565 my $msg = sprintf '%s [%s%s] on ctrl %d is %s',
1566 $name, $busmedia, $capacity, $ctrl, $state;
1567 if (defined $spare) { $msg .= " ($spare)"; }
1568 report('storage', $msg, $E_OK, $nexus);
1575 #-----------------------------------------
1576 # STORAGE: Check logical drives
1577 #-----------------------------------------
1578 sub check_virtual_disks {
1579 return if $#controllers == -1;
1580 return if blacklisted('vdisk', 'all');
1596 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1597 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1598 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1599 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1600 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1601 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1604 if ($opt{use_get_table}) {
1605 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1606 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1609 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1612 # No logical drives is OK
1613 return if !defined $result;
1615 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1618 foreach my $c (@controllers) {
1619 push @output, @{ run_omreport("storage vdisk controller=$c") };
1620 map_item('ctrl', $c, \@output);
1633 16 => 'Regenerating',
1636 32 => 'Reconstructing',
1637 35 => 'Initializing',
1638 36 => 'Background Initialization',
1639 38 => 'Resynching Paused',
1640 52 => 'Permanently Degraded',
1641 54 => 'Degraded Redundancy',
1646 1 => 'Concatenated',
1653 19 => 'Concatenated RAID-1',
1658 # Check virtual disks on each of the controllers
1660 foreach my $out (@output) {
1662 $dev = $out->{virtualDiskDeviceName} || 'Unknown device';
1663 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state) || 'Unknown state';
1664 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout) || 'Unknown layout';
1665 $status = get_snmp_status($out->{virtualDiskComponentStatus});
1666 $size = sprintf '%.2f GB', ($out->{virtualDiskLengthInMB} || 0) / 1024;
1667 $progr = q{}; # not available via SNMP
1668 $nexus = convert_nexus(($out->{virtualDiskNexusID} || 9999));
1671 $dev = get_nonempty_string('Device Name', $out, 'Unknown device');
1672 $state = get_nonempty_string('State', $out, 'Unknown state');
1673 $status = get_nonempty_string('Status', $out, 'Unknown');
1674 $layout = get_nonempty_string('Layout', $out, 'Unknown layout');
1675 $size = get_nonempty_string('Size', $out, 'Unavailable');
1676 $size =~ s{\A (.*GB).* \z}{$1}xms;
1677 $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
1678 $ctrl = $out->{ctrl};
1679 $nexus = join q{:}, $ctrl, get_nonempty_string('ID', $out, '9999');
1682 next VDISK if blacklisted('vdisk', $nexus);
1685 # The device name is undefined sometimes
1686 $dev = q{} if !defined $dev;
1688 # Special case: Regenerating
1689 if ($state eq 'Regenerating') {
1690 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s%s},
1691 $dev, $layout, $size, $state, $progr;
1692 report('storage', $msg, $E_WARNING, $nexus);
1695 elsif ($status ne 'Ok') {
1696 my $msg = sprintf q{Logical Drive '%s' [%s, %s] needs attention: %s},
1697 $dev, $layout, $size, $state;
1698 report('storage', $msg, $status2nagios{$status}, $nexus);
1702 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s},
1703 $dev, $layout, $size, $state;
1704 report('storage', $msg, $E_OK, $nexus);
1711 #-----------------------------------------
1712 # STORAGE: Check cache batteries
1713 #-----------------------------------------
1714 sub check_cache_battery {
1715 return if $#controllers == -1;
1716 return if blacklisted('bat', 'all');
1723 my $learn = undef; # learn state
1724 my $pred = undef; # battery's ability to be charged
1730 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1731 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1732 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1733 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1734 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1735 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1738 if ($opt{use_get_table}) {
1739 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1740 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1742 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1743 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1745 if (defined $result) {
1746 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1750 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1753 # No cache battery is OK
1754 return if !defined $result;
1756 @output = @{ get_snmp_output($result, \%bat_oid) };
1759 foreach my $c (@controllers) {
1760 push @output, @{ run_omreport("storage battery controller=$c") };
1761 map_item('ctrl', $c, \@output);
1771 7 => 'Reconditioning',
1779 # Specifies the learn state activity of the battery
1789 # This property displays the battery's ability to be charged
1792 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1793 2 => 'Ready', # The battery can be charged to full capacity
1794 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1795 # battery cannot be determined until the Learn cycle is complete
1798 # Check battery on each of the controllers
1800 foreach my $out (@output) {
1802 $status = get_snmp_status($out->{batteryComponentStatus});
1803 $state = get_hashval($out->{batteryState}, \%bat_state) || 'Unknown state';
1804 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state) || 'Unknown learn state';
1805 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap) || 'Unknown predicted capacity status';
1806 $ctrl = ($out->{batteryConnectionControllerNumber} || 10000) - 1;
1807 $nexus = convert_nexus(($out->{batteryNexusID} || 9999));
1809 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1812 $id = get_nonempty_string('ID', $out, 9999);
1813 $state = get_nonempty_string('State', $out, 'Unknown state');
1814 $status = get_nonempty_string('Status', $out, 'Unknown');
1815 $learn = get_nonempty_string('Learn State', $out, 'Unknown learn state');
1816 $pred = get_nonempty_string('Predicted Capacity Status', $out, 'Unknown predicted capacity status');
1817 $ctrl = $out->{'ctrl'};
1818 $nexus = join q{:}, $out->{ctrl}, $id;
1821 next BATTERY if blacklisted('bat', $nexus);
1823 # Special case: Charging
1824 if ($state eq 'Charging') {
1825 if ($pred eq 'Failed') {
1826 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [replace battery]',
1827 $id, $ctrl, $state, $pred;
1828 report('storage', $msg, $E_CRITICAL, $nexus);
1831 next BATTERY if blacklisted('bat_charge', $nexus);
1832 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1833 $id, $ctrl, $state, $pred;
1834 report('storage', $msg, $E_WARNING, $nexus);
1837 # Special case: Learning (battery learns its capacity)
1838 elsif ($state eq 'Learning') {
1839 if ($learn eq 'Failed') {
1840 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s)',
1841 $id, $ctrl, $state, $learn;
1842 report('storage', $msg, $E_CRITICAL, $nexus);
1845 next BATTERY if blacklisted('bat_charge', $nexus);
1846 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1847 $id, $ctrl, $state, $learn;
1848 report('storage', $msg, $E_WARNING, $nexus);
1851 # Special case: Power Low (first part of recharge cycle)
1852 elsif ($state eq 'Power Low') {
1853 next BATTERY if blacklisted('bat_charge', $nexus);
1854 my $msg = sprintf 'Cache Battery %d in controller %d is %s [probably harmless]',
1856 report('storage', $msg, $E_WARNING, $nexus);
1858 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1859 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1860 next BATTERY if blacklisted('bat_charge', $nexus);
1861 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1862 $id, $ctrl, $state, $status;
1863 report('storage', $msg, $E_WARNING, $nexus);
1866 elsif ($status ne 'Ok') {
1867 my $msg = sprintf 'Cache Battery %d in controller %d needs attention: %s (%s)',
1868 $id, $ctrl, $state, $status;
1869 report('storage', $msg, $status2nagios{$status}, $nexus);
1873 my $msg = sprintf 'Cache Battery %d in controller %d is %s',
1875 report('storage', $msg, $E_OK, $nexus);
1882 #-----------------------------------------
1883 # STORAGE: Check connectors (channels)
1884 #-----------------------------------------
1885 sub check_connectors {
1886 return if $#controllers == -1;
1887 return if blacklisted('conn', 'all');
1900 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1901 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1902 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1903 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1904 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1907 if ($opt{use_get_table}) {
1908 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1909 $result = $snmp_session->get_table(-baseoid => $channelTable);
1912 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1915 if (!defined $result) {
1916 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1917 $snmp_session->close;
1921 @output = @{ get_snmp_output($result, \%conn_oid) };
1924 foreach my $c (@controllers) {
1925 push @output, @{ run_omreport("storage connector controller=$c") };
1926 map_item('ctrl', $c, \@output);
1944 3 => 'Fibre Channel',
1951 # Check connectors on each of the controllers
1953 foreach my $out (@output) {
1955 $name = $out->{channelName} || 'Unknown channel';
1956 $status = get_snmp_status($out->{channelComponentStatus});
1957 $state = get_hashval($out->{channelState}, \%conn_state) || 'Unknown state';
1958 $type = get_hashval($out->{channelBusType}, \%conn_bustype) || 'Unknown type';
1959 $nexus = convert_nexus(($out->{channelNexusID} || 9999));
1961 $ctrl =~ s{(\d+):\d+}{$1}xms;
1964 $name = get_nonempty_string('Name', $out, 'Unknown channel');
1965 $state = get_nonempty_string('State', $out, 'Unknown state');
1966 $status = get_nonempty_string('Status', $out, 'Unknown');
1967 $type = get_nonempty_string('Connector Type', $out, 'Unknown type');
1968 $ctrl = $out->{ctrl};
1969 $nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
1972 next CHANNEL if blacklisted('conn', $nexus);
1974 my $msg = sprintf '%s [%s] on controller %d is %s',
1975 $name, $type, $ctrl, $state;
1976 report('storage', $msg, $status2nagios{$status}, $nexus);
1982 #-----------------------------------------
1983 # STORAGE: Check enclosures
1984 #-----------------------------------------
1985 sub check_enclosures {
1986 return if blacklisted('encl', 'all');
1993 my $firmware = undef;
1995 my $occupied_slots = undef; # number of occupied slots
1996 my $total_slots = undef; # number of total slots
2002 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
2003 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
2004 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
2005 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
2006 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
2007 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
2008 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
2009 '1.3.6.1.4.1.674.10893.1.20.130.3.1.31' => 'enclosureOccupiedSlotCount', # new in OMSA 6.3.0
2010 '1.3.6.1.4.1.674.10893.1.20.130.3.1.32' => 'enclosureTotalSlots', # new in OMSA 6.3.0
2013 if ($opt{use_get_table}) {
2014 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
2015 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
2018 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
2021 # No enclosures is OK
2022 return if !defined $result;
2024 @output = @{ get_snmp_output($result, \%encl_oid) };
2027 foreach my $c (@controllers) {
2028 push @output, @{ run_omreport("storage enclosure controller=$c") };
2029 map_item('ctrl', $c, \@output);
2044 foreach my $out (@output) {
2046 $id = ($out->{enclosureNumber} || 10000) - 1;
2047 $name = $out->{enclosureName} || 'Unknown enclosure';
2048 $state = get_hashval($out->{enclosureState}, \%encl_state) || 'Unknown state';
2049 $status = get_snmp_status($out->{enclosureComponentStatus});
2050 $firmware = $out->{enclosureFirmwareVersion} || 'N/A';
2051 $nexus = convert_nexus(($out->{enclosureNexusID} || 9999));
2053 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
2054 # for the next two, a value of 9999 means feature not available
2055 $occupied_slots = defined $out->{enclosureOccupiedSlotCount}
2056 && $out->{enclosureOccupiedSlotCount} != 9999
2057 ? $out->{enclosureOccupiedSlotCount} : undef;
2058 $total_slots = defined $out->{enclosureTotalSlots}
2059 && $out->{enclosureTotalSlots} != 9999
2060 ? $out->{enclosureTotalSlots} : undef;
2063 $id = get_nonempty_string('ID', $out, 9999);
2064 $name = get_nonempty_string('Name', $out, 'Unknown enclosure');
2065 $state = get_nonempty_string('State', $out, 'Unknown state');
2066 $status = get_nonempty_string('Status', $out, 'Unknown');
2067 $firmware = get_nonempty_string('Firmware Version', $out, 'N/A');
2068 $firmware =~ s{Not\sApplicable}{N/A}xms;
2069 $nexus = join q{:}, $out->{ctrl}, $id;
2070 $ctrl = $out->{ctrl};
2073 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
2074 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
2076 # store enclosure data for future use
2078 $snmp_enclosure{$out->{enclosureNumber}}{id} = $id;
2079 $snmp_enclosure{$out->{enclosureNumber}}{name} = $name;
2080 $snmp_enclosure{$out->{enclosureNumber}}{nexus} = $nexus;
2083 push @enclosures, { 'id' => $id,
2084 'ctrl' => $out->{ctrl},
2088 # Collecting some storage info
2089 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
2090 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
2091 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
2093 next ENCLOSURE if blacklisted('encl', $nexus);
2096 if (defined $occupied_slots && defined $total_slots) {
2097 $msg = sprintf 'Enclosure %s [%s, %d/%d slots occupied] on ctrl %d is %s',
2098 $nexus, $name, $occupied_slots, $total_slots, $ctrl, $state;
2101 $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
2102 $nexus, $name, $ctrl, $state;
2104 report('storage', $msg, $status2nagios{$status}, $nexus);
2110 #-----------------------------------------
2111 # STORAGE: Check enclosure fans
2112 #-----------------------------------------
2113 sub check_enclosure_fans {
2114 return if $#controllers == -1;
2115 return if blacklisted('encl_fan', 'all');
2122 my $encl_id = undef;
2123 my $encl_name = undef;
2129 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2130 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2131 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2132 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2133 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2134 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2135 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2138 if ($opt{use_get_table}) {
2139 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2140 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2142 $result = $snmp_session->get_table(-baseoid => $fanTable);
2143 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2145 if (defined $result) {
2146 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2150 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2153 # No enclosure fans is OK
2154 return if !defined $result;
2156 @output = @{ get_snmp_output($result, \%fan_oid) };
2159 foreach my $enc (@enclosures) {
2160 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2161 map_item('ctrl', $enc->{ctrl}, \@output);
2162 map_item('encl_id', $enc->{id}, \@output);
2163 map_item('encl_name', $enc->{name}, \@output);
2178 # Check fans on each of the enclosures
2180 foreach my $out (@output) {
2182 $name = $out->{fanName} || 'Unknown fan';
2183 $state = get_hashval($out->{fanState}, \%fan_state) || 'Unknown state';
2184 $status = get_snmp_status($out->{fanComponentStatus});
2185 $speed = $out->{fanProbeCurrValue} || 'N/A';
2186 $encl_name = $out->{fanConnectionEnclosureName} || 'Unknown enclosure';
2187 $encl_id = $snmp_enclosure{$out->{fanConnectionEnclosureNumber}}{nexus};
2188 $nexus = convert_nexus(($out->{fanNexusID} || 9999));
2191 $name = get_nonempty_string('Name', $out, 'Unknown fan');
2192 $state = get_nonempty_string('State', $out, 'Unknown state');
2193 $status = get_nonempty_string('Status', $out, 'Unknown');
2194 $speed = get_nonempty_string('Speed', $out, 'N/A');
2195 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2196 $encl_name = $out->{encl_name};
2197 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2200 next FAN if blacklisted('encl_fan', $nexus);
2203 if ($status ne 'Ok') {
2204 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2205 $name, $encl_id, $encl_name, $state;
2206 report('storage', $msg, $status2nagios{$status}, $nexus);
2210 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2211 $name, $encl_id, $encl_name, $state, $speed;
2212 report('storage', $msg, $E_OK, $nexus);
2219 #-----------------------------------------
2220 # STORAGE: Check enclosure power supplies
2221 #-----------------------------------------
2222 sub check_enclosure_pwr {
2223 return if $#controllers == -1;
2224 return if blacklisted('encl_ps', 'all');
2230 my $encl_id = undef;
2231 my $encl_name = undef;
2237 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2238 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2239 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2240 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2241 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2242 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2245 if ($opt{use_get_table}) {
2246 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2247 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2249 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2250 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2252 if (defined $result) {
2253 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2257 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2260 # No enclosure power supplies is OK
2261 return if !defined $result;
2263 @output = @{ get_snmp_output($result, \%ps_oid) };
2266 foreach my $enc (@enclosures) {
2267 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2268 map_item('ctrl', $enc->{ctrl}, \@output);
2269 map_item('encl_id', $enc->{id}, \@output);
2270 map_item('encl_name', $enc->{name}, \@output);
2279 5 => 'Not Installed',
2285 # Check power supplies on each of the enclosures
2287 foreach my $out (@output) {
2289 $name = $out->{powerSupplyName} || 'Unknown PSU';
2290 $state = get_hashval($out->{powerSupplyState}, \%ps_state) || 'Unknown state';
2291 $status = get_snmp_status($out->{powerSupplyComponentStatus});
2292 $encl_id = $snmp_enclosure{$out->{powerSupplyConnectionEnclosureNumber}}{nexus};
2293 $encl_name = $out->{powerSupplyConnectionEnclosureName} || 'Unknown enclosure';
2294 $nexus = convert_nexus(($out->{powerSupplyNexusID} || 9999));
2297 $name = get_nonempty_string('Name', $out, 'Unknown PSU');
2298 $state = get_nonempty_string('State', $out, 'Unknown state');
2299 $status = get_nonempty_string('Status', $out, 'Unknown');
2300 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2301 $encl_name = $out->{encl_name};
2302 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2305 next PS if blacklisted('encl_ps', $nexus);
2308 if ($status ne 'Ok') {
2309 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2310 $name, $encl_id, $encl_name, $state;
2311 report('storage', $msg, $status2nagios{$status}, $nexus);
2315 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2316 $name, $encl_id, $encl_name, $state;
2317 report('storage', $msg, $E_OK, $nexus);
2324 #-----------------------------------------
2325 # STORAGE: Check enclosure temperatures
2326 #-----------------------------------------
2327 sub check_enclosure_temp {
2328 return if $#controllers == -1;
2329 return if blacklisted('encl_temp', 'all');
2335 my $reading = undef;
2337 my $max_warn = undef;
2338 my $max_crit = undef;
2339 my $min_warn = undef;
2340 my $min_crit = undef;
2341 my $encl_id = undef;
2342 my $encl_name = undef;
2348 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2349 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2350 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2351 '1.3.6.1.4.1.674.10893.1.20.130.11.1.7' => 'temperatureProbeMinWarning',
2352 '1.3.6.1.4.1.674.10893.1.20.130.11.1.8' => 'temperatureProbeMinCritical',
2353 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2354 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2355 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2356 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2357 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2358 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2359 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2362 if ($opt{use_get_table}) {
2363 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2364 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2366 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2367 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2369 if (defined $result) {
2370 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2374 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2377 # No enclosure temperature probes is OK
2378 return if !defined $result;
2380 @output = @{ get_snmp_output($result, \%temp_oid) };
2383 foreach my $enc (@enclosures) {
2384 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2385 map_item('ctrl', $enc->{ctrl}, \@output);
2386 map_item('encl_id', $enc->{id}, \@output);
2387 map_item('encl_name', $enc->{name}, \@output);
2402 # Check temperature probes on each of the enclosures
2404 foreach my $out (@output) {
2406 $name = $out->{temperatureProbeName} || 'Unknown temp probe';
2407 $state = get_hashval($out->{temperatureProbeState}, \%temp_state) || 'Unknown state';
2408 $status = get_snmp_probestatus($out->{temperatureProbeComponentStatus});
2409 $unit = $out->{temperatureProbeUnit} || 'Unknown unit';
2410 $reading = $out->{temperatureProbeCurValue} || '[N/A]';
2411 $max_warn = $out->{temperatureProbeMaxWarning} || '[N/A]';
2412 $max_crit = $out->{temperatureProbeMaxCritical} || '[N/A]';
2413 $min_warn = $out->{temperatureProbeMinWarning} || '[N/A]';
2414 $min_crit = $out->{temperatureProbeMinCritical} || '[N/A]';
2415 $encl_id = $snmp_enclosure{$out->{temperatureConnectionEnclosureNumber}}{nexus};
2416 $encl_name = $out->{temperatureConnectionEnclosureName} || 'Unknown enclosure';
2417 $nexus = convert_nexus(($out->{temperatureProbeNexusID} || 9999));
2420 $name = get_nonempty_string('Name', $out, 'Unknown temp probe');
2421 $state = get_nonempty_string('State', $out, 'Unknown state');
2422 $status = get_nonempty_string('Status', $out, 'Unknown');
2424 $reading = get_nonempty_string('Reading', $out, '[N/A]');
2425 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
2426 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
2427 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
2428 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
2429 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2430 $encl_name = $out->{encl_name};
2431 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2434 next TEMP if blacklisted('encl_temp', $nexus);
2436 # Make sure these values are integers
2437 $reading =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $reading = '[N/A]';
2438 $max_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_warn = '[N/A]';
2439 $max_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_crit = '[N/A]';
2440 $min_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_warn = '[N/A]';
2441 $min_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_crit = '[N/A]';
2443 # Inactive temp probes
2444 if ($status eq 'Unknown' and $state eq 'Inactive') {
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);
2449 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2450 my $msg = sprintf '%s in enclosure %s [%s] is critically high at %d C',
2451 $name, $encl_id, $encl_name, $reading;
2452 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2453 report('chassis', $msg, $err, $nexus);
2455 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2456 my $msg = sprintf '%s in enclosure %s [%s] is too high at %d C',
2457 $name, $encl_id, $encl_name, $reading;
2458 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2459 report('chassis', $msg, $err, $nexus);
2461 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2462 my $msg = sprintf '%s in enclosure %s [%s] is critically low at %d C',
2463 $name, $encl_id, $encl_name, $reading;
2464 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2465 report('chassis', $msg, $err, $nexus);
2467 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2468 my $msg = sprintf '%s in enclosure %s [%s] is too low at %d C',
2469 $name, $encl_id, $encl_name, $reading;
2470 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2471 report('chassis', $msg, $err, $nexus);
2474 elsif ($status ne 'Ok') {
2475 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2476 $name, $encl_id, $encl_name, $state;
2477 if (defined $reading && $reading =~ m{\A -?\d+ \z}xms) {
2478 # take into account that with certain states the
2479 # reading doesn't exist or is not an integer
2480 $msg .= sprintf ' at %s C', $reading;
2481 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2482 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2485 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2486 $min_warn, $min_crit, $max_warn, $max_crit;
2489 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2490 report('storage', $msg, $err, $nexus);
2494 my $msg = sprintf '%s in enclosure %s [%s]',
2495 $name, $encl_id, $encl_name;
2496 if (defined $reading && $reading ne '[N/A]') {
2497 # take into account that with certain states the
2498 # reading doesn't exist or is not an integer
2499 $msg .= sprintf ' reads %d C', $reading;
2500 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2501 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2504 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2505 $min_warn, $min_crit, $max_warn, $max_crit;
2509 $msg .= sprintf ' is %s', $state;
2511 report('storage', $msg, $E_OK, $nexus);
2514 # Collect performance data
2515 if (defined $opt{perfdata} && $reading ne '[N/A]') {
2516 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2517 my $label = "enclosure_${encl_id}_${name}";
2519 $mini =~ s{enclosure_(.+?)_temp_(.+?)}{e$1t$2}xms;
2533 #-----------------------------------------
2534 # STORAGE: Check enclosure management modules (EMM)
2535 #-----------------------------------------
2536 sub check_enclosure_emms {
2537 return if $#controllers == -1;
2538 return if blacklisted('encl_emm', 'all');
2544 my $encl_id = undef;
2545 my $encl_name = undef;
2551 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2552 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2553 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2554 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2555 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2556 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2559 if ($opt{use_get_table}) {
2560 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2561 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2563 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2564 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2566 if (defined $result) {
2567 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2571 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2574 # No enclosure EMMs is OK
2575 return if !defined $result;
2577 @output = @{ get_snmp_output($result, \%emms_oid) };
2580 foreach my $enc (@enclosures) {
2581 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2582 map_item('ctrl', $enc->{ctrl}, \@output);
2583 map_item('encl_id', $enc->{id}, \@output);
2584 map_item('encl_name', $enc->{name}, \@output);
2595 5 => 'Not Installed',
2600 # Check EMMs on each of the enclosures
2602 foreach my $out (@output) {
2604 $name = $out->{enclosureManagementModuleName} || 'Unknown EMM';
2605 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state) || 'Unknown state';
2606 $status = get_snmp_status($out->{enclosureManagementModuleComponentStatus});
2607 $encl_id = $snmp_enclosure{$out->{enclosureManagementModuleConnectionEnclosureNumber}}{nexus};
2608 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName} || 'Unknown enclosure';
2609 $nexus = convert_nexus(($out->{enclosureManagementModuleNexusID} || 9999));
2612 $name = get_nonempty_string('Name', $out, 'Unknown EMM');
2613 $state = get_nonempty_string('State', $out, 'Unknown state');
2614 $status = get_nonempty_string('Status', $out, 'Unknown');
2615 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2616 $encl_name = $out->{encl_name};
2617 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2620 next EMM if blacklisted('encl_emm', $nexus);
2623 if ($status =~ m{\A Other|Unknown \z}xms and $state eq 'Not Installed') {
2624 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2625 $name, $encl_id, $encl_name, $state;
2626 report('storage', $msg, $E_OK, $nexus);
2629 elsif ($status ne 'Ok') {
2630 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2631 $name, $encl_id, $encl_name, $state;
2632 report('storage', $msg, $status2nagios{$status}, $nexus);
2636 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2637 $name, $encl_id, $encl_name, $state;
2638 report('storage', $msg, $E_OK, $nexus);
2645 #-----------------------------------------
2646 # CHASSIS: Check memory modules
2647 #-----------------------------------------
2649 return if blacklisted('dimm', 'all');
2653 my $location = undef;
2662 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2663 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2664 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2665 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2666 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2669 if ($opt{use_get_table}) {
2670 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2671 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2674 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2677 if (!defined $result) {
2678 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2679 $snmp_session->close;
2683 @output = @{ get_snmp_output($result, \%dimm_oid) };
2686 @output = @{ run_omreport("$omopt_chassis memory") };
2689 # Note: These values are bit masks, so combination values are
2690 # possible. If value is 0 (zero), memory device has no faults.
2693 1 => 'ECC single bit correction warning rate exceeded',
2694 2 => 'ECC single bit correction failure rate exceeded',
2695 4 => 'ECC multibit fault encountered',
2696 8 => 'ECC single bit correction logging disabled',
2697 16 => 'device disabled because of spare activation',
2701 foreach my $out (@output) {
2702 @failures = (); # Initialize
2704 $index = ($out->{memoryDeviceIndex} || 10000) - 1;
2705 $status = get_snmp_status($out->{memoryDeviceStatus});
2706 $location = $out->{memoryDeviceLocationName} || 'Unknown location';
2707 $size = sprintf '%d MB', ($out->{memoryDeviceSize} || 0)/1024;
2708 $modes = $out->{memoryDeviceFailureModes} || -9999;
2710 foreach my $mask (sort keys %failure_mode) {
2711 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2714 elsif ($modes == -9999) {
2715 push @failures, q{ERROR: Failure modes not available via SNMP};
2719 my $type = get_nonempty_string('Type', $out, q{});
2720 $index = $type eq '[Not Occupied]' ? undef : get_nonempty_string('Index', $out, 9999);
2721 $status = get_nonempty_string('Status', $out, 'Unknown');
2722 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
2723 $size = get_nonempty_string('Size', $out, 0);
2724 if (defined $size) {
2725 $size =~ s{\s\s}{ }gxms;
2727 # Run 'omreport chassis memory index=X' to get the failures
2728 if ($status ne 'Ok' && defined $index) {
2729 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2730 if (m/\A Failures; (.+?) \z/xms) {
2731 chop(my $fail = $1);
2732 push @failures, split m{\.}xms, $fail;
2737 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2739 # calculate total memory
2740 my $msize = defined $size ? $size : 0;
2741 $msize =~ s{\A (\d+) \s MB}{$1}xms;
2742 $count{mem} += $msize;
2744 next DIMM if blacklisted('dimm', $index);
2746 # Ignore empty memory slots
2747 next DIMM if !defined $index;
2750 if ($status ne 'Ok') {
2752 if (scalar @failures == 0) {
2753 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2754 $index, $location, $size, $status;
2757 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2758 $index, $location, $size, (join q{, }, @failures);
2761 report('chassis', $msg, $status2nagios{$status}, $index);
2765 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2766 $index, $location, $size, $status;
2767 report('chassis', $msg, $E_OK, $index);
2774 #-----------------------------------------
2775 # CHASSIS: Check fans
2776 #-----------------------------------------
2778 return if blacklisted('fan', 'all');
2782 my $reading = undef;
2783 my $location = undef;
2784 my $max_crit = undef;
2785 my $max_warn = undef;
2791 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2792 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2793 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2794 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2795 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2796 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2799 if ($opt{use_get_table}) {
2800 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2801 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2804 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2807 if ($blade && !defined $result) {
2810 elsif (!$blade && !defined $result) {
2811 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2812 $snmp_session->close;
2816 @output = @{ get_snmp_output($result, \%cool_oid) };
2819 @output = @{ run_omreport("$omopt_chassis fans") };
2823 foreach my $out (@output) {
2825 $index = ($out->{coolingDeviceIndex} || 10000) - 1;
2826 $status = get_snmp_probestatus($out->{coolingDeviceStatus});
2827 $reading = $out->{coolingDeviceReading} || 0;
2828 $location = $out->{coolingDeviceLocationName} || 'Unknown location';
2829 $max_crit = $out->{coolingDeviceUpperCriticalThreshold} || 0;
2830 $max_warn = $out->{coolingDeviceUpperNonCriticalThreshold} || 0;
2833 $index = get_nonempty_string('Index', $out, 9999);
2834 $status = get_nonempty_string('Status', $out, 'Unknown');
2835 $reading = get_nonempty_string('Reading', $out, 0);
2836 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
2837 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, 0);
2838 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, 0);
2839 if ($max_crit eq '[N/A]') { $max_crit = 0; }
2840 if ($max_warn eq '[N/A]') { $max_warn = 0; }
2841 $reading =~ s{\A (\d+).* \z}{$1}xms;
2842 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2843 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2846 next FAN if blacklisted('fan', $index);
2849 if ($status ne 'Ok') {
2850 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2851 $index, $location, $status;
2852 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2853 report('chassis', $msg, $err, $index);
2856 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2857 $index, $location, $reading;
2858 report('chassis', $msg, $E_OK, $index);
2861 # Collect performance data
2862 if (defined $opt{perfdata}) {
2863 my $pname = lc $location;
2864 $pname =~ s{\s}{_}gxms;
2865 $pname =~ s{proc_}{cpu#}xms;
2867 label => "fan_${index}_${pname}",
2879 #-----------------------------------------
2880 # CHASSIS: Check power supplies
2881 #-----------------------------------------
2882 sub check_powersupplies {
2883 return if blacklisted('ps', 'all');
2888 my $err_type = undef;
2896 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2897 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2898 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2899 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2900 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2903 if ($opt{use_get_table}) {
2904 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2905 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2908 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2911 # No instrumented PSU is OK (blades, low-end servers)
2912 return 0 if !defined $result;
2914 @output = @{ get_snmp_output($result, \%ps_oid) };
2917 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2927 6 => 'Uninterruptible Power Supply',
2937 1 => 'Presence detected',
2938 2 => 'Failure detected',
2939 4 => 'Predictive Failure',
2941 16 => 'AC lost or out-of-range',
2942 32 => 'AC out-of-range but present',
2943 64 => 'Configuration error',
2946 my %ps_config_error_type
2948 1 => 'Vendor mismatch',
2949 2 => 'Revision mismatch',
2950 3 => 'Processor missing',
2954 foreach my $out (@output) {
2956 @states = (); # contains states for the PS
2958 $index = ($out->{powerSupplyIndex} || 10000) - 1;
2959 $status = get_snmp_status($out->{powerSupplyStatus});
2960 $type = get_hashval($out->{powerSupplyType}, \%ps_type) || 'Unknown type';
2961 $err_type = get_hashval($out->{powerSupplyConfigurationErrorType}, \%ps_config_error_type);
2963 # get the combined state from the StatusReading OID
2964 my $raw_state = $out->{powerSupplySensorState} || 0;
2965 foreach my $mask (sort keys %ps_state) {
2966 if (($raw_state & $mask) != 0) {
2967 push @states, $ps_state{$mask};
2971 # If configuration error, also include the error type
2972 if (defined $err_type) {
2973 push @states, $err_type;
2976 # Finally, construct the state string
2977 $state = join q{, }, @states;
2980 $index = get_nonempty_string('Index', $out, 9999);
2981 $status = get_nonempty_string('Status', $out, 'Unknown');
2982 $type = get_nonempty_string('Type', $out, 'Unknown type');
2983 $state = get_nonempty_string('Online Status', $out, 'Unknown state');
2986 next PS if blacklisted('ps', $index);
2989 if ($status ne 'Ok') {
2990 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2991 $index, $type, $state;
2992 report('chassis', $msg, $status2nagios{$status}, $index);
2995 my $msg = sprintf 'Power Supply %d [%s]: %s',
2996 $index, $type, $state;
2997 report('chassis', $msg, $E_OK, $index);
3004 #-----------------------------------------
3005 # CHASSIS: Check temperatures
3006 #-----------------------------------------
3007 sub check_temperatures {
3008 return if blacklisted('temp', 'all');
3012 my $reading = undef;
3013 my $location = undef;
3014 my $max_crit = undef;
3015 my $max_warn = undef;
3016 my $min_warn = undef;
3017 my $min_crit = undef;
3019 my $discrete = undef;
3022 # Getting custom temperature thresholds (user option)
3023 my %warn_threshold = %{ custom_temperature_thresholds('w') };
3024 my %crit_threshold = %{ custom_temperature_thresholds('c') };
3029 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
3030 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
3031 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
3032 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
3033 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
3034 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
3035 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
3036 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
3037 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
3038 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
3040 # this didn't work well for some reason
3041 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
3043 # Getting values using the table
3044 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
3045 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
3047 if (!defined $result) {
3048 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
3049 $snmp_session->close;
3053 @output = @{ get_snmp_output($result, \%temp_oid) };
3056 @output = @{ run_omreport("$omopt_chassis temps") };
3061 1 => 'Other', # type is other than following values
3062 2 => 'Unknown', # type is unknown
3063 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
3064 16 => 'Discrete', # type is temperature probe with discrete reading
3068 foreach my $out (@output) {
3070 $index = ($out->{temperatureProbeIndex} || 10000) - 1;
3071 $status = get_snmp_probestatus($out->{temperatureProbeStatus});
3072 $location = $out->{temperatureProbeLocationName} || 'Unknown location';
3073 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
3074 $reading = $out->{temperatureProbeReading} || '[N/A]';
3075 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} || '[N/A]';
3076 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} || '[N/A]';
3077 $min_crit = $out->{temperatureProbeLowerCriticalThreshold} || '[N/A]';
3078 $min_warn = $out->{temperatureProbeLowerNonCriticalThreshold} || '[N/A]';
3079 $discrete = $out->{temperatureProbeDiscreteReading} || '[N/A]';
3081 # If numeric values, i.e. not discrete
3082 $reading /= 10 if $reading =~ m{\A \d+ \z}xms;
3083 $max_crit /= 10 if $max_crit =~ m{\A \d+ \z}xms;
3084 $max_warn /= 10 if $max_warn =~ m{\A \d+ \z}xms;
3085 $min_crit /= 10 if $min_crit =~ m{\A \d+ \z}xms;
3086 $min_warn /= 10 if $min_warn =~ m{\A \d+ \z}xms;
3088 # workaround for bad temp probes
3089 if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
3094 $index = get_nonempty_string('Index', $out, 9999);
3095 $status = get_nonempty_string('Status', $out, 'Unknown');
3096 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3097 $reading = get_nonempty_string('Reading', $out, '[N/A]');
3098 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
3099 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
3100 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
3101 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
3103 # Cleaning the temp readings
3104 $reading =~ s{\.0\s+C}{}xms;
3105 $max_crit =~ s{\.0\s+C}{}xms;
3106 $max_warn =~ s{\.0\s+C}{}xms;
3107 $min_crit =~ s{\.0\s+C}{}xms;
3108 $min_warn =~ s{\.0\s+C}{}xms;
3110 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
3111 $discrete = $reading;
3114 next TEMP if blacklisted('temp', $index);
3117 if ($type eq 'Discrete') {
3118 my $msg = sprintf 'Temperature probe %d [%s] is %s',
3119 $index, $location, $discrete;
3120 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3121 report('chassis', $msg, $err, $index);
3124 # First check according to custom thresholds
3125 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
3126 # Custom critical MAX
3127 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3128 $index, $location, $reading, $crit_threshold{$index}{max};
3129 report('chassis', $msg, $E_CRITICAL, $index);
3131 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
3132 # Custom warning MAX
3133 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3134 $index, $location, $reading, $warn_threshold{$index}{max};
3135 report('chassis', $msg, $E_WARNING, $index);
3137 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
3138 # Custom critical MIN
3139 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3140 $index, $location, $reading, $crit_threshold{$index}{min};
3141 report('chassis', $msg, $E_CRITICAL, $index);
3143 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
3144 # Custom warning MIN
3145 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3146 $index, $location, $reading, $warn_threshold{$index}{min};
3147 report('chassis', $msg, $E_WARNING, $index);
3149 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
3150 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
3151 $index, $location, $reading;
3152 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3153 report('chassis', $msg, $err, $index);
3155 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
3156 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
3157 $index, $location, $reading;
3158 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3159 report('chassis', $msg, $err, $index);
3161 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
3162 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
3163 $index, $location, $reading;
3164 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3165 report('chassis', $msg, $err, $index);
3167 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
3168 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
3169 $index, $location, $reading;
3170 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3171 report('chassis', $msg, $err, $index);
3175 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
3176 $index, $location, $reading;
3177 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
3178 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
3181 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
3182 $min_warn, $min_crit, $max_warn, $max_crit;
3184 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3185 report('chassis', $msg, $err, $index);
3188 # Collect performance data
3189 if (defined $opt{perfdata}) {
3190 my $pname = lc $location;
3191 $pname =~ s{\s}{_}gxms;
3192 $pname =~ s{_temp\z}{}xms;
3193 $pname =~ s{proc_}{cpu#}xms;
3195 label => "temp_${index}_${pname}",
3208 #-----------------------------------------
3209 # CHASSIS: Check processors
3210 #-----------------------------------------
3211 sub check_processors {
3212 return if blacklisted('cpu', 'all');
3225 # NOTE: For some reason, older models don't have the
3226 # "Processor Device Status" OIDs. We check both the newer
3227 # (preferred) OIDs and the old ones.
3231 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3232 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3233 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3234 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3235 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3236 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3237 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3238 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3239 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3240 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3243 if ($opt{use_get_table}) {
3244 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3245 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3247 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3248 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3250 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3253 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3256 if (!defined $result) {
3257 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3258 $snmp_session->close;
3262 @output = @{ get_snmp_output($result, \%cpu_oid) };
3265 @output = @{ run_omreport("$omopt_chassis processors") };
3270 1 => 'Other', # other than following values
3271 2 => 'Unknown', # unknown
3272 3 => 'Enabled', # enabled
3273 4 => 'User Disabled', # disabled by user via BIOS setup
3274 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3280 1 => 'Internal Error', # Internal Error
3281 2 => 'Thermal Trip', # Thermal Trip
3282 32 => 'Configuration Error', # Configuration Error
3283 128 => 'Present', # Processor Present
3284 256 => 'Disabled', # Processor Disabled
3285 512 => 'Terminator Present', # Terminator Present
3286 1024 => 'Throttled', # Processor Throttled
3289 # Mapping between family numbers from SNMP and actual CPU family
3292 1 => 'Other', 2 => 'Unknown',
3293 3 => '8086', 4 => '80286',
3294 5 => '386', 6 => '486',
3295 7 => '8087', 8 => '80287',
3296 9 => '80387', 10 => '80487',
3297 11 => 'Pentium', 12 => 'Pentium Pro',
3298 13 => 'Pentium II', 14 => 'Pentium with MMX',
3299 15 => 'Celeron', 16 => 'Pentium II Xeon',
3300 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3301 19 => 'Pentium III', 20 => 'Itanium',
3302 21 => 'Xeon', 22 => 'Pentium 4',
3303 23 => 'Xeon MP', 24 => 'Itanium 2',
3304 25 => 'K5', 26 => 'K6',
3305 27 => 'K6-2', 28 => 'K6-3',
3306 29 => 'Athlon', 30 => 'AMD2900',
3307 31 => 'K6-2+', 32 => 'Power PC',
3308 33 => 'Power PC 601', 34 => 'Power PC 603',
3309 35 => 'Power PC 603+', 36 => 'Power PC 604',
3310 37 => 'Power PC 620', 38 => 'Power PC x704',
3311 39 => 'Power PC 750', 40 => 'Core Duo',
3312 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3313 43 => 'Intel Atom', 44 => undef,
3314 45 => undef, 46 => undef,
3315 47 => undef, 48 => 'Alpha',
3316 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3317 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3318 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3319 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3320 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3321 59 => 'Opteron 6100', 60 => 'Opteron 4100',
3322 61 => undef, 62 => undef,
3323 63 => undef, 64 => 'MIPS',
3324 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3325 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3326 69 => 'MIPS R10000', 70 => undef,
3327 71 => undef, 72 => undef,
3328 73 => undef, 74 => undef,
3329 75 => undef, 76 => undef,
3330 77 => undef, 78 => undef,
3331 79 => undef, 80 => 'SPARC',
3332 81 => 'SuperSPARC', 82 => 'microSPARC II',
3333 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3334 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3335 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3336 89 => undef, 90 => undef,
3337 91 => undef, 92 => undef,
3338 93 => undef, 94 => undef,
3339 95 => undef, 96 => '68040',
3340 97 => '68xxx', 98 => '68000',
3341 99 => '68010', 100 => '68020',
3342 101 => '68030', 102 => undef,
3343 103 => undef, 104 => undef,
3344 105 => undef, 106 => undef,
3345 107 => undef, 108 => undef,
3346 109 => undef, 110 => undef,
3347 111 => undef, 112 => 'Hobbit',
3348 113 => undef, 114 => undef,
3349 115 => undef, 116 => undef,
3350 117 => undef, 118 => undef,
3351 119 => undef, 120 => 'Crusoe TM5000',
3352 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3353 123 => undef, 124 => undef,
3354 125 => undef, 126 => undef,
3355 127 => undef, 128 => 'Weitek',
3356 129 => undef, 130 => 'Celeron M',
3357 131 => 'Athlon 64', 132 => 'Opteron',
3358 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3359 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3360 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3361 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3362 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3363 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3364 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3365 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3366 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3367 151 => undef, 152 => undef,
3368 153 => undef, 154 => undef,
3369 155 => undef, 156 => undef,
3370 157 => undef, 158 => undef,
3371 159 => undef, 160 => 'V30',
3372 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3373 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3374 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3375 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3376 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3377 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3378 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3379 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3380 177 => 'M2', 178 => undef,
3381 179 => 'Pentium 4 HT', 180 => 'AS400',
3382 181 => undef, 182 => 'Athlon XP',
3383 183 => 'Athlon MP', 184 => 'Duron',
3384 185 => 'Pentium M', 186 => 'Celeron D',
3385 187 => 'Pentium D', 188 => 'Pentium Extreme',
3386 189 => 'Core Solo', 190 => 'Core2',
3387 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3388 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3389 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3390 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3391 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3392 201 => 'G4', 202 => 'G5',
3393 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3394 205 => 'Core i5', 206 => 'Core i3',
3395 207 => undef, 208 => undef,
3396 209 => undef, 210 => 'C7-M',
3397 211 => 'C7-D', 212 => 'C7',
3398 213 => 'Eden', 214 => 'Multi-Core Xeon',
3399 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3400 217 => 'VIA Nano', 218 => 'Dual-Core Xeon 5xxx',
3401 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3402 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3403 223 => 'Multi-Core Xeon 7xxx', 224 => 'Multi-Core Xeon 3400',
3404 225 => undef, 226 => undef,
3405 227 => undef, 228 => undef,
3406 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3407 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3408 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3409 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3410 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3411 239 => 'AMD Sempron M', 240 => undef,
3412 241 => undef, 242 => undef,
3413 243 => undef, 244 => undef,
3414 245 => undef, 246 => undef,
3415 247 => undef, 248 => undef,
3416 249 => undef, 250 => 'i860',
3421 foreach my $out (@output) {
3423 $index = exists $out->{processorDeviceStatusIndex}
3424 ? ($out->{processorDeviceStatusIndex} || 10000) - 1
3425 : ($out->{processorDeviceIndex} || 10000) - 1;
3426 $status = exists $out->{processorDeviceStatusStatus}
3427 ? get_snmp_status($out->{processorDeviceStatusStatus})
3428 : get_snmp_status($out->{processorDeviceStatus});
3429 if (defined $out->{processorDeviceStatusReading}) {
3430 my @states = (); # contains states for the CPU
3432 # get the combined state from the StatusReading OID
3433 foreach my $mask (sort keys %cpu_reading) {
3434 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3435 push @states, $cpu_reading{$mask};
3439 # Finally, create the state string
3440 $state = join q{, }, @states;
3443 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state) || 'Unknown state';
3445 $man = $out->{processorDeviceManufacturerName} || undef;
3446 $family = (defined $out->{processorDeviceFamily}
3447 and defined $cpu_family{$out->{processorDeviceFamily}})
3448 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3449 $speed = $out->{processorDeviceCurrentSpeed} || undef;
3450 $brand = $out->{processorDeviceBrandName} || undef;
3453 $index = get_nonempty_string('Index', $out, 9999);
3454 $status = get_nonempty_string('Status', $out, 'Unknown');
3455 $state = get_nonempty_string('State', $out, 'Unknown state');
3456 $brand = get_nonempty_string('Processor Brand', $out, undef);
3457 $family = get_nonempty_string('Processor Family', $out, undef);
3458 $man = get_nonempty_string('Processor Manufacturer', $out, undef);
3459 $speed = get_nonempty_string('Current Speed', $out, undef);
3462 next CPU if blacklisted('cpu', $index);
3464 # Ignore unoccupied CPU slots (omreport)
3465 next CPU if (defined $out->{'Processor Manufacturer'}
3466 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3467 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3469 # Ignore unoccupied CPU slots (snmp)
3470 if ($snmp and defined $out->{processorDeviceStatusReading}
3471 and $out->{processorDeviceStatusReading} == 0) {
3477 if (defined $brand) {
3478 $brand =~ s{\s\s+}{ }gxms;
3479 $brand =~ s{\((R|tm)\)}{}gxms;
3480 $brand =~ s{\s(CPU|Processor)}{}xms;
3481 $brand =~ s{\s\@}{}xms;
3483 elsif (defined $family and defined $man and defined $speed) {
3484 $speed =~ s{\A (\d+) .*}{$1}xms;
3485 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3492 if ($status ne 'Ok') {
3493 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3494 $index, $brand, $state;
3495 report('chassis', $msg, $status2nagios{$status}, $index);
3499 my $msg = sprintf 'Processor %d [%s] is %s',
3500 $index, $brand, $state;
3501 report('chassis', $msg, $E_OK, $index);
3508 #-----------------------------------------
3509 # CHASSIS: Check voltage probes
3510 #-----------------------------------------
3512 return if blacklisted('volt', 'all');
3516 my $reading = undef;
3517 my $location = undef;
3523 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3524 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3525 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3526 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3527 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3530 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3531 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3533 if (!defined $result) {
3534 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3535 $snmp_session->close;
3539 @output = @{ get_snmp_output($result, \%volt_oid) };
3542 @output = @{ run_omreport("$omopt_chassis volts") };
3545 my %volt_discrete_reading
3552 foreach my $out (@output) {
3554 $index = ($out->{voltageProbeIndex} || 10000) - 1;
3555 $status = get_snmp_probestatus($out->{voltageProbeStatus});
3556 $reading = defined $out->{voltageProbeReading}
3557 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3558 : get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading);
3559 $location = $out->{voltageProbeLocationName} || 'Unknown location';
3562 $index = get_nonempty_string('Index', $out, 9999);
3563 $status = get_nonempty_string('Status', $out, 'Unknown');
3564 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3565 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3568 next VOLT if blacklisted('volt', $index);
3571 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3572 $index, $location, $reading;
3573 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3574 report('chassis', $msg, $err, $index);
3580 #-----------------------------------------
3581 # CHASSIS: Check batteries
3582 #-----------------------------------------
3583 sub check_batteries {
3584 return if blacklisted('bp', 'all');
3588 my $reading = undef;
3589 my $location = undef;
3595 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3596 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3597 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3598 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3601 if ($opt{use_get_table}) {
3602 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3603 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3606 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3609 # No batteries is OK
3610 return 0 if !defined $result;
3612 @output = @{ get_snmp_output($result, \%bat_oid) };
3615 @output = @{ run_omreport("$omopt_chassis batteries") };
3620 1 => 'Predictive Failure',
3622 4 => 'Presence Detected',
3626 foreach my $out (@output) {
3628 $index = ($out->{batteryIndex} || 10000) - 1;
3629 $status = get_snmp_status($out->{batteryStatus});
3630 $reading = get_hashval($out->{batteryReading}, \%bat_reading) || 'Unknown reading';
3631 $location = $out->{batteryLocationName} || 'Unknown location';
3634 $index = get_nonempty_string('Index', $out, 9999);
3635 $status = get_nonempty_string('Status', $out, 'Unknown');
3636 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3637 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3640 next BATTERY if blacklisted('bp', $index);
3643 my $msg = sprintf 'Battery probe %d [%s] is %s',
3644 $index, $location, $reading;
3645 report('chassis', $msg, $status2nagios{$status}, $index);
3651 #-----------------------------------------
3652 # CHASSIS: Check amperage probes (power monitoring)
3653 #-----------------------------------------
3654 sub check_pwrmonitoring {
3655 return if blacklisted('amp', 'all');
3659 my $reading = undef;
3660 my $location = undef;
3661 my $max_crit = undef;
3662 my $max_warn = undef;
3670 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3671 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3672 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3673 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3674 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3675 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3676 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3677 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3680 if ($opt{use_get_table}) {
3681 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3682 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3685 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3688 # No pwrmonitoring is OK
3689 return 0 if !defined $result;
3691 @output = @{ get_snmp_output($result, \%amp_oid) };
3694 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3697 my %amp_type # Amperage probe types
3699 1 => 'amperageProbeTypeIsOther', # other than following values
3700 2 => 'amperageProbeTypeIsUnknown', # unknown
3701 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3702 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3703 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3704 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3705 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3706 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3707 9 => 'amperageProbeTypeIsIO', # I/O probe
3708 10 => 'amperageProbeTypeIsCore', # Core probe
3709 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3710 12 => 'amperageProbeTypeIsBattery', # Battery probe
3711 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3712 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3713 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3714 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3715 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3716 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3717 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3718 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3729 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3730 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3731 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3732 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3733 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3737 foreach my $out (@output) {
3739 $index = ($out->{amperageProbeIndex} || 10000) - 1;
3740 $status = get_snmp_probestatus($out->{amperageProbeStatus});
3741 $type = get_hashval($out->{amperageProbeType}, \%amp_type);
3742 $reading = $type eq 'amperageProbeTypeIsDiscrete'
3743 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3744 : ($out->{amperageProbeReading} || 0);
3745 $location = $out->{amperageProbeLocationName} || 'Unknown location';
3746 $max_crit = $out->{amperageProbeUpperCriticalThreshold} || 0;
3747 $max_warn = $out->{amperageProbeUpperNonCriticalThreshold} || 0;
3748 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3749 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3751 # calculate proper values and set unit for ampere probes
3752 if ($unit eq 'hA' and $type ne 'amperageProbeTypeIsDiscrete') {
3760 $index = get_nonempty_string('Index', $out, 9999);
3761 $status = get_nonempty_string('Status', $out, 'Unknown');
3762 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3763 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3764 $max_crit = get_nonempty_string('Failure Threshold', $out, 0);
3765 $max_warn = get_nonempty_string('Warning Threshold', $out, 0);
3767 $max_crit = 0 if $max_crit eq '[N/A]';
3768 $max_warn = 0 if $max_warn eq '[N/A]';
3770 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3771 $unit = $2 || 'unknown';
3772 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3773 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3776 next AMP if blacklisted('amp', $index);
3777 next AMP if $index !~ m{\A \d+ \z}xms;
3779 # Special case: Probe is present but unknown. This happens via
3780 # SNMP on some systems where power monitoring capability is
3781 # disabled due to non-redundant and/or non-instrumented power
3783 # E.g. R410 with newer BMC firmware and 1 power supply
3784 if ($snmp && $status eq 'Unknown' && $reading eq '[N/A]') {
3790 # Special case: Discrete reading
3791 if (defined $type and $type eq 'amperageProbeTypeIsDiscrete') {
3792 my $msg = sprintf 'Amperage probe %d [%s] is %s',
3793 $index, $location, $reading;
3794 report('chassis', $msg, $status2nagios{$status}, $index);
3798 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3799 $index, $location, $reading, $unit;
3800 report('chassis', $msg, $status2nagios{$status}, $index);
3803 # Collect performance data
3804 if (defined $opt{perfdata}) {
3805 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3806 my $label = join q{_}, 'pwr_mon', $index, lc $location;
3807 $label =~ s{\s}{_}gxms;
3810 mini => "p${index}" . lc $unit,
3818 # Collect EXTRA performance data not found at first run. This is a
3820 if (defined $opt{perfdata} && !$snmp) {
3826 foreach (@perfdata) {
3827 if ($_->{label} =~ m/\A pwr_mon_(\d+)/xms) {
3833 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3835 if ($line eq 'Location;Reading') {
3843 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s [AW] \z/xms) {
3846 $aname =~ s{\s}{_}gxms;
3848 # don't use an existing index
3849 while (exists $used{$index}) { ++$index; }
3852 label => "pwr_mon_${index}_${aname}",
3853 mini => "p${index}a",
3867 #-----------------------------------------
3868 # CHASSIS: Check intrusion
3869 #-----------------------------------------
3870 sub check_intrusion {
3871 return if blacklisted('intr', 'all');
3875 my $reading = undef;
3881 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3882 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3883 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3886 if ($opt{use_get_table}) {
3887 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3888 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3891 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3894 # No intrusion is OK
3895 return 0 if !defined $result;
3897 @output = @{ get_snmp_output($result, \%int_oid) };
3900 @output = @{ run_omreport("$omopt_chassis intrusion") };
3905 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3906 2 => 'Breached', # chassis currently breached
3907 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3908 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3912 foreach my $out (@output) {
3914 $index = ($out->{intrusionIndex} || 10000) - 1;
3915 $status = get_snmp_status($out->{intrusionStatus});
3916 $reading = get_hashval($out->{intrusionReading}, \%int_reading) || 'Unknown reading';
3919 $index = get_nonempty_string('Index', $out, 9999);
3920 $status = get_nonempty_string('Status', $out, 'Unknown');
3921 $reading = get_nonempty_string('State', $out, 'Unknown reading');
3924 next INTRUSION if blacklisted('intr', $index);
3927 if ($status ne 'Ok') {
3928 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3930 report('chassis', $msg, $E_WARNING, $index);
3934 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3935 $index, $status, $reading;
3936 report('chassis', $msg, $E_OK, $index);
3943 #-----------------------------------------
3944 # CHASSIS: Check SD Card Device
3945 #-----------------------------------------
3947 return if blacklisted('sdcard', 'all');
3952 my $location = undef;
3953 my $capacity = undef;
3954 my $setting = undef;
3960 '1.3.6.1.4.1.674.10892.1.1100.112.1.2.1' => 'sdCardDeviceIndex',
3961 '1.3.6.1.4.1.674.10892.1.1100.112.1.3.1' => 'sdCardDeviceStatus',
3962 '1.3.6.1.4.1.674.10892.1.1100.112.1.4.1' => 'sdCardDeviceType',
3963 '1.3.6.1.4.1.674.10892.1.1100.112.1.7.1' => 'sdCardDeviceLocationName',
3964 '1.3.6.1.4.1.674.10892.1.1100.112.1.8.1' => 'sdCardDeviceCardPresent',
3965 '1.3.6.1.4.1.674.10892.1.1100.112.1.9.1' => 'sdCardDeviceCardState',
3966 '1.3.6.1.4.1.674.10892.1.1100.112.1.10.1' => 'sdCardDeviceCardStorageSize',
3969 if ($opt{use_get_table}) {
3970 my $sdCardDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.112.1';
3971 $result = $snmp_session->get_table(-baseoid => $sdCardDeviceTable);
3974 $result = $snmp_session->get_entries(-columns => [keys %sd_oid]);
3978 return 0 if !defined $result;
3980 @output = @{ get_snmp_output($result, \%sd_oid) };
3983 @output = @{ run_omreport("$omopt_chassis removableflashmedia") };
3986 # Note: These values are bit fields, so combination values are possible.
3989 0 => 'None', # state is none of the following:
3990 1 => 'Present', # device is present
3991 2 => 'IPMI-ready', # device is IPMI ready
3992 4 => 'Full-ready', # device is full ready
3993 8 => 'Offline', # device is offline
3994 16 => 'Failed', # device is failed
3995 32 => 'Active', # device is active
3996 64 => 'Bootable', # device is bootable
3997 128 => 'Write-protected', # device is write-protected
3998 256 => 'Standby', # device is in standby mode
4003 foreach my $out (@output) {
4005 $index = ($out->{sdCardDeviceIndex} || 10000) - 1;
4006 $status = get_snmp_status($out->{sdCardDeviceStatus});
4008 if (defined $out->{sdCardDeviceCardState}) {
4009 my @states = (); # contains states SD card
4011 # get the combined state from the Device Status OID
4012 foreach my $mask (sort keys %sd_state) {
4013 if (($out->{sdCardDeviceCardState} & $mask) != 0) {
4014 push @states, $sd_state{$mask};
4018 # Finally, create the state string
4019 $state = join q{, }, @states;
4021 # special case: absent
4022 if ($out->{sdCardDeviceCardState} % 2 == 0) {
4027 $location = $out->{sdCardDeviceLocationName} || 'Unknown location';
4028 $capacity = sprintf '%s MB', ($out->{sdCardDeviceCardStorageSize} || 'Unknown size');
4032 $status = get_nonempty_string('Status', $out, 'Ok');
4033 $state = get_nonempty_string('State', $out, 'Unknown state');
4034 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
4035 $capacity = get_nonempty_string('Storage Size', $out, 'Unknown size');
4037 $capacity =~ s{\[Not Available\]}{Unknown Size};
4040 next SDCARD if blacklisted('sd', $index);
4041 $count{sd}++ if $state ne 'Absent';
4043 if ($status ne 'Ok') {
4044 my $msg = sprintf 'SD Card %d needs attention: %s',
4046 report('chassis', $msg, $E_WARNING, $index);
4048 # Special case: Not Present
4049 elsif ($status eq 'Ok' and $state eq 'Absent') {
4050 my $msg = sprintf 'SD Card %d [%s] is %s',
4051 $index, $location, $state;
4052 report('chassis', $msg, $E_OK, $index);
4056 my $msg = sprintf 'SD Card %d [%s, %s] is %s',
4057 $index, $location, $capacity, $state;
4058 report('chassis', $msg, $E_OK, $index);
4065 #-----------------------------------------
4066 # CHASSIS: Check alert log
4067 #-----------------------------------------
4068 sub check_alertlog {
4069 return if $snmp; # Not supported with SNMP
4071 my @output = @{ run_omreport("$omopt_system alertlog") };
4072 foreach my $out (@output) {
4073 ++$count{alert}{$out->{Severity}};
4076 # Create error messages and set exit value if appropriate
4078 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
4079 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4081 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
4082 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
4083 report('other', $msg, $err);
4088 #-----------------------------------------
4089 # CHASSIS: Check ESM log overall health
4090 #-----------------------------------------
4091 sub check_esmlog_health {
4095 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
4096 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
4097 if (!defined $result) {
4098 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
4099 $snmp_session->error;
4100 report('other', $msg, $E_UNKNOWN);
4102 $health = get_snmp_status($result->{$systemStateEventLogStatus});
4105 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
4106 if (m/\A Health;(.+) \z/xms) {
4114 # If the overall health of the ESM log is other than "Ok", the
4115 # fill grade of the log is more than 80% and the log should be
4117 if ($health eq 'Ok') {
4118 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
4119 report('other', $msg, $E_OK);
4121 elsif ($health eq 'Critical') {
4122 my $msg = sprintf 'ESM log is 100%% full';
4123 report('other', $msg, $status2nagios{$health});
4126 my $msg = sprintf 'ESM log is more than 80%% full';
4127 report('other', $msg, $status2nagios{$health});
4133 #-----------------------------------------
4134 # CHASSIS: Check ESM log
4135 #-----------------------------------------
4142 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
4144 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
4147 return if !defined $result;
4149 @output = @{ get_snmp_output($result, \%esm_oid) };
4150 foreach my $out (@output) {
4151 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
4155 @output = @{ run_omreport("$omopt_system esmlog") };
4156 foreach my $out (@output) {
4157 ++$count{esm}{$out->{Severity}};
4161 # Create error messages and set exit value if appropriate
4163 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
4164 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4166 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
4167 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
4168 report('other', $msg, $err);
4174 # Handy function for checking all storage components
4177 check_controllers();
4178 check_physical_disks();
4179 check_virtual_disks();
4180 check_cache_battery();
4183 check_enclosure_fans();
4184 check_enclosure_pwr();
4185 check_enclosure_temp();
4186 check_enclosure_emms();
4192 #---------------------------------------------------------------------
4194 #---------------------------------------------------------------------
4197 # Fetch output from 'omreport chassis info', put in sysinfo hash
4199 sub get_omreport_chassis_info {
4200 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
4201 my @lines = <$INFO>;
4204 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag|System\sRevision)/xms;
4205 my ($key, $val) = split /;/xms;
4206 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4207 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4208 if ($key eq 'Chassis Model' or $key eq 'Model') {
4209 $sysinfo{model} = $val;
4211 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
4212 $sysinfo{serial} = $val;
4214 if ($key eq 'System Revision') {
4215 $sysinfo{rev} = q{ } . $val;
4223 # Fetch output from 'omreport chassis bios', put in sysinfo hash
4225 sub get_omreport_chassis_bios {
4226 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
4227 my @lines = <$BIOS>;
4231 my ($key, $val) = split /;/xms;
4232 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4233 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4234 $sysinfo{bios} = $val if $key eq 'Version';
4235 $sysinfo{biosdate} = $val if $key eq 'Release Date';
4242 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
4244 sub get_omreport_system_operatingsystem {
4245 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
4250 my ($key, $val) = split /;/xms;
4251 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4252 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4253 if ($key eq 'Operating System') {
4254 $sysinfo{osname} = $val;
4256 elsif ($key eq 'Operating System Version') {
4257 $sysinfo{osver} = $val;
4265 # Fetch output from 'omreport about', put in sysinfo hash
4267 sub get_omreport_about {
4268 if (open my $OM, '-|', "$omreport about -fmt ssv") {
4272 if (m/\A Version;(.+) \z/xms) {
4282 # Fetch chassis info via SNMP, put in sysinfo hash
4284 sub get_snmp_chassis_info {
4287 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
4288 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
4289 '1.3.6.1.4.1.674.10892.1.300.10.1.48.1' => 'chassisSystemRevisionName',
4292 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
4293 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
4295 if (defined $result) {
4296 foreach my $oid (keys %{ $result }) {
4297 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
4298 $sysinfo{model} = $result->{$oid};
4299 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
4301 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
4302 $sysinfo{serial} = $result->{$oid};
4304 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisSystemRevisionName') {
4305 $sysinfo{rev} = q{ } . $result->{$oid};
4310 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
4311 $snmp_session->error;
4312 report('other', $msg, $E_UNKNOWN);
4318 # Fetch BIOS info via SNMP, put in sysinfo hash
4320 sub get_snmp_chassis_bios {
4323 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
4324 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
4327 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
4328 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
4330 if (defined $result) {
4331 foreach my $oid (keys %{ $result }) {
4332 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
4333 $sysinfo{biosdate} = $result->{$oid};
4334 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
4336 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
4337 $sysinfo{bios} = $result->{$oid};
4342 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
4343 $snmp_session->error;
4344 report('other', $msg, $E_UNKNOWN);
4350 # Fetch OS info via SNMP, put in sysinfo hash
4352 sub get_snmp_system_operatingsystem {
4355 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
4356 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
4359 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
4360 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
4362 if (defined $result) {
4363 foreach my $oid (keys %{ $result }) {
4364 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
4365 $sysinfo{osname} = ($result->{$oid});
4367 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
4368 $sysinfo{osver} = $result->{$oid};
4373 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
4374 $snmp_session->error;
4375 report('other', $msg, $E_UNKNOWN);
4381 # Fetch OMSA version via SNMP, put in sysinfo hash
4383 sub get_snmp_about {
4384 # systemManagementSoftwareGlobalVersionName
4385 my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
4386 my $result = $snmp_session->get_request(-varbindlist => [$oid]);
4388 if (defined $result) {
4389 $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
4390 ? $result->{$oid} : 'unknown';
4393 my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
4394 report('other', $msg, $E_UNKNOWN);
4400 # Collects some information about the system
4404 # Get system model and serial number
4405 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4407 # Get BIOS information. Only if needed
4408 if ( $opt{okinfo} >= 1
4410 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4411 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4414 # Get OMSA information. Only if needed
4415 if ($opt{okinfo} >= 3 or $opt{debug}) {
4416 $snmp ? get_snmp_about() : get_omreport_about();
4419 # Return now if debug
4420 return if $opt{debug};
4422 # Get OS information. Only if needed
4423 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4424 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4431 # Helper function for running omreport when the results are strictly
4433 sub run_omreport_info {
4434 my $command = shift;
4438 # Run omreport and fetch output
4439 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4441 # Parse output, store in array
4442 for ((split /\n/xms, $rawtext)) {
4443 if (m/\A Error/xms) {
4444 my $msg = "Problem running 'omreport $command': $_";
4445 report('other', $msg, $E_UNKNOWN);
4447 next if !m/;/xms; # ignore lines with less than two fields
4448 my @vals = split m/;/xms;
4449 $output{$vals[0]} = $vals[1];
4452 # Finally, return the collected information
4456 # Get various firmware information (BMC, RAC)
4457 sub get_firmware_info {
4458 my @snmp_output = ();
4459 my %nrpe_output = ();
4464 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4465 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4466 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4469 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4470 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4472 # Some don't have this OID, this is ok
4473 if (!defined $result) {
4477 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4480 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4483 my %fw_type # Firmware types
4485 1 => 'other', # other than following values
4486 2 => 'unknown', # unknown
4487 3 => 'systemBIOS', # System BIOS
4488 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4489 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4490 6 => 'systemBackPlane', # System (Primary) Backplane
4491 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4492 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4493 9 => 'frontPanel', # Front Panel Controller
4494 10 => 'baseboardManagementController', # Baseboard Management Controller
4495 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4496 12 => 'sensorData', # Sensor Data Records
4497 13 => 'peripheralBay', # Peripheral Bay Backplane
4498 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4499 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4500 16 => 'rac', # Remote Access Controller
4501 17 => 'iDRAC', # Integrated Dell Remote Access Controller
4502 19 => 'unifiedServerConfigurator', # Unified Server Configurator
4503 20 => 'lifecycleController', # Lifecycle Controller
4508 foreach my $out (@snmp_output) {
4509 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4510 $sysinfo{'bmc'} = 1;
4511 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4513 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|iDRAC \z}xms) {
4514 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4515 $sysinfo{'rac'} = 1;
4516 $sysinfo{'rac_name'} = $name;
4517 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4522 foreach my $key (keys %nrpe_output) {
4523 next if !defined $nrpe_output{$key};
4524 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4525 $sysinfo{'bmc'} = 1;
4526 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4528 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4530 $sysinfo{'rac'} = 1;
4531 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4532 $sysinfo{'rac_name'} = $name;
4542 #=====================================================================
4544 #=====================================================================
4546 # Here we do the actual checking of components
4547 # Check global status if applicable
4549 $globalstatus = check_global();
4552 # Do multiple selected checks
4553 if ($check{storage}) { check_storage(); }
4554 if ($check{memory}) { check_memory(); }
4555 if ($check{fans}) { check_fans(); }
4556 if ($check{power}) { check_powersupplies(); }
4557 if ($check{temp}) { check_temperatures(); }
4558 if ($check{cpu}) { check_processors(); }
4559 if ($check{voltage}) { check_volts(); }
4560 if ($check{batteries}) { check_batteries(); }
4561 if ($check{amperage}) { check_pwrmonitoring(); }
4562 if ($check{intrusion}) { check_intrusion(); }
4563 if ($check{sdcard}) { check_sdcard(); }
4564 if ($check{alertlog}) { check_alertlog(); }
4565 if ($check{esmlog}) { check_esmlog(); }
4566 if ($check{esmhealth}) { check_esmlog_health(); }
4569 #---------------------------------------------------------------------
4571 #---------------------------------------------------------------------
4582 # Get system information
4585 # Get firmware info if requested via option
4586 if ($opt{okinfo} >= 1) {
4587 get_firmware_info();
4590 # Close SNMP session
4592 $snmp_session->close;
4597 # finding the mode of operation
4600 # Setting the domain (IP version and transport protocol)
4601 my $transport = $opt{tcp} ? 'TCP' : 'UDP';
4602 my $ipversion = $opt{ipv6} ? 'IPv6' : 'IPv4';
4603 $mode = "SNMPv$opt{protocol} $transport/$ipversion";
4606 print " System: $sysinfo{model}$sysinfo{rev}";
4607 print q{ } x (25 - length "$sysinfo{model}$sysinfo{rev}"), "OMSA version: $sysinfo{om}\n";
4608 print " ServiceTag: $sysinfo{serial}";
4609 print q{ } x (25 - length $sysinfo{serial}), "Plugin version: $VERSION\n";
4610 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4611 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Checking mode: $mode\n";
4612 if ($#report_storage >= 0) {
4613 print "-----------------------------------------------------------------------------\n";
4614 print " Storage Components \n";
4615 print "=============================================================================\n";
4616 print " STATE | ID | MESSAGE TEXT \n";
4617 print "---------+----------+--------------------------------------------------------\n";
4618 foreach (@report_storage) {
4619 my ($msg, $level, $nexus) = @{$_};
4620 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4621 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4622 $nagios_alert_count{$reverse_exitcode{$level}}++;
4625 if ($#report_chassis >= 0) {
4626 print "-----------------------------------------------------------------------------\n";
4627 print " Chassis Components \n";
4628 print "=============================================================================\n";
4629 print " STATE | ID | MESSAGE TEXT \n";
4630 print "---------+------+------------------------------------------------------------\n";
4631 foreach (@report_chassis) {
4632 my ($msg, $level, $nexus) = @{$_};
4633 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4634 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4635 $nagios_alert_count{$reverse_exitcode{$level}}++;
4638 if ($#report_other >= 0) {
4639 print "-----------------------------------------------------------------------------\n";
4640 print " Other messages \n";
4641 print "=============================================================================\n";
4642 print " STATE | MESSAGE TEXT \n";
4643 print "---------+-------------------------------------------------------------------\n";
4644 foreach (@report_other) {
4645 my ($msg, $level, $nexus) = @{$_};
4646 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4647 $nagios_alert_count{$reverse_exitcode{$level}}++;
4652 my $c = 0; # counter to determine linebreaks
4654 # Run through each message, sorted by severity level
4656 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4657 my ($msg, $level, $nexus) = @{ $_ };
4658 next ALERT if $level == $E_OK;
4660 if (defined $opt{only}) {
4661 # If user wants only critical alerts
4662 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4664 # If user wants only warning alerts
4665 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4668 # Prefix with service tag if specified with option '-i|--info'
4670 if (defined $opt{htmlinfo}) {
4671 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4672 . "\">$sysinfo{serial}</a>] " . $msg;
4675 $msg = "[$sysinfo{serial}] " . $msg;
4679 # Prefix with nagios level if specified with option '--state'
4680 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4682 # Prefix with one-letter nagios level if specified with option '--short-state'
4683 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4685 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4687 $nagios_alert_count{$reverse_exitcode{$level}}++;
4691 # Determine our exit code
4693 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4694 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4695 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4697 # Global status via SNMP.. extra safety check
4698 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4699 print "OOPS! Something is wrong with this server, but I don't know what. ";
4700 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4701 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4702 print "please file a bug report.\n";
4707 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4709 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4710 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4711 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4712 'memory' => "MEMORY OK - $count{dimm} memory modules, $count{mem} MB total memory",
4713 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4714 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4715 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4716 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4717 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4718 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4719 '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",
4720 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4721 'esmhealth' => "ESM LOG OK - less than 80% used",
4722 'sdcard' => "SD CARDS OK - $count{sd} SD cards installed",
4725 print $okmsg{$opt{only}};
4727 elsif ($exit_code == $E_OK && !$opt{debug}) {
4728 if (defined $opt{htmlinfo}) {
4729 printf q{OK - System: '<a href="%s">%s%s</a>', SN: '<a href="%s">%s</a>'},
4730 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
4731 warranty_url($sysinfo{serial}), $sysinfo{serial};
4734 printf q{OK - System: '%s%s', SN: '%s'},
4735 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
4738 if ($check{memory}) {
4740 if ($count{mem} >= 1024) {
4741 $count{mem} /= 1024;
4744 printf ', %d %s ram (%d dimms)', $count{mem}, $unit, $count{dimm};
4747 print ', not checking memory';
4750 if ($check{storage}) {
4751 printf ', %d logical drives, %d physical drives',
4752 $count{vdisk}, $count{pdisk};
4755 print ', not checking storage';
4758 if ($opt{okinfo} >= 1) {
4760 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4762 if ($sysinfo{rac}) {
4763 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4765 if ($sysinfo{bmc}) {
4766 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4770 if ($opt{okinfo} >= 2) {
4771 if ($check{storage}) {
4772 my @storageprint = ();
4773 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4774 chomp $sysinfo{controller}{$id}{driver};
4775 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4776 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4777 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4778 if (defined $sysinfo{controller}{$id}{storport}) {
4779 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4781 push @storageprint, $msg;
4783 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4784 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4785 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4786 $sysinfo{enclosure}{$id}->{firmware};
4790 foreach my $line (@storageprint) {
4791 print $linebreak, $line;
4796 if ($opt{okinfo} >= 3) {
4797 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4802 if ($opt{extinfo}) {
4804 if (defined $opt{htmlinfo}) {
4805 printf '------ SYSTEM: <a href="%s">%s%s</a>, SN: <a href="%s">%s</a>',
4806 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
4807 warranty_url($sysinfo{serial}), $sysinfo{serial};
4810 printf '------ SYSTEM: %s%s, SN: %s',
4811 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
4814 if (defined $opt{postmsg}) {
4816 if (-f $opt{postmsg}) {
4817 open my $POST, '<', $opt{postmsg}
4818 or ( print $linebreak
4819 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4820 and exit $E_UNKNOWN );
4826 $post = $opt{postmsg};
4828 if (defined $post) {
4830 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4831 $post =~ s{[%]m}{$sysinfo{model}$sysinfo{rev}}gxms;
4832 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4833 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4834 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4835 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4836 $post =~ s{[%]p}{$count{pdisk}}gxms;
4837 $post =~ s{[%]l}{$count{vdisk}}gxms;
4838 $post =~ s{[%]n}{$linebreak}gxms;
4839 $post =~ s{[%]{2}}{%}gxms;
4845 # Reset the WARN signal
4846 $SIG{__WARN__} = 'DEFAULT';
4848 # Print any perl warnings that have occured
4849 if (@perl_warnings) {
4850 foreach (@perl_warnings) {
4852 print "${linebreak}INTERNAL ERROR: @$_";
4854 $exit_code = $E_UNKNOWN;
4857 # Print performance data
4858 if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
4859 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4862 # Sort routine for performance data
4864 my %order = ( fan => 0, pwr => 1, tem => 2, enc => 3, );
4865 return ($order{(substr $a->{label}, 0, 3)} cmp $order{(substr $b->{label}, 0, 3)}) ||
4866 $a->{label} cmp $b->{label};
4869 # Print performance data sorted
4870 my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
4871 print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
4874 # Print a linebreak at the end
4875 print "\n" if !$opt{debug};
4877 # Exit with proper exit code