5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2008-2011 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';
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 -B, --show-blacklist Show blacklistings in OK output
102 -I, --htmlinfo HTML output with clickable links
104 CHECK CONTROL AND BLACKLISTING:
106 -a, --all Check everything, even log content
107 -b, --blacklist Blacklist missing and/or failed components
108 --only Only check a certain component or alert type
109 --check Fine-tune which components are checked
110 --no-storage Don't check storage
112 For more information and advanced options, see the manual page or URL:
113 http://folk.uio.no/trondham/software/check_openmanage.html
116 # Version and license text
117 $LICENSE = <<"END_LICENSE";
119 Copyright (C) 2008-2011 $AUTHOR
120 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
121 This is free software: you are free to change and redistribute it.
122 There is NO WARRANTY, to the extent permitted by law.
124 Written by $AUTHOR <$CONTACT>
127 # Options with default values
128 %opt = ( 'blacklist' => [], # blacklisting
129 'check' => [], # check control
130 'critical' => [], # temperature critical limits
131 'warning' => [], # temperature warning limits
132 'timeout' => 30, # default timeout is 30 seconds
133 'debug' => 0, # debugging / verbose output
134 'help' => 0, # display help output
135 'perfdata' => undef, # output performance data
136 'info' => 0, # display servicetag
137 'extinfo' => 0, # display extra info
138 'htmlinfo' => undef, # html tags in output
139 'postmsg' => undef, # post message
140 'state' => 0, # display alert type
141 'short-state' => 0, # display alert type (short)
142 'okinfo' => 0, # default "ok" output level
143 'show_blacklist' => 0, # show blacklisted components
144 'linebreak' => undef, # specify linebreak
145 'version' => 0, # plugin version info
146 'all' => 0, # check everything
147 'only' => undef, # only one component
148 'no_storage' => 0, # don't check storage
149 'omreport' => undef, # omreport path
150 'port' => 161, # default SNMP port
151 'hostname' => undef, # hostname or IP
152 'community' => 'public', # SMNP v1 or v2c
153 'protocol' => 2, # default SNMP protocol 2c
154 'ipv6' => 0, # default is IPv4
155 'tcp' => 0, # default is UDP
156 'username' => undef, # SMNP v3
157 'authpassword' => undef, # SMNP v3
158 'authkey' => undef, # SMNP v3
159 'authprotocol' => undef, # SMNP v3
160 'privpassword' => undef, # SMNP v3
161 'privkey' => undef, # SMNP v3
162 'privprotocol' => undef, # SMNP v3
163 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
167 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
168 'check=s' => \@{ $opt{check} },
169 'c|critical=s' => \@{ $opt{critical} },
170 'w|warning=s' => \@{ $opt{warning} },
171 't|timeout=i' => \$opt{timeout},
172 'd|debug' => \$opt{debug},
173 'h|help' => \$opt{help},
174 'V|version' => \$opt{version},
175 'p|perfdata:s' => \$opt{perfdata},
176 'i|info' => \$opt{info},
177 'e|extinfo' => \$opt{extinfo},
178 'I|htmlinfo:s' => \$opt{htmlinfo},
179 'postmsg=s' => \$opt{postmsg},
180 's|state' => \$opt{state},
181 'S|short-state' => \$opt{shortstate},
182 'o|ok-info=i' => \$opt{okinfo},
183 'B|show-blacklist' => \$opt{show_blacklist},
184 'linebreak=s' => \$opt{linebreak},
185 'a|all' => \$opt{all},
186 'only=s' => \$opt{only},
187 'no-storage' => \$opt{no_storage},
188 'omreport=s' => \$opt{omreport},
189 'port=i' => \$opt{port},
190 'H|hostname=s' => \$opt{hostname},
191 'C|community=s' => \$opt{community},
192 'P|protocol=i' => \$opt{protocol},
193 '6|ipv6' => \$opt{ipv6},
195 'U|username=s' => \$opt{username},
196 'authpassword=s' => \$opt{authpassword},
197 'authkey=s' => \$opt{authkey},
198 'authprotocol=s' => \$opt{authprotocol},
199 'privpassword=s' => \$opt{privpassword},
200 'privkey=s' => \$opt{privkey},
201 'privprotocol=s' => \$opt{privprotocol},
202 'use-get_table' => \$opt{use_get_table},
203 ) or do { print $USAGE; exit $E_UNKNOWN };
205 # If user requested help
211 # If user requested version info
219 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
224 # If we're using SNMP
225 $snmp = defined $opt{hostname} ? 1 : 0;
227 # SNMP session variables
228 $snmp_session = undef;
231 # The omreport command
234 # Check flags, override available with the --check option
235 %check = ( 'storage' => 1, # check storage subsystem
236 'memory' => 1, # check memory (dimms)
237 'fans' => 1, # check fan status
238 'power' => 1, # check power supplies
239 'temp' => 1, # check temperature
240 'cpu' => 1, # check processors
241 'voltage' => 1, # check voltage
242 'batteries' => 1, # check battery probes
243 'amperage' => 1, # check power consumption
244 'intrusion' => 1, # check intrusion detection
245 'sdcard' => 1, # check removable flash media (SD cards)
246 'alertlog' => 0, # check the alert log
247 'esmlog' => 0, # check the ESM log (hardware log)
248 'esmhealth' => 1, # check the ESM log overall health
252 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
254 # Line break from option
255 if (defined $opt{linebreak}) {
256 if ($opt{linebreak} eq 'REG') {
259 elsif ($opt{linebreak} eq 'HTML') {
260 $linebreak = '<br/>';
263 $linebreak = $opt{linebreak};
267 # Exit with status=UNKNOWN if there is firmware upgrade in progress
268 if (!$snmp && -f $FW_LOCK) {
269 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
273 # List of controllers and enclosures
274 @controllers = (); # controllers
275 @enclosures = (); # enclosures
276 %snmp_enclosure = (); # enclosures
279 @report_storage = (); # messages with associated nagios level (storage)
280 @report_chassis = (); # messages with associated nagios level (chassis)
281 @report_other = (); # messages with associated nagios level (other)
283 # Counters for everything
286 'pdisk' => 0, # number of physical disks
287 'vdisk' => 0, # number of logical drives (virtual disks)
288 'temp' => 0, # number of temperature probes
289 'volt' => 0, # number of voltage probes
290 'amp' => 0, # number of amperage probes
291 'intr' => 0, # number of intrusion probes
292 'dimm' => 0, # number of memory modules
293 'mem' => 0, # total memory
294 'fan' => 0, # number of fan probes
295 'cpu' => 0, # number of CPUs
296 'bat' => 0, # number of batteries
297 'power' => 0, # number of power supplies
298 'sd' => 0, # number of SD cards
300 'Critical' => 0, # critical entries in ESM log
301 'Non-Critical' => 0, # warning entries in ESM log
302 'Ok' => 0, # ok entries in ESM log
305 'Critical' => 0, # critical entries in alert log
306 'Non-Critical' => 0, # warning entries in alert log
307 'Ok' => 0, # ok entries in alert log
314 # Global health status
315 $global = 1; # default is to check global status
316 $globalstatus = $E_OK; # default global health status is "OK"
318 # Nagios error levels reversed
322 $E_WARNING => 'WARNING',
323 $E_CRITICAL => 'CRITICAL',
324 $E_UNKNOWN => 'UNKNOWN',
327 # OpenManage (omreport) and SNMP error levels
330 'Unknown' => $E_CRITICAL,
331 'Critical' => $E_CRITICAL,
332 'Non-Critical' => $E_WARNING,
334 'Non-Recoverable' => $E_CRITICAL,
335 'Other' => $E_CRITICAL,
346 6 => 'Non-Recoverable',
349 # Probe Status via SNMP
352 1 => 'Other', # probe status is not one of the following:
353 2 => 'Unknown', # probe status is unknown (not known or monitored)
354 3 => 'Ok', # probe is reporting a value within the thresholds
355 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
356 5 => 'criticalUpper', # probe has crossed upper critical threshold
357 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
358 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
359 8 => 'criticalLower', # probe has crossed lower critical threshold
360 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
361 10 => 'failed', # probe is not functional
364 # Probe status translated to Nagios alarm levels
367 'Other' => $E_CRITICAL,
368 'Unknown' => $E_CRITICAL,
370 'nonCriticalUpper' => $E_WARNING,
371 'criticalUpper' => $E_CRITICAL,
372 'nonRecoverableUpper' => $E_CRITICAL,
373 'nonCriticalLower' => $E_WARNING,
374 'criticalLower' => $E_CRITICAL,
375 'nonRecoverableLower' => $E_CRITICAL,
376 'failed' => $E_CRITICAL,
379 # System information gathered
382 'bios' => 'N/A', # BIOS version
383 'biosdate' => 'N/A', # BIOS release date
384 'serial' => 'N/A', # serial number (service tag)
385 'model' => 'N/A', # system model
386 'rev' => q{}, # system revision
387 'osname' => 'N/A', # OS name
388 'osver' => 'N/A', # OS version
389 'om' => 'N/A', # OMSA version
390 'bmc' => 0, # HAS baseboard management controller (BMC)
391 'rac' => 0, # HAS remote access controller (RAC)
392 'rac_name' => 'N/A', # remote access controller (RAC)
393 'bmc_fw' => 'N/A', # BMC firmware
394 'rac_fw' => 'N/A', # RAC firmware
397 # Adjust which checks to perform
398 adjust_checks() if defined $opt{check};
400 # Blacklisted components
401 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
403 # If blacklisting is in effect, don't check global health status
404 if (scalar keys %blacklist > 0) {
408 # Take into account new hardware and blades
409 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
410 $omopt_system = 'system'; # default "system" option to omreport
411 $blade = 0; # if this is a blade system
413 # Some initializations and checking before we begin
415 snmp_initialize(); # initialize SNMP
416 snmp_check(); # check that SNMP works
417 snmp_detect_blade(); # detect blade via SNMP
420 # Find the omreport binary
422 # Check help output from omreport, see which options are available.
423 # Also detecting blade via omreport.
424 check_omreport_options();
428 #---------------------------------------------------------------------
430 #---------------------------------------------------------------------
433 # Store a message in one of the message arrays
436 my ($type, $msg, $exval, $id) = @_;
437 defined $id or $id = q{};
441 'storage' => \@report_storage,
442 'chassis' => \@report_chassis,
443 'other' => \@report_other,
446 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
451 # Run command, put resulting output lines in an array and return a
452 # pointer to that array
457 open my $CMD, '-|', $command
458 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
462 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
463 and return \@lines };
468 # Run command, put resulting output in a string variable and return it
473 open my $CMD, '-|', $command
474 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
475 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
478 # NOTE: We don't check the return value of close() since omreport
479 # does something weird sometimes.
487 sub snmp_initialize {
488 # Legal SNMP v3 protocols
489 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
490 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
492 # Parameters to Net::SNMP->session()
495 '-port' => $opt{port},
496 '-hostname' => $opt{hostname},
497 '-version' => $opt{protocol},
500 # Setting the domain (IP version and transport protocol)
501 my $transport = $opt{tcp} ? 'tcp' : 'udp';
502 my $ipversion = $opt{ipv6} ? 'ipv6' : 'ipv4';
503 $param{'-domain'} = "$transport/$ipversion";
505 # Parameters for SNMP v3
506 if ($opt{protocol} == 3) {
508 # Username is mandatory
509 if (defined $opt{username}) {
510 $param{'-username'} = $opt{username};
513 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
517 # Authpassword is optional
518 if (defined $opt{authpassword}) {
519 $param{'-authpassword'} = $opt{authpassword};
522 # Authkey is optional
523 if (defined $opt{authkey}) {
524 $param{'-authkey'} = $opt{authkey};
527 # Privpassword is optional
528 if (defined $opt{privpassword}) {
529 $param{'-privpassword'} = $opt{privpassword};
532 # Privkey is optional
533 if (defined $opt{privkey}) {
534 $param{'-privkey'} = $opt{privkey};
537 # Privprotocol is optional
538 if (defined $opt{privprotocol}) {
539 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
540 $param{'-privprotocol'} = $opt{privprotocol};
543 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
544 . "must be one of [des|aes|aes128|3des|3desde]\n";
549 # Authprotocol is optional
550 if (defined $opt{authprotocol}) {
551 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
552 $param{'-authprotocol'} = $opt{authprotocol};
555 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
556 . "must be one of [md5|sha]\n";
561 # Parameters for SNMP v2c or v1
562 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
563 $param{'-community'} = $opt{community};
566 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
570 # Try to initialize the SNMP session
571 if ( eval { require Net::SNMP; 1 } ) {
572 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
573 if (!defined $snmp_session) {
574 printf "SNMP: %s\n", $snmp_error;
579 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
586 # Checking if SNMP works by probing for "chassisModelName", which all
587 # servers should have
590 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
591 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
593 # Typically if remote host isn't responding
594 if (!defined $result) {
595 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
599 # If OpenManage isn't installed or is not working
600 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
601 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
608 # Detecting blade via SNMP
610 sub snmp_detect_blade {
611 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
612 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
614 # Identify blade. Older models (4th and 5th gen models) and/or old
615 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
616 # similar, we assume that this isn't a blade
617 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
624 # Locate the omreport binary
627 # If user has specified path to omreport
628 if (defined $opt{omreport} and -x $opt{omreport}) {
629 $omreport = qq{"$opt{omreport}"};
633 # Possible full paths for omreport
636 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA >= 6.2.0
637 '/usr/bin/omreport', # default on Linux with OMSA < 6.2.0
638 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
639 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
640 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
641 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
642 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
643 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
646 # Find the one to use
648 foreach my $bin (@omreport_paths) {
650 $omreport = qq{"$bin"};
655 # Exit with status=UNKNOWN if OM is not installed, or we don't
656 # have permission to execute the binary
657 if (!defined $omreport) {
658 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
665 # Checks output from 'omreport -?' and searches for arguments to
666 # omreport, to accommodate deprecated options "chassis" and "system"
667 # (on newer hardware), as well as blade servers.
669 sub check_omreport_options {
670 foreach (@{ run_command("$omreport -? 2>&1") }) {
671 if (m/\A servermodule /xms) {
672 # If "servermodule" argument to omreport exists, use it
673 # instead of argument "system"
674 $omopt_system = 'servermodule';
676 elsif (m/\A mainsystem /xms) {
677 # If "mainsystem" argument to omreport exists, use it
678 # instead of argument "chassis"
679 $omopt_chassis = 'mainsystem';
681 elsif (m/\A modularenclosure /xms) {
682 # If "modularenclusure" argument to omreport exists, assume
683 # that this is a blade
691 # Read the blacklist option and return a hash containing the
692 # blacklisted components
698 if (scalar @{ $opt{blacklist} } >= 0) {
699 foreach my $black (@{ $opt{blacklist} }) {
702 open my $BL, '<', $black
703 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
715 return {} if $#bl < 0;
717 # Parse blacklist string, put in hash
718 foreach my $black (@bl) {
719 my @comps = split m{/}xms, $black;
720 foreach my $c (@comps) {
721 next if $c !~ m/=/xms;
722 my ($key, $val) = split /=/xms, $c;
723 my @vals = split /,/xms, $val;
724 $blacklist{$key} = \@vals;
732 # Read the check option and adjust the hash %check, which is a rough
733 # list of components to be checked
738 # First, take the '--no-storage' option
739 if ($opt{no_storage}) {
743 # Adjust checking based on the '--all' option
746 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
747 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
750 if (scalar @{ $opt{check} } > 0) {
751 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
755 # set the check hash to check everything
756 map { $_ = 1 } values %check;
761 # Adjust checking based on the '--only' option
762 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
764 if (scalar @{ $opt{check} } > 0) {
765 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
768 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
769 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
773 # reset the check hash
774 map { $_ = 0 } values %check;
776 # adjust the check hash
777 if ($opt{only} eq 'chassis') {
778 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
779 batteries amperage intrusion esmhealth);
782 $check{$opt{only}} = 1;
788 # Adjust checking based on the '--check' option
789 if (scalar @{ $opt{check} } >= 0) {
790 foreach my $check (@{ $opt{check} }) {
793 open my $CL, '<', $check
794 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
807 # Parse checklist string, put in hash
808 foreach my $check (@cl) {
809 my @checks = split /,/xms, $check;
810 foreach my $c (@checks) {
811 next if $c !~ m/=/xms;
812 my ($key, $val) = split /=/xms, $c;
817 # Check if we should check global health status
819 foreach (keys %check) {
820 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
821 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
823 if ($check{$_} == 0) { # found something with checking turned off
833 # Runs omreport and returns an array of anonymous hashes containing
835 # Takes one argument: string containing parameters to omreport
842 # Errors that are OK. Some low-end poweredge (and blades) models
843 # don't have RAID controllers, intrusion detection sensor, or
844 # redundant/instrumented power supplies etc.
847 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
848 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
849 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
850 | Invalid\scommand:\spwrmonitoring # Old hardware
851 | Hardware\sor\sfeature\snot\spresent\. # SD cards
852 | Invalid\scommand:\sremovableflashmedia # SD cards with old OMSA
853 | Error\sCorrection; # Memory stuff. Not really an error (new in OMSA 6.4)
854 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
855 # | No\scontrollers\sfound # No RAID controller
858 # Errors that are OK on blade servers
861 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
864 # Run omreport and fetch output
865 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
866 return [] if !defined $rawtext;
868 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
869 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
871 # Report if no controllers found
872 if ($command eq 'storage controller' and $rawtext =~ m{No\scontrollers\sfound}xms) {
873 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
876 # Openmanage sometimes puts a linebreak between "Error" and the
878 $rawtext =~ s{^Error\s*\n}{Error: }xms;
880 # Parse output, store in array
881 for ((split m{\n}xms, $rawtext)) {
883 next if m{$ok_errors}xms;
884 next if ($blade and m{$ok_blade_errors}xms);
885 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
888 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
889 my @vals = split /;/xms;
890 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed|Connector\sName) \z/xms) {
895 push @output, { map { $_ => $vals[$i++] } @keys };
900 # Finally, return the collected information
905 # Checks if a component is blacklisted. Returns 1 if the component is
906 # blacklisted, 0 otherwise. Takes two arguments:
907 # arg1: component name
908 # arg2: component id or index
911 my $name = shift; # component name
912 my $id = shift; # component id
913 my $ret = 0; # return value
915 if (defined $blacklist{$name}) {
916 foreach my $comp (@{ $blacklist{$name} }) {
917 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
926 # Converts the NexusID from SNMP to our version
929 $nexus =~ s{\A \\}{}xms;
930 $nexus =~ s{\\}{:}gxms;
934 # Sets custom temperature thresholds based on user supplied options
935 sub custom_temperature_thresholds {
936 my $type = shift; # type of threshold, either w (warning) or c (critical)
937 my %thres = (); # will contain the thresholds
938 my @limits = (); # holds the input
940 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
942 if (scalar @opt >= 0) {
943 foreach my $t (@opt) {
947 or do { report('other', "Couldn't open temperature threshold file $t: $!",
948 $E_UNKNOWN) and return {} };
959 # Parse checklist string, put in hash
960 foreach my $th (@limits) {
961 my @tmp = split m{,}xms, $th;
962 foreach my $t (@tmp) {
963 next if $t !~ m{=}xms;
964 my ($key, $val) = split m{=}xms, $t;
965 if ($val =~ m{/}xms) {
966 my ($max, $min) = split m{/}xms, $val;
967 $thres{$key}{max} = $max;
968 $thres{$key}{min} = $min;
971 $thres{$key}{max} = $val;
980 # Gets the output from SNMP result according to the OIDs checked
981 sub get_snmp_output {
982 my ($result,$oidref) = @_;
986 foreach my $oid (keys %{ $result }) {
988 $short =~ s{\s}{}gxms; # remove whitespace
989 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
991 if (exists $oidref->{$short}) {
992 $temp[$id]{$oidref->{$short}} = $result->{$oid};
996 # Remove any empty indexes
997 foreach my $out (@temp) {
1007 # Map the controller or other item in-place
1009 my ($key, $val, $list) = @_;
1011 foreach my $lst (@{ $list }) {
1012 if (!exists $lst->{$key}) {
1013 $lst->{$key} = $val;
1019 # Return the URL for official Dell documentation for a specific
1021 sub documentation_url {
1024 # create model short form, e.g. "r710"
1025 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
1027 # special case for blades (e.g. M600, M710), they have common
1029 $model =~ s{\A m\d+ \z}{m}xms;
1031 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1034 # Return the URL for warranty information for a server with a given
1035 # serial number (servicetag)
1039 # Dell support sites for different parts of the world
1042 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1043 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1044 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1047 # warranty URLs for different country codes
1051 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1052 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1053 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1054 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1055 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1056 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1057 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1058 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1059 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1060 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1061 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1062 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1063 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1064 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1065 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1066 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1067 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1068 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1069 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1070 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1072 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1073 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1074 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1075 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1077 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1078 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1079 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1081 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1084 if (exists $url{$opt{htmlinfo}}) {
1085 return $url{$opt{htmlinfo}} . $tag;
1088 return $url{XX} . $tag;
1093 # This helper function returns the corresponding value of a hash key,
1094 # but takes into account that the key may not exist
1096 my $key = shift || return undef;
1098 return defined $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1101 # Find component status from hash
1102 sub get_snmp_status {
1103 my $key = shift || return 'Unknown';
1104 return exists $snmp_status{$key} ? $snmp_status{$key} : 'Unknown';
1107 # Find component status from hash
1108 sub get_snmp_probestatus {
1109 my $key = shift || return 'Unknown';
1110 return exists $snmp_probestatus{$key} ? $snmp_probestatus{$key} : 'Unknown';
1113 # Check that a hash entry is defined and not an empty string. Return a
1114 # chosen string (parameter) if these conditions are not met
1115 sub get_nonempty_string {
1116 my $key = shift; # key to check
1117 my $hash = shift; # hash where the key belongs
1118 my $alt = shift; # alternate return value
1119 if (defined $hash->{$key} and $hash->{$key} ne q{}) {
1120 return $hash->{$key};
1126 #---------------------------------------------------------------------
1128 #---------------------------------------------------------------------
1130 #-----------------------------------------
1131 # Check global health status
1132 #-----------------------------------------
1138 # Checks global status, i.e. both storage and chassis
1140 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1141 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1142 if (!defined $result) {
1143 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1146 $health = $status2nagios{get_snmp_status($result->{$systemStateGlobalSystemStatus})};
1150 # NB! This does not check storage, only chassis...
1152 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1154 next if m/\A SEVERITY;COMPONENT/xms;
1155 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1156 $health = $status2nagios{$1};
1167 #-----------------------------------------
1168 # STORAGE: Check controllers
1169 #-----------------------------------------
1170 sub check_controllers {
1177 my $firmware = undef;
1179 my $minstdr = undef; # Minimum required Storport driver version
1180 my $stdr = undef; # Storport driver version
1186 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1187 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1188 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1189 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1190 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1191 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1192 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1193 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1194 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1195 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1196 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1199 # We use get_table() here for the odd case where a server has
1200 # two or more controllers, and where some OIDs are missing on
1201 # one of the controllers.
1202 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1203 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1205 if (!defined $result) {
1206 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
1210 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1213 @output = @{ run_omreport('storage controller') };
1227 foreach my $out (@output) {
1229 $name = $out->{controllerName} || 'Unknown controller';
1230 $state = get_hashval($out->{controllerState}, \%ctrl_state) || 'Unknown state';
1231 $status = get_snmp_status($out->{controllerComponentStatus});
1232 $minfw = $out->{controllerMinFWVersion} || undef;
1233 $mindr = $out->{controllerMinDriverVersion} || undef;
1234 $firmware = $out->{controllerFWVersion} || 'N/A';
1235 $driver = $out->{controllerDriverVersion} || 'N/A';
1236 $minstdr = $out->{'controllerMinRequiredStorportVer'} || undef;
1237 $stdr = $out->{controllerStorportDriverVersion} || undef;
1238 $nexus = convert_nexus(($out->{controllerNexusID} || 9999));
1241 $nexus = get_nonempty_string('ID', $out, '9999');
1242 $name = get_nonempty_string('Name', $out, 'Unknown controller');
1243 $state = get_nonempty_string('State', $out, 'Unknown state');
1244 $status = get_nonempty_string('Status', $out, 'Unknown');
1245 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1246 ? $out->{'Minimum Required Firmware Version'} : undef;
1247 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1248 ? $out->{'Minimum Required Driver Version'} : undef;
1249 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1250 ? $out->{'Firmware Version'} : 'N/A';
1251 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1252 ? $out->{'Driver Version'} : 'N/A';
1253 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1254 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1255 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1256 $stdr = (exists $out->{'Storport Driver Version'}
1257 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1258 ? $out->{'Storport Driver Version'} : undef;
1261 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1262 push @controllers, $nexus;
1264 # Collecting some storage info
1265 $sysinfo{'controller'}{$nexus}{'id'} = $nexus;
1266 $sysinfo{'controller'}{$nexus}{'name'} = $name;
1267 $sysinfo{'controller'}{$nexus}{'driver'} = $driver;
1268 $sysinfo{'controller'}{$nexus}{'firmware'} = $firmware;
1269 $sysinfo{'controller'}{$nexus}{'storport'} = $stdr;
1271 # Store controller info for future use (SNMP)
1273 $snmp_controller{$out->{controllerNumber}} = $nexus;
1276 next CTRL if blacklisted('ctrl', $nexus);
1278 # Special case: old firmware
1279 if (!blacklisted('ctrl_fw', $nexus) && defined $minfw) {
1281 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1282 $nexus, $name, $firmware;
1283 report('storage', $msg, $E_WARNING, $nexus);
1285 # Special case: old driver
1286 if (!blacklisted('ctrl_driver', $nexus) && defined $mindr) {
1288 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1289 $nexus, $name, $driver;
1290 report('storage', $msg, $E_WARNING, $nexus);
1292 # Special case: old storport driver
1293 if (!blacklisted('ctrl_stdr', $nexus) && defined $minstdr) {
1295 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1296 $nexus, $name, $stdr;
1297 report('storage', $msg, $E_WARNING, $nexus);
1300 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1301 and (defined $minfw or defined $mindr or defined $minstdr))) {
1302 my $msg = sprintf 'Controller %d [%s] is %s',
1303 $nexus, $name, $state;
1304 report('storage', $msg, $E_OK, $nexus);
1308 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1309 $nexus, $name, $state;
1310 report('storage', $msg, $status2nagios{$status}, $nexus);
1317 #-----------------------------------------
1318 # STORAGE: Check physical drives
1319 #-----------------------------------------
1320 sub check_physical_disks {
1321 return if $#controllers == -1;
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') {
1503 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;
1595 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1596 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1597 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1598 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1599 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1600 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1603 if ($opt{use_get_table}) {
1604 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1605 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1608 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1611 # No logical drives is OK
1612 return if !defined $result;
1614 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1617 foreach my $c (@controllers) {
1618 push @output, @{ run_omreport("storage vdisk controller=$c") };
1619 map_item('ctrl', $c, \@output);
1632 16 => 'Regenerating',
1635 32 => 'Reconstructing',
1636 35 => 'Initializing',
1637 36 => 'Background Initialization',
1638 38 => 'Resynching Paused',
1639 52 => 'Permanently Degraded',
1640 54 => 'Degraded Redundancy',
1645 1 => 'Concatenated',
1648 4 => 'UNSUPPORTED:raid-2',
1649 5 => 'UNSUPPORTED:raid-3',
1650 6 => 'UNSUPPORTED:raid-4',
1653 9 => 'UNSUPPORTED:raid-7',
1655 11 => 'UNSUPPORTED:raid-30',
1657 13 => 'UNSUPPORTED:addSpares',
1658 14 => 'UNSUPPORTED:deleteLogical',
1659 15 => 'UNSUPPORTED:transformLogical',
1660 18 => 'UNSUPPORTED:raid-0-plus-1',
1661 19 => 'Concatenated RAID-1',
1662 20 => 'UNSUPPORTED:concatRaid-5',
1663 21 => 'UNSUPPORTED:noRaid',
1664 22 => 'UNSUPPORTED:volume',
1665 23 => 'UNSUPPORTED:raidMorph',
1670 # Check virtual disks on each of the controllers
1672 foreach my $out (@output) {
1674 $dev = $out->{virtualDiskDeviceName} || 'Unknown device';
1675 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state) || 'Unknown state';
1676 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout) || 'Unknown layout';
1677 $status = get_snmp_status($out->{virtualDiskComponentStatus});
1678 $size = sprintf '%.2f GB', ($out->{virtualDiskLengthInMB} || 0) / 1024;
1679 $progr = q{}; # not available via SNMP
1680 $nexus = convert_nexus(($out->{virtualDiskNexusID} || 9999));
1683 $dev = get_nonempty_string('Device Name', $out, 'Unknown device');
1684 $state = get_nonempty_string('State', $out, 'Unknown state');
1685 $status = get_nonempty_string('Status', $out, 'Unknown');
1686 $layout = get_nonempty_string('Layout', $out, 'Unknown layout');
1687 $size = get_nonempty_string('Size', $out, 'Unavailable');
1688 $size =~ s{\A (.*GB).* \z}{$1}xms;
1689 $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
1690 $ctrl = $out->{ctrl};
1691 $nexus = join q{:}, $ctrl, get_nonempty_string('ID', $out, '9999');
1695 next VDISK if blacklisted('vdisk', $nexus);
1697 # The device name is undefined sometimes
1698 $dev = q{} if !defined $dev;
1700 # Special case: Regenerating
1701 if ($state eq 'Regenerating') {
1702 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s%s},
1703 $dev, $layout, $size, $state, $progr;
1704 report('storage', $msg, $E_WARNING, $nexus);
1707 elsif ($status ne 'Ok') {
1708 my $msg = sprintf q{Logical Drive '%s' [%s, %s] needs attention: %s},
1709 $dev, $layout, $size, $state;
1710 report('storage', $msg, $status2nagios{$status}, $nexus);
1714 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s},
1715 $dev, $layout, $size, $state;
1716 report('storage', $msg, $E_OK, $nexus);
1723 #-----------------------------------------
1724 # STORAGE: Check cache batteries
1725 #-----------------------------------------
1726 sub check_cache_battery {
1727 return if $#controllers == -1;
1734 my $learn = undef; # learn state
1735 my $pred = undef; # battery's ability to be charged
1741 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1742 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1743 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1744 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1745 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1746 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1749 if ($opt{use_get_table}) {
1750 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1751 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1753 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1754 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1756 if (defined $result) {
1757 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1761 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1764 # No cache battery is OK
1765 return if !defined $result;
1767 @output = @{ get_snmp_output($result, \%bat_oid) };
1770 foreach my $c (@controllers) {
1771 push @output, @{ run_omreport("storage battery controller=$c") };
1772 map_item('ctrl', $c, \@output);
1782 7 => 'Reconditioning',
1790 # Specifies the learn state activity of the battery
1800 # This property displays the battery's ability to be charged
1803 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1804 2 => 'Ready', # The battery can be charged to full capacity
1805 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1806 # battery cannot be determined until the Learn cycle is complete
1809 # Check battery on each of the controllers
1811 foreach my $out (@output) {
1813 $status = get_snmp_status($out->{batteryComponentStatus});
1814 $state = get_hashval($out->{batteryState}, \%bat_state) || 'Unknown state';
1815 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state) || 'Unknown learn state';
1816 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap) || 'Unknown predicted capacity status';
1817 $ctrl = ($out->{batteryConnectionControllerNumber} || 10000) - 1;
1818 $nexus = convert_nexus(($out->{batteryNexusID} || 9999));
1820 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1823 $id = get_nonempty_string('ID', $out, 9999);
1824 $state = get_nonempty_string('State', $out, 'Unknown state');
1825 $status = get_nonempty_string('Status', $out, 'Unknown');
1826 $learn = get_nonempty_string('Learn State', $out, 'Unknown learn state');
1827 $pred = get_nonempty_string('Predicted Capacity Status', $out, 'Unknown predicted capacity status');
1828 $ctrl = $out->{'ctrl'};
1829 $nexus = join q{:}, $out->{ctrl}, $id;
1832 next BATTERY if blacklisted('bat', $nexus);
1834 # Special case: Charging
1835 if ($state eq 'Charging') {
1836 if ($pred eq 'Failed') {
1837 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [replace battery]',
1838 $id, $ctrl, $state, $pred;
1839 report('storage', $msg, $E_CRITICAL, $nexus);
1842 next BATTERY if blacklisted('bat_charge', $nexus);
1843 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1844 $id, $ctrl, $state, $pred;
1845 report('storage', $msg, $E_WARNING, $nexus);
1848 # Special case: Learning (battery learns its capacity)
1849 elsif ($state eq 'Learning') {
1850 if ($learn eq 'Failed') {
1851 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s)',
1852 $id, $ctrl, $state, $learn;
1853 report('storage', $msg, $E_CRITICAL, $nexus);
1856 next BATTERY if blacklisted('bat_charge', $nexus);
1857 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1858 $id, $ctrl, $state, $learn;
1859 report('storage', $msg, $E_WARNING, $nexus);
1862 # Special case: Power Low (first part of recharge cycle)
1863 elsif ($state eq 'Power Low') {
1864 next BATTERY if blacklisted('bat_charge', $nexus);
1865 my $msg = sprintf 'Cache Battery %d in controller %d is %s [probably harmless]',
1867 report('storage', $msg, $E_WARNING, $nexus);
1869 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1870 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1871 next BATTERY if blacklisted('bat_charge', $nexus);
1872 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
1873 $id, $ctrl, $state, $status;
1874 report('storage', $msg, $E_WARNING, $nexus);
1878 my $msg = sprintf 'Cache Battery %d in controller %d is %s',
1880 report('storage', $msg, $status2nagios{$status}, $nexus);
1887 #-----------------------------------------
1888 # STORAGE: Check connectors (channels)
1889 #-----------------------------------------
1890 sub check_connectors {
1891 return if $#controllers == -1;
1904 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1905 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1906 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1907 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1908 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1911 if ($opt{use_get_table}) {
1912 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1913 $result = $snmp_session->get_table(-baseoid => $channelTable);
1916 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1919 if (!defined $result) {
1920 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1921 $snmp_session->close;
1925 @output = @{ get_snmp_output($result, \%conn_oid) };
1928 foreach my $c (@controllers) {
1929 push @output, @{ run_omreport("storage connector controller=$c") };
1930 map_item('ctrl', $c, \@output);
1948 3 => 'Fibre Channel',
1955 # Check connectors on each of the controllers
1957 foreach my $out (@output) {
1959 $name = $out->{channelName} || 'Unknown channel';
1960 $status = get_snmp_status($out->{channelComponentStatus});
1961 $state = get_hashval($out->{channelState}, \%conn_state) || 'Unknown state';
1962 $type = get_hashval($out->{channelBusType}, \%conn_bustype) || 'Unknown type';
1963 $nexus = convert_nexus(($out->{channelNexusID} || 9999));
1965 $ctrl =~ s{(\d+):\d+}{$1}xms;
1968 $name = get_nonempty_string('Name', $out, 'Unknown channel');
1969 $state = get_nonempty_string('State', $out, 'Unknown state');
1970 $status = get_nonempty_string('Status', $out, 'Unknown');
1971 $type = get_nonempty_string('Connector Type', $out, 'Unknown type');
1972 $ctrl = $out->{ctrl};
1973 $nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
1976 next CHANNEL if blacklisted('conn', $nexus);
1978 my $msg = sprintf '%s [%s] on controller %d is %s',
1979 $name, $type, $ctrl, $state;
1980 report('storage', $msg, $status2nagios{$status}, $nexus);
1986 #-----------------------------------------
1987 # STORAGE: Check enclosures
1988 #-----------------------------------------
1989 sub check_enclosures {
1995 my $firmware = undef;
1997 my $occupied_slots = undef; # number of occupied slots
1998 my $total_slots = undef; # number of total slots
2004 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
2005 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
2006 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
2007 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
2008 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
2009 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
2010 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
2011 '1.3.6.1.4.1.674.10893.1.20.130.3.1.31' => 'enclosureOccupiedSlotCount', # new in OMSA 6.3.0
2012 '1.3.6.1.4.1.674.10893.1.20.130.3.1.32' => 'enclosureTotalSlots', # new in OMSA 6.3.0
2015 if ($opt{use_get_table}) {
2016 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
2017 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
2020 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
2023 # No enclosures is OK
2024 return if !defined $result;
2026 @output = @{ get_snmp_output($result, \%encl_oid) };
2029 foreach my $c (@controllers) {
2030 push @output, @{ run_omreport("storage enclosure controller=$c") };
2031 map_item('ctrl', $c, \@output);
2046 foreach my $out (@output) {
2048 $id = ($out->{enclosureNumber} || 10000) - 1;
2049 $name = $out->{enclosureName} || 'Unknown enclosure';
2050 $state = get_hashval($out->{enclosureState}, \%encl_state) || 'Unknown state';
2051 $status = get_snmp_status($out->{enclosureComponentStatus});
2052 $firmware = $out->{enclosureFirmwareVersion} || 'N/A';
2053 $nexus = convert_nexus(($out->{enclosureNexusID} || 9999));
2055 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
2056 # for the next two, a value of 9999 means feature not available
2057 $occupied_slots = defined $out->{enclosureOccupiedSlotCount}
2058 && $out->{enclosureOccupiedSlotCount} != 9999
2059 ? $out->{enclosureOccupiedSlotCount} : undef;
2060 $total_slots = defined $out->{enclosureTotalSlots}
2061 && $out->{enclosureTotalSlots} != 9999
2062 ? $out->{enclosureTotalSlots} : undef;
2065 $id = get_nonempty_string('ID', $out, 9999);
2066 $name = get_nonempty_string('Name', $out, 'Unknown enclosure');
2067 $state = get_nonempty_string('State', $out, 'Unknown state');
2068 $status = get_nonempty_string('Status', $out, 'Unknown');
2069 $firmware = get_nonempty_string('Firmware Version', $out, 'N/A');
2070 $firmware =~ s{Not\sApplicable}{N/A}xms;
2071 $nexus = join q{:}, $out->{ctrl}, $id;
2072 $ctrl = $out->{ctrl};
2075 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
2076 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
2078 # store enclosure data for future use
2080 $snmp_enclosure{$out->{enclosureNumber}}{id} = $id;
2081 $snmp_enclosure{$out->{enclosureNumber}}{name} = $name;
2082 $snmp_enclosure{$out->{enclosureNumber}}{nexus} = $nexus;
2085 push @enclosures, { 'id' => $id,
2086 'ctrl' => $out->{ctrl},
2090 # Collecting some storage info
2091 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
2092 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
2093 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
2095 next ENCLOSURE if blacklisted('encl', $nexus);
2098 if (defined $occupied_slots && defined $total_slots) {
2099 $msg = sprintf 'Enclosure %s [%s, %d/%d slots occupied] on ctrl %d is %s',
2100 $nexus, $name, $occupied_slots, $total_slots, $ctrl, $state;
2103 $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
2104 $nexus, $name, $ctrl, $state;
2106 report('storage', $msg, $status2nagios{$status}, $nexus);
2112 #-----------------------------------------
2113 # STORAGE: Check enclosure fans
2114 #-----------------------------------------
2115 sub check_enclosure_fans {
2116 return if $#controllers == -1;
2123 my $encl_id = undef;
2124 my $encl_name = undef;
2130 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2131 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2132 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2133 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2134 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2135 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2136 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2139 if ($opt{use_get_table}) {
2140 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2141 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2143 $result = $snmp_session->get_table(-baseoid => $fanTable);
2144 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2146 if (defined $result) {
2147 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2151 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2154 # No enclosure fans is OK
2155 return if !defined $result;
2157 @output = @{ get_snmp_output($result, \%fan_oid) };
2160 foreach my $enc (@enclosures) {
2161 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2162 map_item('ctrl', $enc->{ctrl}, \@output);
2163 map_item('encl_id', $enc->{id}, \@output);
2164 map_item('encl_name', $enc->{name}, \@output);
2179 # Check fans on each of the enclosures
2181 foreach my $out (@output) {
2183 $name = $out->{fanName} || 'Unknown fan';
2184 $state = get_hashval($out->{fanState}, \%fan_state) || 'Unknown state';
2185 $status = get_snmp_status($out->{fanComponentStatus});
2186 $speed = $out->{fanProbeCurrValue} || 'N/A';
2187 $encl_name = $out->{fanConnectionEnclosureName} || 'Unknown enclosure';
2188 $encl_id = $snmp_enclosure{$out->{fanConnectionEnclosureNumber}}{nexus};
2189 $nexus = convert_nexus(($out->{fanNexusID} || 9999));
2192 $name = get_nonempty_string('Name', $out, 'Unknown fan');
2193 $state = get_nonempty_string('State', $out, 'Unknown state');
2194 $status = get_nonempty_string('Status', $out, 'Unknown');
2195 $speed = get_nonempty_string('Speed', $out, 'N/A');
2196 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2197 $encl_name = $out->{encl_name};
2198 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2201 next FAN if blacklisted('encl_fan', $nexus);
2204 if ($status ne 'Ok') {
2205 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2206 $name, $encl_id, $encl_name, $state;
2207 report('storage', $msg, $status2nagios{$status}, $nexus);
2211 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2212 $name, $encl_id, $encl_name, $state, $speed;
2213 report('storage', $msg, $E_OK, $nexus);
2220 #-----------------------------------------
2221 # STORAGE: Check enclosure power supplies
2222 #-----------------------------------------
2223 sub check_enclosure_pwr {
2224 return if $#controllers == -1;
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;
2334 my $reading = undef;
2336 my $max_warn = undef;
2337 my $max_crit = undef;
2338 my $min_warn = undef;
2339 my $min_crit = undef;
2340 my $encl_id = undef;
2341 my $encl_name = undef;
2347 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2348 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2349 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2350 '1.3.6.1.4.1.674.10893.1.20.130.11.1.7' => 'temperatureProbeMinWarning',
2351 '1.3.6.1.4.1.674.10893.1.20.130.11.1.8' => 'temperatureProbeMinCritical',
2352 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2353 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2354 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2355 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2356 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2357 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2358 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2361 if ($opt{use_get_table}) {
2362 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2363 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2365 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2366 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2368 if (defined $result) {
2369 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2373 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2376 # No enclosure temperature probes is OK
2377 return if !defined $result;
2379 @output = @{ get_snmp_output($result, \%temp_oid) };
2382 foreach my $enc (@enclosures) {
2383 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2384 map_item('ctrl', $enc->{ctrl}, \@output);
2385 map_item('encl_id', $enc->{id}, \@output);
2386 map_item('encl_name', $enc->{name}, \@output);
2401 # Check temperature probes on each of the enclosures
2403 foreach my $out (@output) {
2405 $name = $out->{temperatureProbeName} || 'Unknown temp probe';
2406 $state = get_hashval($out->{temperatureProbeState}, \%temp_state) || 'Unknown state';
2407 $status = get_snmp_probestatus($out->{temperatureProbeComponentStatus});
2408 $unit = $out->{temperatureProbeUnit} || 'Unknown unit';
2409 $reading = $out->{temperatureProbeCurValue} || '[N/A]';
2410 $max_warn = $out->{temperatureProbeMaxWarning} || '[N/A]';
2411 $max_crit = $out->{temperatureProbeMaxCritical} || '[N/A]';
2412 $min_warn = $out->{temperatureProbeMinWarning} || '[N/A]';
2413 $min_crit = $out->{temperatureProbeMinCritical} || '[N/A]';
2414 $encl_id = $snmp_enclosure{$out->{temperatureConnectionEnclosureNumber}}{nexus};
2415 $encl_name = $out->{temperatureConnectionEnclosureName} || 'Unknown enclosure';
2416 $nexus = convert_nexus(($out->{temperatureProbeNexusID} || 9999));
2419 $name = get_nonempty_string('Name', $out, 'Unknown temp probe');
2420 $state = get_nonempty_string('State', $out, 'Unknown state');
2421 $status = get_nonempty_string('Status', $out, 'Unknown');
2423 $reading = get_nonempty_string('Reading', $out, '[N/A]');
2424 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
2425 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
2426 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
2427 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
2428 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2429 $encl_name = $out->{encl_name};
2430 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2433 next TEMP if blacklisted('encl_temp', $nexus);
2435 # Make sure these values are integers
2436 $reading =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $reading = '[N/A]';
2437 $max_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_warn = '[N/A]';
2438 $max_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_crit = '[N/A]';
2439 $min_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_warn = '[N/A]';
2440 $min_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_crit = '[N/A]';
2442 # Inactive temp probes
2443 if ($status eq 'Unknown' and $state eq 'Inactive') {
2444 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2445 $name, $encl_id, $encl_name, $state;
2446 report('storage', $msg, $E_OK, $nexus);
2448 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2449 my $msg = sprintf '%s in enclosure %s [%s] is critically high at %d C',
2450 $name, $encl_id, $encl_name, $reading;
2451 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2452 report('chassis', $msg, $err, $nexus);
2454 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2455 my $msg = sprintf '%s in enclosure %s [%s] is too high at %d C',
2456 $name, $encl_id, $encl_name, $reading;
2457 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2458 report('chassis', $msg, $err, $nexus);
2460 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2461 my $msg = sprintf '%s in enclosure %s [%s] is critically low at %d C',
2462 $name, $encl_id, $encl_name, $reading;
2463 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2464 report('chassis', $msg, $err, $nexus);
2466 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2467 my $msg = sprintf '%s in enclosure %s [%s] is too low at %d C',
2468 $name, $encl_id, $encl_name, $reading;
2469 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2470 report('chassis', $msg, $err, $nexus);
2473 elsif ($status ne 'Ok') {
2474 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2475 $name, $encl_id, $encl_name, $state;
2476 if (defined $reading && $reading =~ m{\A -?\d+ \z}xms) {
2477 # take into account that with certain states the
2478 # reading doesn't exist or is not an integer
2479 $msg .= sprintf ' at %s C', $reading;
2480 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2481 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2484 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2485 $min_warn, $min_crit, $max_warn, $max_crit;
2488 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2489 report('storage', $msg, $err, $nexus);
2493 my $msg = sprintf '%s in enclosure %s [%s]',
2494 $name, $encl_id, $encl_name;
2495 if (defined $reading && $reading ne '[N/A]') {
2496 # take into account that with certain states the
2497 # reading doesn't exist or is not an integer
2498 $msg .= sprintf ' reads %d C', $reading;
2499 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2500 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2503 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2504 $min_warn, $min_crit, $max_warn, $max_crit;
2508 $msg .= sprintf ' is %s', $state;
2510 report('storage', $msg, $E_OK, $nexus);
2513 # Collect performance data
2514 if (defined $opt{perfdata} && $reading ne '[N/A]') {
2515 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2516 my $label = "enclosure_${encl_id}_${name}";
2518 $mini =~ s{enclosure_(.+?)_temp_(.+?)}{e$1t$2}xms;
2532 #-----------------------------------------
2533 # STORAGE: Check enclosure management modules (EMM)
2534 #-----------------------------------------
2535 sub check_enclosure_emms {
2536 return if $#controllers == -1;
2542 my $encl_id = undef;
2543 my $encl_name = undef;
2549 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2550 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2551 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2552 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2553 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2554 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2557 if ($opt{use_get_table}) {
2558 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2559 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2561 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2562 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2564 if (defined $result) {
2565 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2569 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2572 # No enclosure EMMs is OK
2573 return if !defined $result;
2575 @output = @{ get_snmp_output($result, \%emms_oid) };
2578 foreach my $enc (@enclosures) {
2579 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2580 map_item('ctrl', $enc->{ctrl}, \@output);
2581 map_item('encl_id', $enc->{id}, \@output);
2582 map_item('encl_name', $enc->{name}, \@output);
2593 5 => 'Not Installed',
2598 # Check EMMs on each of the enclosures
2600 foreach my $out (@output) {
2602 $name = $out->{enclosureManagementModuleName} || 'Unknown EMM';
2603 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state) || 'Unknown state';
2604 $status = get_snmp_status($out->{enclosureManagementModuleComponentStatus});
2605 $encl_id = $snmp_enclosure{$out->{enclosureManagementModuleConnectionEnclosureNumber}}{nexus};
2606 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName} || 'Unknown enclosure';
2607 $nexus = convert_nexus(($out->{enclosureManagementModuleNexusID} || 9999));
2610 $name = get_nonempty_string('Name', $out, 'Unknown EMM');
2611 $state = get_nonempty_string('State', $out, 'Unknown state');
2612 $status = get_nonempty_string('Status', $out, 'Unknown');
2613 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2614 $encl_name = $out->{encl_name};
2615 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2618 next EMM if blacklisted('encl_emm', $nexus);
2621 if ($status =~ m{\A Other|Unknown \z}xms and $state eq 'Not Installed') {
2622 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2623 $name, $encl_id, $encl_name, $state;
2624 report('storage', $msg, $E_OK, $nexus);
2627 elsif ($status ne 'Ok') {
2628 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2629 $name, $encl_id, $encl_name, $state;
2630 report('storage', $msg, $status2nagios{$status}, $nexus);
2634 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2635 $name, $encl_id, $encl_name, $state;
2636 report('storage', $msg, $E_OK, $nexus);
2643 #-----------------------------------------
2644 # CHASSIS: Check memory modules
2645 #-----------------------------------------
2649 my $location = undef;
2658 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2659 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2660 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2661 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2662 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2665 if ($opt{use_get_table}) {
2666 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2667 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2670 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2673 if (!defined $result) {
2674 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2675 $snmp_session->close;
2679 @output = @{ get_snmp_output($result, \%dimm_oid) };
2682 @output = @{ run_omreport("$omopt_chassis memory") };
2685 # Note: These values are bit masks, so combination values are
2686 # possible. If value is 0 (zero), memory device has no faults.
2689 1 => 'ECC single bit correction warning rate exceeded',
2690 2 => 'ECC single bit correction failure rate exceeded',
2691 4 => 'ECC multibit fault encountered',
2692 8 => 'ECC single bit correction logging disabled',
2693 16 => 'device disabled because of spare activation',
2697 foreach my $out (@output) {
2698 @failures = (); # Initialize
2700 $index = ($out->{memoryDeviceIndex} || 10000) - 1;
2701 $status = get_snmp_status($out->{memoryDeviceStatus});
2702 $location = $out->{memoryDeviceLocationName} || 'Unknown location';
2703 $size = sprintf '%d MB', ($out->{memoryDeviceSize} || 0)/1024;
2704 $modes = $out->{memoryDeviceFailureModes} || -9999;
2706 foreach my $mask (sort keys %failure_mode) {
2707 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2710 elsif ($modes == -9999) {
2711 push @failures, q{ERROR: Failure modes not available via SNMP};
2715 my $type = get_nonempty_string('Type', $out, q{});
2716 $index = $type eq '[Not Occupied]' ? undef : get_nonempty_string('Index', $out, 9999);
2717 $status = get_nonempty_string('Status', $out, 'Unknown');
2718 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
2719 $size = get_nonempty_string('Size', $out, 0);
2720 if (defined $size) {
2721 $size =~ s{\s\s}{ }gxms;
2723 # Run 'omreport chassis memory index=X' to get the failures
2724 if ($status ne 'Ok' && defined $index) {
2725 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2726 if (m/\A Failures; (.+?) \z/xms) {
2727 chop(my $fail = $1);
2728 push @failures, split m{\.}xms, $fail;
2733 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2735 # calculate total memory
2736 my $msize = defined $size ? $size : 0;
2737 $msize =~ s{\A (\d+) \s MB}{$1}xms;
2738 $count{mem} += $msize;
2740 # Ignore empty memory slots
2741 next DIMM if !defined $index;
2744 next DIMM if blacklisted('dimm', $index);
2746 if ($status ne 'Ok') {
2748 if (scalar @failures == 0) {
2749 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2750 $index, $location, $size, $status;
2753 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2754 $index, $location, $size, (join q{, }, @failures);
2757 report('chassis', $msg, $status2nagios{$status}, $index);
2761 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2762 $index, $location, $size, $status;
2763 report('chassis', $msg, $E_OK, $index);
2770 #-----------------------------------------
2771 # CHASSIS: Check fans
2772 #-----------------------------------------
2776 my $reading = undef;
2777 my $location = undef;
2778 my $max_crit = undef;
2779 my $max_warn = undef;
2785 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2786 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2787 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2788 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2789 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2790 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2793 if ($opt{use_get_table}) {
2794 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2795 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2798 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2801 if ($blade && !defined $result) {
2804 elsif (!$blade && !defined $result) {
2805 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2806 $snmp_session->close;
2810 @output = @{ get_snmp_output($result, \%cool_oid) };
2813 @output = @{ run_omreport("$omopt_chassis fans") };
2817 foreach my $out (@output) {
2819 $index = ($out->{coolingDeviceIndex} || 10000) - 1;
2820 $status = get_snmp_probestatus($out->{coolingDeviceStatus});
2821 $reading = $out->{coolingDeviceReading} || 0;
2822 $location = $out->{coolingDeviceLocationName} || 'Unknown location';
2823 $max_crit = $out->{coolingDeviceUpperCriticalThreshold} || 0;
2824 $max_warn = $out->{coolingDeviceUpperNonCriticalThreshold} || 0;
2827 $index = get_nonempty_string('Index', $out, 9999);
2828 $status = get_nonempty_string('Status', $out, 'Unknown');
2829 $reading = get_nonempty_string('Reading', $out, 0);
2830 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
2831 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, 0);
2832 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, 0);
2833 if ($max_crit eq '[N/A]') { $max_crit = 0; }
2834 if ($max_warn eq '[N/A]') { $max_warn = 0; }
2835 $reading =~ s{\A (\d+).* \z}{$1}xms;
2836 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2837 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2841 next FAN if blacklisted('fan', $index);
2843 if ($status ne 'Ok') {
2844 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2845 $index, $location, $status;
2846 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2847 report('chassis', $msg, $err, $index);
2850 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2851 $index, $location, $reading;
2852 report('chassis', $msg, $E_OK, $index);
2855 # Collect performance data
2856 if (defined $opt{perfdata}) {
2857 my $pname = lc $location;
2858 $pname =~ s{\s}{_}gxms;
2859 $pname =~ s{proc_}{cpu#}xms;
2861 label => "fan_${index}_${pname}",
2873 #-----------------------------------------
2874 # CHASSIS: Check power supplies
2875 #-----------------------------------------
2876 sub check_powersupplies {
2880 my $err_type = undef;
2888 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2889 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2890 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2891 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2892 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2895 if ($opt{use_get_table}) {
2896 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2897 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2900 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2903 # No instrumented PSU is OK (blades, low-end servers)
2904 return 0 if !defined $result;
2906 @output = @{ get_snmp_output($result, \%ps_oid) };
2909 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2919 6 => 'Uninterruptible Power Supply',
2929 1 => 'Presence detected',
2930 2 => 'Failure detected',
2931 4 => 'Predictive Failure',
2933 16 => 'AC lost or out-of-range',
2934 32 => 'AC out-of-range but present',
2935 64 => 'Configuration error',
2938 my %ps_config_error_type
2940 1 => 'Vendor mismatch',
2941 2 => 'Revision mismatch',
2942 3 => 'Processor missing',
2946 foreach my $out (@output) {
2948 @states = (); # contains states for the PS
2950 $index = ($out->{powerSupplyIndex} || 10000) - 1;
2951 $status = get_snmp_status($out->{powerSupplyStatus});
2952 $type = get_hashval($out->{powerSupplyType}, \%ps_type) || 'Unknown type';
2953 $err_type = get_hashval($out->{powerSupplyConfigurationErrorType}, \%ps_config_error_type);
2955 # get the combined state from the StatusReading OID
2956 my $raw_state = $out->{powerSupplySensorState} || 0;
2957 foreach my $mask (sort keys %ps_state) {
2958 if (($raw_state & $mask) != 0) {
2959 push @states, $ps_state{$mask};
2963 # If configuration error, also include the error type
2964 if (defined $err_type) {
2965 push @states, $err_type;
2968 # Finally, construct the state string
2969 $state = join q{, }, @states;
2972 $index = get_nonempty_string('Index', $out, 9999);
2973 $status = get_nonempty_string('Status', $out, 'Unknown');
2974 $type = get_nonempty_string('Type', $out, 'Unknown type');
2975 $state = get_nonempty_string('Online Status', $out, 'Unknown state');
2979 next PS if blacklisted('ps', $index);
2981 if ($status ne 'Ok') {
2982 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2983 $index, $type, $state;
2984 report('chassis', $msg, $status2nagios{$status}, $index);
2987 my $msg = sprintf 'Power Supply %d [%s]: %s',
2988 $index, $type, $state;
2989 report('chassis', $msg, $E_OK, $index);
2996 #-----------------------------------------
2997 # CHASSIS: Check temperatures
2998 #-----------------------------------------
2999 sub check_temperatures {
3002 my $reading = undef;
3003 my $location = undef;
3004 my $max_crit = undef;
3005 my $max_warn = undef;
3006 my $min_warn = undef;
3007 my $min_crit = undef;
3009 my $discrete = undef;
3012 # Getting custom temperature thresholds (user option)
3013 my %warn_threshold = %{ custom_temperature_thresholds('w') };
3014 my %crit_threshold = %{ custom_temperature_thresholds('c') };
3019 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
3020 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
3021 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
3022 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
3023 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
3024 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
3025 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
3026 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
3027 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
3028 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
3030 # this didn't work well for some reason
3031 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
3033 # Getting values using the table
3034 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
3035 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
3037 if (!defined $result) {
3038 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
3039 $snmp_session->close;
3043 @output = @{ get_snmp_output($result, \%temp_oid) };
3046 @output = @{ run_omreport("$omopt_chassis temps") };
3051 1 => 'Other', # type is other than following values
3052 2 => 'Unknown', # type is unknown
3053 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
3054 16 => 'Discrete', # type is temperature probe with discrete reading
3058 foreach my $out (@output) {
3060 $index = ($out->{temperatureProbeIndex} || 10000) - 1;
3061 $status = get_snmp_probestatus($out->{temperatureProbeStatus});
3062 $location = $out->{temperatureProbeLocationName} || 'Unknown location';
3063 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
3064 $reading = $out->{temperatureProbeReading} || '[N/A]';
3065 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} || '[N/A]';
3066 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} || '[N/A]';
3067 $min_crit = $out->{temperatureProbeLowerCriticalThreshold} || '[N/A]';
3068 $min_warn = $out->{temperatureProbeLowerNonCriticalThreshold} || '[N/A]';
3069 $discrete = $out->{temperatureProbeDiscreteReading} || '[N/A]';
3071 # If numeric values, i.e. not discrete
3072 $reading /= 10 if $reading =~ m{\A \d+ \z}xms;
3073 $max_crit /= 10 if $max_crit =~ m{\A \d+ \z}xms;
3074 $max_warn /= 10 if $max_warn =~ m{\A \d+ \z}xms;
3075 $min_crit /= 10 if $min_crit =~ m{\A \d+ \z}xms;
3076 $min_warn /= 10 if $min_warn =~ m{\A \d+ \z}xms;
3078 # workaround for bad temp probes
3079 if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
3084 $index = get_nonempty_string('Index', $out, 9999);
3085 $status = get_nonempty_string('Status', $out, 'Unknown');
3086 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3087 $reading = get_nonempty_string('Reading', $out, '[N/A]');
3088 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
3089 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
3090 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
3091 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
3093 # Cleaning the temp readings
3094 $reading =~ s{\.0\s+C}{}xms;
3095 $max_crit =~ s{\.0\s+C}{}xms;
3096 $max_warn =~ s{\.0\s+C}{}xms;
3097 $min_crit =~ s{\.0\s+C}{}xms;
3098 $min_warn =~ s{\.0\s+C}{}xms;
3100 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
3101 $discrete = $reading;
3105 next TEMP if blacklisted('temp', $index);
3107 if ($type eq 'Discrete') {
3108 my $msg = sprintf 'Temperature probe %d [%s] is %s',
3109 $index, $location, $discrete;
3110 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3111 report('chassis', $msg, $err, $index);
3114 # First check according to custom thresholds
3115 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
3116 # Custom critical MAX
3117 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3118 $index, $location, $reading, $crit_threshold{$index}{max};
3119 report('chassis', $msg, $E_CRITICAL, $index);
3121 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
3122 # Custom warning MAX
3123 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3124 $index, $location, $reading, $warn_threshold{$index}{max};
3125 report('chassis', $msg, $E_WARNING, $index);
3127 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
3128 # Custom critical MIN
3129 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3130 $index, $location, $reading, $crit_threshold{$index}{min};
3131 report('chassis', $msg, $E_CRITICAL, $index);
3133 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
3134 # Custom warning MIN
3135 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3136 $index, $location, $reading, $warn_threshold{$index}{min};
3137 report('chassis', $msg, $E_WARNING, $index);
3139 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
3140 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
3141 $index, $location, $reading;
3142 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3143 report('chassis', $msg, $err, $index);
3145 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
3146 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
3147 $index, $location, $reading;
3148 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3149 report('chassis', $msg, $err, $index);
3151 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
3152 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
3153 $index, $location, $reading;
3154 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3155 report('chassis', $msg, $err, $index);
3157 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
3158 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
3159 $index, $location, $reading;
3160 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3161 report('chassis', $msg, $err, $index);
3165 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
3166 $index, $location, $reading;
3167 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
3168 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
3171 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
3172 $min_warn, $min_crit, $max_warn, $max_crit;
3174 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3175 report('chassis', $msg, $err, $index);
3178 # Collect performance data
3179 if (defined $opt{perfdata}) {
3180 my $pname = lc $location;
3181 $pname =~ s{\s}{_}gxms;
3182 $pname =~ s{_temp\z}{}xms;
3183 $pname =~ s{proc_}{cpu#}xms;
3185 label => "temp_${index}_${pname}",
3198 #-----------------------------------------
3199 # CHASSIS: Check processors
3200 #-----------------------------------------
3201 sub check_processors {
3213 # NOTE: For some reason, older models don't have the
3214 # "Processor Device Status" OIDs. We check both the newer
3215 # (preferred) OIDs and the old ones.
3219 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3220 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3221 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3222 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3223 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3224 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3225 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3226 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3227 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3228 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3231 if ($opt{use_get_table}) {
3232 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3233 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3235 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3236 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3238 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3241 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3244 if (!defined $result) {
3245 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3246 $snmp_session->close;
3250 @output = @{ get_snmp_output($result, \%cpu_oid) };
3253 @output = @{ run_omreport("$omopt_chassis processors") };
3258 1 => 'Other', # other than following values
3259 2 => 'Unknown', # unknown
3260 3 => 'Enabled', # enabled
3261 4 => 'User Disabled', # disabled by user via BIOS setup
3262 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3268 1 => 'Internal Error', # Internal Error
3269 2 => 'Thermal Trip', # Thermal Trip
3270 32 => 'Configuration Error', # Configuration Error
3271 128 => 'Present', # Processor Present
3272 256 => 'Disabled', # Processor Disabled
3273 512 => 'Terminator Present', # Terminator Present
3274 1024 => 'Throttled', # Processor Throttled
3277 # Mapping between family numbers from SNMP and actual CPU family
3280 1 => 'Other', 2 => 'Unknown',
3281 3 => '8086', 4 => '80286',
3282 5 => '386', 6 => '486',
3283 7 => '8087', 8 => '80287',
3284 9 => '80387', 10 => '80487',
3285 11 => 'Pentium', 12 => 'Pentium Pro',
3286 13 => 'Pentium II', 14 => 'Pentium with MMX',
3287 15 => 'Celeron', 16 => 'Pentium II Xeon',
3288 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3289 19 => 'Pentium III', 20 => 'Itanium',
3290 21 => 'Xeon', 22 => 'Pentium 4',
3291 23 => 'Xeon MP', 24 => 'Itanium 2',
3292 25 => 'K5', 26 => 'K6',
3293 27 => 'K6-2', 28 => 'K6-3',
3294 29 => 'Athlon', 30 => 'AMD2900',
3295 31 => 'K6-2+', 32 => 'Power PC',
3296 33 => 'Power PC 601', 34 => 'Power PC 603',
3297 35 => 'Power PC 603+', 36 => 'Power PC 604',
3298 37 => 'Power PC 620', 38 => 'Power PC x704',
3299 39 => 'Power PC 750', 40 => 'Core Duo',
3300 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3301 43 => 'Intel Atom', 44 => undef,
3302 45 => undef, 46 => undef,
3303 47 => undef, 48 => 'Alpha',
3304 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3305 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3306 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3307 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3308 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3309 59 => 'Opteron 6100', 60 => 'Opteron 4100',
3310 61 => undef, 62 => undef,
3311 63 => undef, 64 => 'MIPS',
3312 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3313 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3314 69 => 'MIPS R10000', 70 => undef,
3315 71 => undef, 72 => undef,
3316 73 => undef, 74 => undef,
3317 75 => undef, 76 => undef,
3318 77 => undef, 78 => undef,
3319 79 => undef, 80 => 'SPARC',
3320 81 => 'SuperSPARC', 82 => 'microSPARC II',
3321 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3322 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3323 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3324 89 => undef, 90 => undef,
3325 91 => undef, 92 => undef,
3326 93 => undef, 94 => undef,
3327 95 => undef, 96 => '68040',
3328 97 => '68xxx', 98 => '68000',
3329 99 => '68010', 100 => '68020',
3330 101 => '68030', 102 => undef,
3331 103 => undef, 104 => undef,
3332 105 => undef, 106 => undef,
3333 107 => undef, 108 => undef,
3334 109 => undef, 110 => undef,
3335 111 => undef, 112 => 'Hobbit',
3336 113 => undef, 114 => undef,
3337 115 => undef, 116 => undef,
3338 117 => undef, 118 => undef,
3339 119 => undef, 120 => 'Crusoe TM5000',
3340 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3341 123 => undef, 124 => undef,
3342 125 => undef, 126 => undef,
3343 127 => undef, 128 => 'Weitek',
3344 129 => undef, 130 => 'Celeron M',
3345 131 => 'Athlon 64', 132 => 'Opteron',
3346 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3347 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3348 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3349 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3350 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3351 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3352 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3353 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3354 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3355 151 => undef, 152 => undef,
3356 153 => undef, 154 => undef,
3357 155 => undef, 156 => undef,
3358 157 => undef, 158 => undef,
3359 159 => undef, 160 => 'V30',
3360 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3361 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3362 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3363 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3364 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3365 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3366 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3367 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3368 177 => 'M2', 178 => undef,
3369 179 => 'Pentium 4 HT', 180 => 'AS400',
3370 181 => undef, 182 => 'Athlon XP',
3371 183 => 'Athlon MP', 184 => 'Duron',
3372 185 => 'Pentium M', 186 => 'Celeron D',
3373 187 => 'Pentium D', 188 => 'Pentium Extreme',
3374 189 => 'Core Solo', 190 => 'Core2',
3375 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3376 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3377 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3378 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3379 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3380 201 => 'G4', 202 => 'G5',
3381 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3382 205 => 'Core i5', 206 => 'Core i3',
3383 207 => undef, 208 => undef,
3384 209 => undef, 210 => 'C7-M',
3385 211 => 'C7-D', 212 => 'C7',
3386 213 => 'Eden', 214 => 'Multi-Core Xeon',
3387 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3388 217 => 'VIA Nano', 218 => 'Dual-Core Xeon 5xxx',
3389 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3390 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3391 223 => 'Multi-Core Xeon 7xxx', 224 => 'Multi-Core Xeon 3400',
3392 225 => undef, 226 => undef,
3393 227 => undef, 228 => undef,
3394 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3395 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3396 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3397 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3398 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3399 239 => 'AMD Sempron M', 240 => undef,
3400 241 => undef, 242 => undef,
3401 243 => undef, 244 => undef,
3402 245 => undef, 246 => undef,
3403 247 => undef, 248 => undef,
3404 249 => undef, 250 => 'i860',
3409 foreach my $out (@output) {
3411 $index = exists $out->{processorDeviceStatusIndex}
3412 ? ($out->{processorDeviceStatusIndex} || 10000) - 1
3413 : ($out->{processorDeviceIndex} || 10000) - 1;
3414 $status = exists $out->{processorDeviceStatusStatus}
3415 ? get_snmp_status($out->{processorDeviceStatusStatus})
3416 : get_snmp_status($out->{processorDeviceStatus});
3417 if (defined $out->{processorDeviceStatusReading}) {
3418 my @states = (); # contains states for the CPU
3420 # get the combined state from the StatusReading OID
3421 foreach my $mask (sort keys %cpu_reading) {
3422 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3423 push @states, $cpu_reading{$mask};
3427 # Finally, create the state string
3428 $state = join q{, }, @states;
3431 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state) || 'Unknown state';
3433 $man = $out->{processorDeviceManufacturerName} || undef;
3434 $family = (defined $out->{processorDeviceFamily}
3435 and defined $cpu_family{$out->{processorDeviceFamily}})
3436 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3437 $speed = $out->{processorDeviceCurrentSpeed} || undef;
3438 $brand = $out->{processorDeviceBrandName} || undef;
3441 $index = get_nonempty_string('Index', $out, 9999);
3442 $status = get_nonempty_string('Status', $out, 'Unknown');
3443 $state = get_nonempty_string('State', $out, 'Unknown state');
3444 $brand = get_nonempty_string('Processor Brand', $out, undef);
3445 $family = get_nonempty_string('Processor Family', $out, undef);
3446 $man = get_nonempty_string('Processor Manufacturer', $out, undef);
3447 $speed = get_nonempty_string('Current Speed', $out, undef);
3450 # Ignore unoccupied CPU slots (omreport)
3451 next CPU if (defined $out->{'Processor Manufacturer'}
3452 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3453 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3455 # Ignore unoccupied CPU slots (snmp)
3456 if ($snmp and defined $out->{processorDeviceStatusReading}
3457 and $out->{processorDeviceStatusReading} == 0) {
3462 next CPU if blacklisted('cpu', $index);
3464 if (defined $brand) {
3465 $brand =~ s{\s\s+}{ }gxms;
3466 $brand =~ s{\((R|tm)\)}{}gxms;
3467 $brand =~ s{\s(CPU|Processor)}{}xms;
3468 $brand =~ s{\s\@}{}xms;
3470 elsif (defined $family and defined $man and defined $speed) {
3471 $speed =~ s{\A (\d+) .*}{$1}xms;
3472 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3479 if ($status ne 'Ok') {
3480 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3481 $index, $brand, $state;
3482 report('chassis', $msg, $status2nagios{$status}, $index);
3486 my $msg = sprintf 'Processor %d [%s] is %s',
3487 $index, $brand, $state;
3488 report('chassis', $msg, $E_OK, $index);
3495 #-----------------------------------------
3496 # CHASSIS: Check voltage probes
3497 #-----------------------------------------
3501 my $reading = undef;
3502 my $location = undef;
3508 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3509 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3510 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3511 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3512 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3515 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3516 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3518 if (!defined $result) {
3519 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3520 $snmp_session->close;
3524 @output = @{ get_snmp_output($result, \%volt_oid) };
3527 @output = @{ run_omreport("$omopt_chassis volts") };
3530 my %volt_discrete_reading
3537 foreach my $out (@output) {
3539 $index = ($out->{voltageProbeIndex} || 10000) - 1;
3540 $status = get_snmp_probestatus($out->{voltageProbeStatus});
3541 $reading = defined $out->{voltageProbeReading}
3542 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3543 : (get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading) || 'Unknown reading');
3544 $location = $out->{voltageProbeLocationName} || 'Unknown location';
3547 $index = get_nonempty_string('Index', $out, 9999);
3548 $status = get_nonempty_string('Status', $out, 'Unknown');
3549 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3550 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3554 next VOLT if blacklisted('volt', $index);
3556 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3557 $index, $location, $reading;
3558 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3559 report('chassis', $msg, $err, $index);
3565 #-----------------------------------------
3566 # CHASSIS: Check batteries
3567 #-----------------------------------------
3568 sub check_batteries {
3571 my $reading = undef;
3572 my $location = undef;
3578 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3579 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3580 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3581 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3584 if ($opt{use_get_table}) {
3585 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3586 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3589 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3592 # No batteries is OK
3593 return 0 if !defined $result;
3595 @output = @{ get_snmp_output($result, \%bat_oid) };
3598 @output = @{ run_omreport("$omopt_chassis batteries") };
3603 1 => 'Predictive Failure',
3605 4 => 'Presence Detected',
3609 foreach my $out (@output) {
3611 $index = ($out->{batteryIndex} || 10000) - 1;
3612 $status = get_snmp_status($out->{batteryStatus});
3613 $reading = get_hashval($out->{batteryReading}, \%bat_reading) || 'Unknown reading';
3614 $location = $out->{batteryLocationName} || 'Unknown location';
3617 $index = get_nonempty_string('Index', $out, 9999);
3618 $status = get_nonempty_string('Status', $out, 'Unknown');
3619 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3620 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3624 next BATTERY if blacklisted('bp', $index);
3626 my $msg = sprintf 'Battery probe %d [%s] is %s',
3627 $index, $location, $reading;
3628 report('chassis', $msg, $status2nagios{$status}, $index);
3634 #-----------------------------------------
3635 # CHASSIS: Check amperage probes (power monitoring)
3636 #-----------------------------------------
3637 sub check_pwrmonitoring {
3640 my $reading = undef;
3641 my $location = undef;
3642 my $max_crit = undef;
3643 my $max_warn = undef;
3651 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3652 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3653 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3654 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3655 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3656 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3657 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3658 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3661 if ($opt{use_get_table}) {
3662 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3663 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3666 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3669 # No pwrmonitoring is OK
3670 return 0 if !defined $result;
3672 @output = @{ get_snmp_output($result, \%amp_oid) };
3675 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3678 my %amp_type # Amperage probe types
3680 1 => 'amperageProbeTypeIsOther', # other than following values
3681 2 => 'amperageProbeTypeIsUnknown', # unknown
3682 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3683 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3684 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3685 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3686 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3687 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3688 9 => 'amperageProbeTypeIsIO', # I/O probe
3689 10 => 'amperageProbeTypeIsCore', # Core probe
3690 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3691 12 => 'amperageProbeTypeIsBattery', # Battery probe
3692 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3693 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3694 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3695 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3696 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3697 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3698 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3699 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3710 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3711 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3712 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3713 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3714 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3718 foreach my $out (@output) {
3720 $index = ($out->{amperageProbeIndex} || 10000) - 1;
3721 $status = get_snmp_probestatus($out->{amperageProbeStatus});
3722 $type = get_hashval($out->{amperageProbeType}, \%amp_type);
3723 $reading = $type eq 'amperageProbeTypeIsDiscrete'
3724 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3725 : ($out->{amperageProbeReading} || 0);
3726 $location = $out->{amperageProbeLocationName} || 'Unknown location';
3727 $max_crit = $out->{amperageProbeUpperCriticalThreshold} || 0;
3728 $max_warn = $out->{amperageProbeUpperNonCriticalThreshold} || 0;
3729 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3730 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3732 # calculate proper values and set unit for ampere probes
3733 if ($unit eq 'hA' and $type ne 'amperageProbeTypeIsDiscrete') {
3741 $index = get_nonempty_string('Index', $out, 9999);
3742 $status = get_nonempty_string('Status', $out, 'Unknown');
3743 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3744 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3745 $max_crit = get_nonempty_string('Failure Threshold', $out, 0);
3746 $max_warn = get_nonempty_string('Warning Threshold', $out, 0);
3748 $max_crit = 0 if $max_crit eq '[N/A]';
3749 $max_warn = 0 if $max_warn eq '[N/A]';
3751 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3752 $unit = $2 || 'unknown';
3753 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3754 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3757 next AMP if $index !~ m{\A \d+ \z}xms;
3759 # Special case: Probe is present but unknown. This happens via
3760 # SNMP on some systems where power monitoring capability is
3761 # disabled due to non-redundant and/or non-instrumented power
3763 # E.g. R410 with newer BMC firmware and 1 power supply
3764 if ($snmp && $status eq 'Unknown' && $reading == 0) {
3769 next AMP if blacklisted('amp', $index);
3771 # Special case: Discrete reading
3772 if (defined $type and $type eq 'amperageProbeTypeIsDiscrete') {
3773 my $msg = sprintf 'Amperage probe %d [%s] is %s',
3774 $index, $location, $reading;
3775 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3776 report('chassis', $msg, $err, $index);
3780 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3781 $index, $location, $reading, $unit;
3782 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3783 report('chassis', $msg, $err, $index);
3786 # Collect performance data
3787 if (defined $opt{perfdata}) {
3788 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3789 my $label = join q{_}, 'pwr_mon', $index, lc $location;
3790 $label =~ s{\s}{_}gxms;
3793 mini => "p${index}" . lc $unit,
3801 # Collect EXTRA performance data not found at first run. This is a
3803 if (defined $opt{perfdata} && !$snmp) {
3809 foreach (@perfdata) {
3810 if ($_->{label} =~ m/\A pwr_mon_(\d+)/xms) {
3816 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3818 if ($line eq 'Location;Reading') {
3826 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s [AW] \z/xms) {
3829 $aname =~ s{\s}{_}gxms;
3831 # don't use an existing index
3832 while (exists $used{$index}) { ++$index; }
3835 label => "pwr_mon_${index}_${aname}",
3836 mini => "p${index}a",
3850 #-----------------------------------------
3851 # CHASSIS: Check intrusion
3852 #-----------------------------------------
3853 sub check_intrusion {
3856 my $reading = undef;
3862 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3863 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3864 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3867 if ($opt{use_get_table}) {
3868 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3869 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3872 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3875 # No intrusion is OK
3876 return 0 if !defined $result;
3878 @output = @{ get_snmp_output($result, \%int_oid) };
3881 @output = @{ run_omreport("$omopt_chassis intrusion") };
3886 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3887 2 => 'Breached', # chassis currently breached
3888 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3889 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3893 foreach my $out (@output) {
3895 $index = ($out->{intrusionIndex} || 10000) - 1;
3896 $status = get_snmp_status($out->{intrusionStatus});
3897 $reading = get_hashval($out->{intrusionReading}, \%int_reading) || 'Unknown reading';
3900 $index = get_nonempty_string('Index', $out, 9999);
3901 $status = get_nonempty_string('Status', $out, 'Unknown');
3902 $reading = get_nonempty_string('State', $out, 'Unknown reading');
3906 next INTRUSION if blacklisted('intr', $index);
3908 if ($status ne 'Ok') {
3909 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3911 report('chassis', $msg, $E_WARNING, $index);
3915 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3916 $index, $status, $reading;
3917 report('chassis', $msg, $E_OK, $index);
3924 #-----------------------------------------
3925 # CHASSIS: Check SD Card Device
3926 #-----------------------------------------
3931 my $location = undef;
3932 my $capacity = undef;
3933 my $setting = undef;
3939 '1.3.6.1.4.1.674.10892.1.1100.112.1.2.1' => 'sdCardDeviceIndex',
3940 '1.3.6.1.4.1.674.10892.1.1100.112.1.3.1' => 'sdCardDeviceStatus',
3941 '1.3.6.1.4.1.674.10892.1.1100.112.1.4.1' => 'sdCardDeviceType',
3942 '1.3.6.1.4.1.674.10892.1.1100.112.1.7.1' => 'sdCardDeviceLocationName',
3943 '1.3.6.1.4.1.674.10892.1.1100.112.1.8.1' => 'sdCardDeviceCardPresent',
3944 '1.3.6.1.4.1.674.10892.1.1100.112.1.9.1' => 'sdCardDeviceCardState',
3945 '1.3.6.1.4.1.674.10892.1.1100.112.1.10.1' => 'sdCardDeviceCardStorageSize',
3948 if ($opt{use_get_table}) {
3949 my $sdCardDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.112.1';
3950 $result = $snmp_session->get_table(-baseoid => $sdCardDeviceTable);
3953 $result = $snmp_session->get_entries(-columns => [keys %sd_oid]);
3957 return 0 if !defined $result;
3959 @output = @{ get_snmp_output($result, \%sd_oid) };
3962 @output = @{ run_omreport("$omopt_chassis removableflashmedia") };
3965 # Note: These values are bit fields, so combination values are possible.
3968 0 => 'None', # state is none of the following:
3969 1 => 'Present', # device is present
3970 2 => 'IPMI-ready', # device is IPMI ready
3971 4 => 'Full-ready', # device is full ready
3972 8 => 'Offline', # device is offline
3973 16 => 'Failed', # device is failed
3974 32 => 'Active', # device is active
3975 64 => 'Bootable', # device is bootable
3976 128 => 'Write-protected', # device is write-protected
3977 256 => 'Standby', # device is in standby mode
3982 foreach my $out (@output) {
3984 $index = ($out->{sdCardDeviceIndex} || 10000) - 1;
3985 $status = get_snmp_status($out->{sdCardDeviceStatus});
3987 if (defined $out->{sdCardDeviceCardState}) {
3988 my @states = (); # contains states SD card
3990 # get the combined state from the Device Status OID
3991 foreach my $mask (sort keys %sd_state) {
3992 if (($out->{sdCardDeviceCardState} & $mask) != 0) {
3993 push @states, $sd_state{$mask};
3997 # Finally, create the state string
3998 $state = join q{, }, @states;
4000 # special case: absent
4001 if ($out->{sdCardDeviceCardState} % 2 == 0) {
4006 $location = $out->{sdCardDeviceLocationName} || 'Unknown location';
4007 $capacity = sprintf '%s MB', ($out->{sdCardDeviceCardStorageSize} || 'Unknown size');
4011 $status = get_nonempty_string('Status', $out, 'Ok');
4012 $state = get_nonempty_string('State', $out, 'Unknown state');
4013 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
4014 $capacity = get_nonempty_string('Storage Size', $out, 'Unknown size');
4016 $capacity =~ s{\[Not Available\]}{Unknown Size};
4019 $count{sd}++ if $state ne 'Absent';
4020 next SDCARD if blacklisted('sd', $index);
4022 if ($status ne 'Ok') {
4023 my $msg = sprintf 'SD Card %d needs attention: %s',
4025 report('chassis', $msg, $E_WARNING, $index);
4027 # Special case: Not Present
4028 elsif ($status eq 'Ok' and $state eq 'Absent') {
4029 my $msg = sprintf 'SD Card %d [%s] is %s',
4030 $index, $location, $state;
4031 report('chassis', $msg, $E_OK, $index);
4035 my $msg = sprintf 'SD Card %d [%s, %s] is %s',
4036 $index, $location, $capacity, $state;
4037 report('chassis', $msg, $E_OK, $index);
4044 #-----------------------------------------
4045 # CHASSIS: Check alert log
4046 #-----------------------------------------
4047 sub check_alertlog {
4048 return if $snmp; # Not supported with SNMP
4050 my @output = @{ run_omreport("$omopt_system alertlog") };
4051 foreach my $out (@output) {
4052 ++$count{alert}{$out->{Severity}};
4055 # Create error messages and set exit value if appropriate
4057 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
4058 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4060 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
4061 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
4062 report('other', $msg, $err);
4067 #-----------------------------------------
4068 # CHASSIS: Check ESM log overall health
4069 #-----------------------------------------
4070 sub check_esmlog_health {
4074 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
4075 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
4076 if (!defined $result) {
4077 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
4078 $snmp_session->error;
4079 report('other', $msg, $E_UNKNOWN);
4081 $health = get_snmp_status($result->{$systemStateEventLogStatus});
4084 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
4085 if (m/\A Health;(.+) \z/xms) {
4093 # If the overall health of the ESM log is other than "Ok", the
4094 # fill grade of the log is more than 80% and the log should be
4096 if ($health eq 'Ok') {
4097 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
4098 report('other', $msg, $E_OK);
4100 elsif ($health eq 'Critical') {
4101 my $msg = sprintf 'ESM log is 100%% full';
4102 report('other', $msg, $status2nagios{$health});
4105 my $msg = sprintf 'ESM log is more than 80%% full';
4106 report('other', $msg, $status2nagios{$health});
4112 #-----------------------------------------
4113 # CHASSIS: Check ESM log
4114 #-----------------------------------------
4121 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
4123 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
4126 return if !defined $result;
4128 @output = @{ get_snmp_output($result, \%esm_oid) };
4129 foreach my $out (@output) {
4130 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
4134 @output = @{ run_omreport("$omopt_system esmlog") };
4135 foreach my $out (@output) {
4136 ++$count{esm}{$out->{Severity}};
4140 # Create error messages and set exit value if appropriate
4142 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
4143 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4145 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
4146 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
4147 report('other', $msg, $err);
4153 # Handy function for checking all storage components
4156 check_controllers();
4157 check_physical_disks();
4158 check_virtual_disks();
4159 check_cache_battery();
4162 check_enclosure_fans();
4163 check_enclosure_pwr();
4164 check_enclosure_temp();
4165 check_enclosure_emms();
4171 #---------------------------------------------------------------------
4173 #---------------------------------------------------------------------
4176 # Fetch output from 'omreport chassis info', put in sysinfo hash
4178 sub get_omreport_chassis_info {
4179 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
4180 my @lines = <$INFO>;
4183 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag|System\sRevision)/xms;
4184 my ($key, $val) = split /;/xms;
4185 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4186 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4187 if ($key eq 'Chassis Model' or $key eq 'Model') {
4188 $sysinfo{model} = $val;
4190 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
4191 $sysinfo{serial} = $val;
4193 if ($key eq 'System Revision') {
4194 $sysinfo{rev} = q{ } . $val;
4202 # Fetch output from 'omreport chassis bios', put in sysinfo hash
4204 sub get_omreport_chassis_bios {
4205 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
4206 my @lines = <$BIOS>;
4210 my ($key, $val) = split /;/xms;
4211 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4212 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4213 $sysinfo{bios} = $val if $key eq 'Version';
4214 $sysinfo{biosdate} = $val if $key eq 'Release Date';
4221 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
4223 sub get_omreport_system_operatingsystem {
4224 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
4229 my ($key, $val) = split /;/xms;
4230 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4231 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4232 if ($key eq 'Operating System') {
4233 $sysinfo{osname} = $val;
4235 elsif ($key eq 'Operating System Version') {
4236 $sysinfo{osver} = $val;
4244 # Fetch output from 'omreport about', put in sysinfo hash
4246 sub get_omreport_about {
4247 if (open my $OM, '-|', "$omreport about -fmt ssv") {
4251 if (m/\A Version;(.+) \z/xms) {
4261 # Fetch chassis info via SNMP, put in sysinfo hash
4263 sub get_snmp_chassis_info {
4266 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
4267 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
4268 '1.3.6.1.4.1.674.10892.1.300.10.1.48.1' => 'chassisSystemRevisionName',
4271 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
4272 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
4274 if (defined $result) {
4275 foreach my $oid (keys %{ $result }) {
4276 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
4277 $sysinfo{model} = $result->{$oid};
4278 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
4280 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
4281 $sysinfo{serial} = $result->{$oid};
4283 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisSystemRevisionName') {
4284 $sysinfo{rev} = q{ } . $result->{$oid};
4289 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
4290 $snmp_session->error;
4291 report('other', $msg, $E_UNKNOWN);
4297 # Fetch BIOS info via SNMP, put in sysinfo hash
4299 sub get_snmp_chassis_bios {
4302 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
4303 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
4306 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
4307 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
4309 if (defined $result) {
4310 foreach my $oid (keys %{ $result }) {
4311 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
4312 $sysinfo{biosdate} = $result->{$oid};
4313 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
4315 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
4316 $sysinfo{bios} = $result->{$oid};
4321 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
4322 $snmp_session->error;
4323 report('other', $msg, $E_UNKNOWN);
4329 # Fetch OS info via SNMP, put in sysinfo hash
4331 sub get_snmp_system_operatingsystem {
4334 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
4335 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
4338 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
4339 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
4341 if (defined $result) {
4342 foreach my $oid (keys %{ $result }) {
4343 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
4344 $sysinfo{osname} = ($result->{$oid});
4346 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
4347 $sysinfo{osver} = $result->{$oid};
4352 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
4353 $snmp_session->error;
4354 report('other', $msg, $E_UNKNOWN);
4360 # Fetch OMSA version via SNMP, put in sysinfo hash
4362 sub get_snmp_about {
4363 # systemManagementSoftwareGlobalVersionName
4364 my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
4365 my $result = $snmp_session->get_request(-varbindlist => [$oid]);
4367 if (defined $result) {
4368 $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
4369 ? $result->{$oid} : 'unknown';
4372 my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
4373 report('other', $msg, $E_UNKNOWN);
4379 # Collects some information about the system
4383 # Get system model and serial number
4384 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4386 # Get BIOS information. Only if needed
4387 if ( $opt{okinfo} >= 1
4389 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4390 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4393 # Get OMSA information. Only if needed
4394 if ($opt{okinfo} >= 3 or $opt{debug}) {
4395 $snmp ? get_snmp_about() : get_omreport_about();
4398 # Return now if debug
4399 return if $opt{debug};
4401 # Get OS information. Only if needed
4402 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4403 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4410 # Helper function for running omreport when the results are strictly
4412 sub run_omreport_info {
4413 my $command = shift;
4417 # Run omreport and fetch output
4418 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4420 # Parse output, store in array
4421 for ((split /\n/xms, $rawtext)) {
4422 if (m/\A Error/xms) {
4423 my $msg = "Problem running 'omreport $command': $_";
4424 report('other', $msg, $E_UNKNOWN);
4426 next if !m/;/xms; # ignore lines with less than two fields
4427 my @vals = split m/;/xms;
4428 $output{$vals[0]} = $vals[1];
4431 # Finally, return the collected information
4435 # Get various firmware information (BMC, RAC)
4436 sub get_firmware_info {
4437 my @snmp_output = ();
4438 my %nrpe_output = ();
4443 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4444 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4445 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4448 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4449 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4451 # Some don't have this OID, this is ok
4452 if (!defined $result) {
4456 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4459 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4462 my %fw_type # Firmware types
4464 1 => 'other', # other than following values
4465 2 => 'unknown', # unknown
4466 3 => 'systemBIOS', # System BIOS
4467 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4468 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4469 6 => 'systemBackPlane', # System (Primary) Backplane
4470 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4471 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4472 9 => 'frontPanel', # Front Panel Controller
4473 10 => 'baseboardManagementController', # Baseboard Management Controller
4474 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4475 12 => 'sensorData', # Sensor Data Records
4476 13 => 'peripheralBay', # Peripheral Bay Backplane
4477 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4478 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4479 16 => 'rac', # Remote Access Controller
4480 17 => 'iDRAC', # Integrated Dell Remote Access Controller
4481 19 => 'unifiedServerConfigurator', # Unified Server Configurator
4482 20 => 'lifecycleController', # Lifecycle Controller
4487 foreach my $out (@snmp_output) {
4488 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4489 $sysinfo{'bmc'} = 1;
4490 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4492 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|iDRAC \z}xms) {
4493 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4494 $sysinfo{'rac'} = 1;
4495 $sysinfo{'rac_name'} = $name;
4496 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4501 foreach my $key (keys %nrpe_output) {
4502 next if !defined $nrpe_output{$key};
4503 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4504 $sysinfo{'bmc'} = 1;
4505 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4507 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4509 $sysinfo{'rac'} = 1;
4510 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4511 $sysinfo{'rac_name'} = $name;
4521 #=====================================================================
4523 #=====================================================================
4525 # Here we do the actual checking of components
4526 # Check global status if applicable
4528 $globalstatus = check_global();
4531 # Do multiple selected checks
4532 if ($check{storage}) { check_storage(); }
4533 if ($check{memory}) { check_memory(); }
4534 if ($check{fans}) { check_fans(); }
4535 if ($check{power}) { check_powersupplies(); }
4536 if ($check{temp}) { check_temperatures(); }
4537 if ($check{cpu}) { check_processors(); }
4538 if ($check{voltage}) { check_volts(); }
4539 if ($check{batteries}) { check_batteries(); }
4540 if ($check{amperage}) { check_pwrmonitoring(); }
4541 if ($check{intrusion}) { check_intrusion(); }
4542 if ($check{sdcard}) { check_sdcard(); }
4543 if ($check{alertlog}) { check_alertlog(); }
4544 if ($check{esmlog}) { check_esmlog(); }
4545 if ($check{esmhealth}) { check_esmlog_health(); }
4548 #---------------------------------------------------------------------
4550 #---------------------------------------------------------------------
4561 # Get system information
4564 # Get firmware info if requested via option
4565 if ($opt{okinfo} >= 1) {
4566 get_firmware_info();
4569 # Close SNMP session
4571 $snmp_session->close;
4576 # finding the mode of operation
4579 # Setting the domain (IP version and transport protocol)
4580 my $transport = $opt{tcp} ? 'TCP' : 'UDP';
4581 my $ipversion = $opt{ipv6} ? 'IPv6' : 'IPv4';
4582 $mode = "SNMPv$opt{protocol} $transport/$ipversion";
4585 print " System: $sysinfo{model}$sysinfo{rev}";
4586 print q{ } x (25 - length "$sysinfo{model}$sysinfo{rev}"), "OMSA version: $sysinfo{om}\n";
4587 print " ServiceTag: $sysinfo{serial}";
4588 print q{ } x (25 - length $sysinfo{serial}), "Plugin version: $VERSION\n";
4589 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4590 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Checking mode: $mode\n";
4591 if ($#report_storage >= 0) {
4592 print "-----------------------------------------------------------------------------\n";
4593 print " Storage Components \n";
4594 print "=============================================================================\n";
4595 print " STATE | ID | MESSAGE TEXT \n";
4596 print "---------+----------+--------------------------------------------------------\n";
4597 foreach (@report_storage) {
4598 my ($msg, $level, $nexus) = @{$_};
4599 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4600 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4601 $nagios_alert_count{$reverse_exitcode{$level}}++;
4604 if ($#report_chassis >= 0) {
4605 print "-----------------------------------------------------------------------------\n";
4606 print " Chassis Components \n";
4607 print "=============================================================================\n";
4608 print " STATE | ID | MESSAGE TEXT \n";
4609 print "---------+------+------------------------------------------------------------\n";
4610 foreach (@report_chassis) {
4611 my ($msg, $level, $nexus) = @{$_};
4612 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4613 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4614 $nagios_alert_count{$reverse_exitcode{$level}}++;
4617 if ($#report_other >= 0) {
4618 print "-----------------------------------------------------------------------------\n";
4619 print " Other messages \n";
4620 print "=============================================================================\n";
4621 print " STATE | MESSAGE TEXT \n";
4622 print "---------+-------------------------------------------------------------------\n";
4623 foreach (@report_other) {
4624 my ($msg, $level, $nexus) = @{$_};
4625 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4626 $nagios_alert_count{$reverse_exitcode{$level}}++;
4631 my $c = 0; # counter to determine linebreaks
4633 # Run through each message, sorted by severity level
4635 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4636 my ($msg, $level, $nexus) = @{ $_ };
4637 next ALERT if $level == $E_OK;
4639 if (defined $opt{only}) {
4640 # If user wants only critical alerts
4641 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4643 # If user wants only warning alerts
4644 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4647 # Prefix with service tag if specified with option '-i|--info'
4649 if (defined $opt{htmlinfo}) {
4650 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4651 . "\">$sysinfo{serial}</a>] " . $msg;
4654 $msg = "[$sysinfo{serial}] " . $msg;
4658 # Prefix with nagios level if specified with option '--state'
4659 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4661 # Prefix with one-letter nagios level if specified with option '--short-state'
4662 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4664 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4666 $nagios_alert_count{$reverse_exitcode{$level}}++;
4670 # Determine our exit code
4672 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4673 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4674 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4676 # Global status via SNMP.. extra safety check
4677 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4678 print "OOPS! Something is wrong with this server, but I don't know what. ";
4679 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4680 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4681 print "please file a bug report.\n";
4686 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4688 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4689 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4690 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4691 'memory' => "MEMORY OK - $count{dimm} memory modules, $count{mem} MB total memory",
4692 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4693 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4694 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4695 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4696 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4697 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4698 '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",
4699 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4700 'esmhealth' => "ESM LOG OK - less than 80% used",
4701 'sdcard' => "SD CARDS OK - $count{sd} SD cards installed",
4704 print $okmsg{$opt{only}};
4706 # show blacklisted components
4707 if ($opt{show_blacklist} and %blacklist) {
4709 foreach (keys %blacklist) {
4710 push @blstr, "$_=" . join ',', @{ $blacklist{$_} };
4713 print "----- BLACKLISTED: " . join '/', @blstr;
4716 elsif ($exit_code == $E_OK && !$opt{debug}) {
4717 if (defined $opt{htmlinfo}) {
4718 printf q{OK - System: '<a href="%s">%s%s</a>', SN: '<a href="%s">%s</a>'},
4719 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
4720 warranty_url($sysinfo{serial}), $sysinfo{serial};
4723 printf q{OK - System: '%s%s', SN: '%s'},
4724 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
4727 if ($check{memory}) {
4729 if ($count{mem} >= 1024) {
4730 $count{mem} /= 1024;
4733 printf ', %d %s ram (%d dimms)', $count{mem}, $unit, $count{dimm};
4736 print ', not checking memory';
4739 if ($check{storage}) {
4740 printf ', %d logical drives, %d physical drives',
4741 $count{vdisk}, $count{pdisk};
4744 print ', not checking storage';
4747 # show blacklisted components
4748 if ($opt{show_blacklist} and %blacklist) {
4750 foreach (keys %blacklist) {
4751 push @blstr, "$_=" . join ',', @{ $blacklist{$_} };
4754 print "----- BLACKLISTED: " . join '/', @blstr;
4757 if ($opt{okinfo} >= 1) {
4759 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4761 if ($sysinfo{rac}) {
4762 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4764 if ($sysinfo{bmc}) {
4765 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4769 if ($opt{okinfo} >= 2) {
4770 if ($check{storage}) {
4771 my @storageprint = ();
4772 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4773 chomp $sysinfo{controller}{$id}{driver};
4774 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4775 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4776 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4777 if (defined $sysinfo{controller}{$id}{storport}) {
4778 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4780 push @storageprint, $msg;
4782 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4783 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4784 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4785 $sysinfo{enclosure}{$id}->{firmware};
4789 foreach my $line (@storageprint) {
4790 print $linebreak, $line;
4795 if ($opt{okinfo} >= 3) {
4796 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4801 if ($opt{extinfo}) {
4803 if (defined $opt{htmlinfo}) {
4804 printf '------ SYSTEM: <a href="%s">%s%s</a>, SN: <a href="%s">%s</a>',
4805 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
4806 warranty_url($sysinfo{serial}), $sysinfo{serial};
4809 printf '------ SYSTEM: %s%s, SN: %s',
4810 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
4813 if (defined $opt{postmsg}) {
4815 if (-f $opt{postmsg}) {
4816 open my $POST, '<', $opt{postmsg}
4817 or ( print $linebreak
4818 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4819 and exit $E_UNKNOWN );
4825 $post = $opt{postmsg};
4827 if (defined $post) {
4829 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4830 $post =~ s{[%]m}{$sysinfo{model}$sysinfo{rev}}gxms;
4831 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4832 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4833 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4834 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4835 $post =~ s{[%]p}{$count{pdisk}}gxms;
4836 $post =~ s{[%]l}{$count{vdisk}}gxms;
4837 $post =~ s{[%]n}{$linebreak}gxms;
4838 $post =~ s{[%]{2}}{%}gxms;
4844 # Reset the WARN signal
4845 $SIG{__WARN__} = 'DEFAULT';
4847 # Print any perl warnings that have occured
4848 if (@perl_warnings) {
4849 foreach (@perl_warnings) {
4851 print "${linebreak}INTERNAL ERROR: @$_";
4853 $exit_code = $E_UNKNOWN;
4856 # Print performance data
4857 if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
4858 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4861 # Sort routine for performance data
4863 my %order = ( fan => 0, pwr => 1, tem => 2, enc => 3, );
4864 return ($order{(substr $a->{label}, 0, 3)} cmp $order{(substr $b->{label}, 0, 3)}) ||
4865 $a->{label} cmp $b->{label};
4868 # Print performance data sorted
4869 my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
4870 print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
4873 # Print a linebreak at the end
4874 print "\n" if !$opt{debug};
4876 # Exit with proper exit code