5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2010 Trond H. Amundsen
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 require 5.006; # Perl v5.6.0 or newer is required
29 use POSIX qw(isatty ceil);
30 use Getopt::Long qw(:config no_ignore_case);
32 # Global (package) variables used throughout the code
33 use vars qw( $NAME $VERSION $AUTHOR $CONTACT $E_OK $E_WARNING $E_CRITICAL
34 $E_UNKNOWN $FW_LOCK $USAGE $HELP $LICENSE
35 $snmp_session $snmp_error $omreport $globalstatus $global
36 $linebreak $omopt_chassis $omopt_system $blade
38 %check %opt %reverse_exitcode %status2nagios
39 %snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
40 %blacklist %nagios_alert_count %count %snmp_enclosure %snmp_controller
41 @perl_warnings @controllers @enclosures @perfdata
42 @report_storage @report_chassis @report_other
45 #---------------------------------------------------------------------
46 # Initialization and global variables
47 #---------------------------------------------------------------------
49 # Collect perl warnings in an array
50 $SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
52 # Version and similar info
53 $NAME = 'check_openmanage';
54 $VERSION = '3.5.10-beta5';
55 $AUTHOR = 'Trond H. Amundsen';
56 $CONTACT = 't.h.amundsen@usit.uio.no';
64 # Firmware update lock file [FIXME: location on Windows?]
65 $FW_LOCK = '/var/lock/.spsetup'; # default on Linux
68 $USAGE = <<"END_USAGE";
69 Usage: $NAME [OPTION]...
77 -p, --perfdata Output performance data
78 -t, --timeout Plugin timeout in seconds
79 -c, --critical Customise temperature critical limits
80 -w, --warning Customise temperature warning limits
81 -d, --debug Debug output, reports everything
82 -h, --help Display this help text
83 -V, --version Display version info
87 -H, --hostname Hostname or IP (required for SNMP)
88 -C, --community SNMP community string
89 -P, --protocol SNMP protocol version
90 --port SNMP port number
94 -i, --info Prefix any alerts with the service tag
95 -e, --extinfo Append system info to alerts
96 -s, --state Prefix alerts with alert state
97 -S, --short-state Prefix alerts with alert state (abbreviated)
98 -o, --okinfo Verbosity when check result is OK
99 -I, --htmlinfo HTML output with clickable links
101 CHECK CONTROL AND BLACKLISTING:
103 -a, --all Check everything, even log content
104 -b, --blacklist Blacklist missing and/or failed components
105 --only Only check a certain component or alert type
106 --check Fine-tune which components are checked
108 For more information and advanced options, see the manual page or URL:
109 http://folk.uio.no/trondham/software/check_openmanage.html
112 # Version and license text
113 $LICENSE = <<"END_LICENSE";
115 Copyright (C) 2010 $AUTHOR
116 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
117 This is free software: you are free to change and redistribute it.
118 There is NO WARRANTY, to the extent permitted by law.
120 Written by $AUTHOR <$CONTACT>
123 # Options with default values
124 %opt = ( 'blacklist' => [], # blacklisting
125 'check' => [], # check control
126 'critical' => [], # temperature critical limits
127 'warning' => [], # temperature warning limits
128 'timeout' => 30, # default timeout is 30 seconds
129 'debug' => 0, # debugging / verbose output
130 'help' => 0, # display help output
131 'perfdata' => undef, # output performance data
132 'info' => 0, # display servicetag
133 'extinfo' => 0, # display extra info
134 'htmlinfo' => undef, # html tags in output
135 'postmsg' => undef, # post message
136 'state' => 0, # display alert type
137 'short-state' => 0, # display alert type (short)
138 'okinfo' => 0, # default "ok" output level
139 'linebreak' => undef, # specify linebreak
140 'version' => 0, # plugin version info
141 'all' => 0, # check everything
142 'only' => undef, # only one component
143 'omreport' => undef, # omreport path
144 'port' => 161, # default SNMP port
145 'hostname' => undef, # hostname or IP
146 'community' => 'public', # SMNP v1 or v2c
147 'protocol' => 2, # default SNMP protocol 2c
148 'username' => undef, # SMNP v3
149 'authpassword' => undef, # SMNP v3
150 'authkey' => undef, # SMNP v3
151 'authprotocol' => undef, # SMNP v3
152 'privpassword' => undef, # SMNP v3
153 'privkey' => undef, # SMNP v3
154 'privprotocol' => undef, # SMNP v3
155 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
159 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
160 'check=s' => \@{ $opt{check} },
161 'c|critical=s' => \@{ $opt{critical} },
162 'w|warning=s' => \@{ $opt{warning} },
163 't|timeout=i' => \$opt{timeout},
164 'd|debug' => \$opt{debug},
165 'h|help' => \$opt{help},
166 'V|version' => \$opt{version},
167 'p|perfdata:s' => \$opt{perfdata},
168 'i|info' => \$opt{info},
169 'e|extinfo' => \$opt{extinfo},
170 'I|htmlinfo:s' => \$opt{htmlinfo},
171 'postmsg=s' => \$opt{postmsg},
172 's|state' => \$opt{state},
173 'S|short-state' => \$opt{shortstate},
174 'o|ok-info=i' => \$opt{okinfo},
175 'linebreak=s' => \$opt{linebreak},
176 'a|all' => \$opt{all},
177 'only=s' => \$opt{only},
178 'omreport=s' => \$opt{omreport},
179 'port=i' => \$opt{port},
180 'H|hostname=s' => \$opt{hostname},
181 'C|community=s' => \$opt{community},
182 'P|protocol=i' => \$opt{protocol},
183 'U|username=s' => \$opt{username},
184 'authpassword=s' => \$opt{authpassword},
185 'authkey=s' => \$opt{authkey},
186 'authprotocol=s' => \$opt{authprotocol},
187 'privpassword=s' => \$opt{privpassword},
188 'privkey=s' => \$opt{privkey},
189 'privprotocol=s' => \$opt{privprotocol},
190 'use-get_table' => \$opt{use_get_table},
191 ) or do { print $USAGE; exit $E_UNKNOWN };
193 # If user requested help
199 # If user requested version info
207 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
212 # If we're using SNMP
213 $snmp = defined $opt{hostname} ? 1 : 0;
215 # SNMP session variables
216 $snmp_session = undef;
219 # The omreport command
222 # Check flags, override available with the --check option
223 %check = ( 'storage' => 1, # check storage subsystem
224 'memory' => 1, # check memory (dimms)
225 'fans' => 1, # check fan status
226 'power' => 1, # check power supplies
227 'temp' => 1, # check temperature
228 'cpu' => 1, # check processors
229 'voltage' => 1, # check voltage
230 'batteries' => 1, # check battery probes
231 'amperage' => 1, # check power consumption
232 'intrusion' => 1, # check intrusion detection
233 'alertlog' => 0, # check the alert log
234 'esmlog' => 0, # check the ESM log (hardware log)
235 'esmhealth' => 1, # check the ESM log overall health
239 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
241 # Line break from option
242 if (defined $opt{linebreak}) {
243 if ($opt{linebreak} eq 'REG') {
246 elsif ($opt{linebreak} eq 'HTML') {
247 $linebreak = '<br/>';
250 $linebreak = $opt{linebreak};
254 # Exit with status=UNKNOWN if there is firmware upgrade in progress
255 if (!$snmp && -f $FW_LOCK) {
256 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
260 # List of controllers and enclosures
261 @controllers = (); # controllers
262 @enclosures = (); # enclosures
263 %snmp_enclosure = (); # enclosures
266 @report_storage = (); # messages with associated nagios level (storage)
267 @report_chassis = (); # messages with associated nagios level (chassis)
268 @report_other = (); # messages with associated nagios level (other)
270 # Counters for everything
273 'pdisk' => 0, # number of physical disks
274 'vdisk' => 0, # number of logical drives (virtual disks)
275 'temp' => 0, # number of temperature probes
276 'volt' => 0, # number of voltage probes
277 'amp' => 0, # number of amperage probes
278 'intr' => 0, # number of intrusion probes
279 'dimm' => 0, # number of memory modules
280 'mem' => 0, # total memory
281 'fan' => 0, # number of fan probes
282 'cpu' => 0, # number of CPUs
283 'bat' => 0, # number of batteries
284 'power' => 0, # number of power supplies
286 'Critical' => 0, # critical entries in ESM log
287 'Non-Critical' => 0, # warning entries in ESM log
288 'Ok' => 0, # ok entries in ESM log
291 'Critical' => 0, # critical entries in alert log
292 'Non-Critical' => 0, # warning entries in alert log
293 'Ok' => 0, # ok entries in alert log
300 # Global health status
301 $global = 1; # default is to check global status
302 $globalstatus = $E_OK; # default global health status is "OK"
304 # Nagios error levels reversed
308 $E_WARNING => 'WARNING',
309 $E_CRITICAL => 'CRITICAL',
310 $E_UNKNOWN => 'UNKNOWN',
313 # OpenManage (omreport) and SNMP error levels
316 'Unknown' => $E_CRITICAL,
317 'Critical' => $E_CRITICAL,
318 'Non-Critical' => $E_WARNING,
320 'Non-Recoverable' => $E_CRITICAL,
321 'Other' => $E_CRITICAL,
332 6 => 'Non-Recoverable',
335 # Probe Status via SNMP
338 1 => 'Other', # probe status is not one of the following:
339 2 => 'Unknown', # probe status is unknown (not known or monitored)
340 3 => 'Ok', # probe is reporting a value within the thresholds
341 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
342 5 => 'criticalUpper', # probe has crossed upper critical threshold
343 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
344 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
345 8 => 'criticalLower', # probe has crossed lower critical threshold
346 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
347 10 => 'failed', # probe is not functional
350 # Probe status translated to Nagios alarm levels
353 'Other' => $E_CRITICAL,
354 'Unknown' => $E_CRITICAL,
356 'nonCriticalUpper' => $E_WARNING,
357 'criticalUpper' => $E_CRITICAL,
358 'nonRecoverableUpper' => $E_CRITICAL,
359 'nonCriticalLower' => $E_WARNING,
360 'criticalLower' => $E_CRITICAL,
361 'nonRecoverableLower' => $E_CRITICAL,
362 'failed' => $E_CRITICAL,
365 # System information gathered
368 'bios' => 'N/A', # BIOS version
369 'biosdate' => 'N/A', # BIOS release date
370 'serial' => 'N/A', # serial number (service tag)
371 'model' => 'N/A', # system model
372 'osname' => 'N/A', # OS name
373 'osver' => 'N/A', # OS version
374 'om' => 'N/A', # OMSA version
375 'bmc' => 0, # HAS baseboard management controller (BMC)
376 'rac' => 0, # HAS remote access controller (RAC)
377 'rac_name' => 'N/A', # remote access controller (RAC)
378 'bmc_fw' => 'N/A', # BMC firmware
379 'rac_fw' => 'N/A', # RAC firmware
382 # Adjust which checks to perform
383 adjust_checks() if defined $opt{check};
385 # Blacklisted components
386 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
388 # If blacklisting is in effect, don't check global health status
389 if (scalar keys %blacklist > 0) {
393 # Take into account new hardware and blades
394 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
395 $omopt_system = 'system'; # default "system" option to omreport
396 $blade = 0; # if this is a blade system
398 # Some initializations and checking before we begin
400 snmp_initialize(); # initialize SNMP
401 snmp_check(); # check that SNMP works
402 snmp_detect_blade(); # detect blade via SNMP
405 # Find the omreport binary
407 # Check help output from omreport, see which options are available.
408 # Also detecting blade via omreport.
409 check_omreport_options();
413 #---------------------------------------------------------------------
415 #---------------------------------------------------------------------
418 # Store a message in one of the message arrays
421 my ($type, $msg, $exval, $id) = @_;
422 defined $id or $id = q{};
426 'storage' => \@report_storage,
427 'chassis' => \@report_chassis,
428 'other' => \@report_other,
431 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
436 # Run command, put resulting output lines in an array and return a
437 # pointer to that array
442 open my $CMD, '-|', $command
443 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
447 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
448 and return \@lines };
453 # Run command, put resulting output in a string variable and return it
458 open my $CMD, '-|', $command
459 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
460 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
463 # NOTE: We don't check the return value of close() since omreport
464 # does something weird sometimes.
472 sub snmp_initialize {
473 # Legal SNMP v3 protocols
474 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
475 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
477 # Parameters to Net::SNMP->session()
480 '-port' => $opt{port},
481 '-hostname' => $opt{hostname},
482 '-version' => $opt{protocol},
485 # Parameters for SNMP v3
486 if ($opt{protocol} == 3) {
488 # Username is mandatory
489 if (defined $opt{username}) {
490 $param{'-username'} = $opt{username};
493 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
497 # Authpassword is optional
498 if (defined $opt{authpassword}) {
499 $param{'-authpassword'} = $opt{authpassword};
502 # Authkey is optional
503 if (defined $opt{authkey}) {
504 $param{'-authkey'} = $opt{authkey};
507 # Privpassword is optional
508 if (defined $opt{privpassword}) {
509 $param{'-privpassword'} = $opt{privpassword};
512 # Privkey is optional
513 if (defined $opt{privkey}) {
514 $param{'-privkey'} = $opt{privkey};
517 # Privprotocol is optional
518 if (defined $opt{privprotocol}) {
519 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
520 $param{'-privprotocol'} = $opt{privprotocol};
523 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
524 . "must be one of [des|aes|aes128|3des|3desde]\n";
529 # Authprotocol is optional
530 if (defined $opt{authprotocol}) {
531 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
532 $param{'-authprotocol'} = $opt{authprotocol};
535 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
536 . "must be one of [md5|sha]\n";
541 # Parameters for SNMP v2c or v1
542 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
543 $param{'-community'} = $opt{community};
546 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
550 # Try to initialize the SNMP session
551 if ( eval { require Net::SNMP; 1 } ) {
552 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
553 if (!defined $snmp_session) {
554 printf "SNMP: %s\n", $snmp_error;
559 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
566 # Checking if SNMP works by probing for "chassisModelName", which all
567 # servers should have
570 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
571 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
573 # Typically if remote host isn't responding
574 if (!defined $result) {
575 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
579 # If OpenManage isn't installed or is not working
580 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
581 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
588 # Detecting blade via SNMP
590 sub snmp_detect_blade {
591 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
592 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
594 # Identify blade. Older models (4th and 5th gen models) and/or old
595 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
596 # similar, we assume that this isn't a blade
597 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
604 # Locate the omreport binary
607 # If user has specified path to omreport
608 if (defined $opt{omreport} and -x $opt{omreport}) {
609 $omreport = qq{"$opt{omreport}"};
613 # Possible full paths for omreport
616 '/usr/bin/omreport', # default on Linux
617 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA 6.2.0
618 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
619 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
620 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
621 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
622 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
623 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
626 # Find the one to use
628 foreach my $bin (@omreport_paths) {
630 $omreport = qq{"$bin"};
635 # Exit with status=UNKNOWN if OM is not installed, or we don't
636 # have permission to execute the binary
637 if (!defined $omreport) {
638 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
645 # Checks output from 'omreport -?' and searches for arguments to
646 # omreport, to accommodate deprecated options "chassis" and "system"
647 # (on newer hardware), as well as blade servers.
649 sub check_omreport_options {
650 foreach (@{ run_command("$omreport -? 2>&1") }) {
651 if (m/\A servermodule /xms) {
652 # If "servermodule" argument to omreport exists, use it
653 # instead of argument "system"
654 $omopt_system = 'servermodule';
656 elsif (m/\A mainsystem /xms) {
657 # If "mainsystem" argument to omreport exists, use it
658 # instead of argument "chassis"
659 $omopt_chassis = 'mainsystem';
661 elsif (m/\A modularenclosure /xms) {
662 # If "modularenclusure" argument to omreport exists, assume
663 # that this is a blade
671 # Read the blacklist option and return a hash containing the
672 # blacklisted components
678 if (scalar @{ $opt{blacklist} } >= 0) {
679 foreach my $black (@{ $opt{blacklist} }) {
682 open my $BL, '<', $black
683 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
696 return {} if $#bl < 0;
698 # Parse blacklist string, put in hash
699 foreach my $black (@bl) {
700 my @comps = split m{/}xms, $black;
701 foreach my $c (@comps) {
702 next if $c !~ m/=/xms;
703 my ($key, $val) = split /=/xms, $c;
704 my @vals = split /,/xms, $val;
705 $blacklist{$key} = \@vals;
713 # Read the check option and adjust the hash %check, which is a rough
714 # list of components to be checked
719 # Adjust checking based on the '--all' option
722 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
723 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
726 if (scalar @{ $opt{check} } > 0) {
727 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
731 # set the check hash to check everything
732 map { $_ = 1 } values %check;
737 # Adjust checking based on the '--only' option
738 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
740 if (scalar @{ $opt{check} } > 0) {
741 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
744 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
745 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
749 # reset the check hash
750 map { $_ = 0 } values %check;
752 # adjust the check hash
753 if ($opt{only} eq 'chassis') {
754 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
755 batteries amperage intrusion esmhealth);
758 $check{$opt{only}} = 1;
764 # Adjust checking based on the '--check' option
765 if (scalar @{ $opt{check} } >= 0) {
766 foreach my $check (@{ $opt{check} }) {
769 open my $CL, '<', $check
770 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
783 # Parse checklist string, put in hash
784 foreach my $check (@cl) {
785 my @checks = split /,/xms, $check;
786 foreach my $c (@checks) {
787 next if $c !~ m/=/xms;
788 my ($key, $val) = split /=/xms, $c;
793 # Check if we should check global health status
795 foreach (keys %check) {
796 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
797 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
799 if ($check{$_} == 0) { # found something with checking turned off
809 # Runs omreport and returns an array of anonymous hashes containing
811 # Takes one argument: string containing parameters to omreport
818 # Errors that are OK. Some low-end poweredge (and blades) models
819 # don't have RAID controllers, intrusion detection sensor, or
820 # redundant/instrumented power supplies etc.
823 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
824 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
825 | No\scontrollers\sfound # No RAID controller
826 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
827 | Invalid\scommand:\spwrmonitoring # Older OMSAs lack this command(?)
828 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
831 # Errors that are OK on blade servers
834 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
837 # Run omreport and fetch output
838 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
839 return [] if !defined $rawtext;
841 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
842 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
844 # Openmanage sometimes puts a linebreak between "Error" and the
846 $rawtext =~ s{^Error\s*\n}{Error: }xms;
848 # Parse output, store in array
849 for ((split m{\n}xms, $rawtext)) {
851 next if m{$ok_errors}xms;
852 next if ($blade and m{$ok_blade_errors}xms);
853 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
856 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
857 my @vals = split /;/xms;
858 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed) \z/xms) {
863 push @output, { map { $_ => $vals[$i++] } @keys };
868 # Finally, return the collected information
874 # Checks if a component is blacklisted. Returns 1 if the component is
875 # blacklisted, 0 otherwise. Takes two arguments:
876 # arg1: component name
877 # arg2: component id or index
880 my $name = shift; # component name
881 my $id = shift; # component id
882 my $ret = 0; # return value
884 if (defined $blacklist{$name}) {
885 foreach my $comp (@{ $blacklist{$name} }) {
886 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
895 # Converts the NexusID from SNMP to our version
898 $nexus =~ s{\A \\}{}xms;
899 $nexus =~ s{\\}{:}gxms;
903 # Sets custom temperature thresholds based on user supplied options
904 sub custom_temperature_thresholds {
905 my $type = shift; # type of threshold, either w (warning) or c (critical)
906 my %thres = (); # will contain the thresholds
907 my @limits = (); # holds the input
909 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
911 if (scalar @opt >= 0) {
912 foreach my $t (@opt) {
916 or do { report('other', "Couldn't open temperature threshold file $t: $!",
917 $E_UNKNOWN) and return {} };
928 # Parse checklist string, put in hash
929 foreach my $th (@limits) {
930 my @tmp = split m{,}xms, $th;
931 foreach my $t (@tmp) {
932 next if $t !~ m{=}xms;
933 my ($key, $val) = split m{=}xms, $t;
934 if ($val =~ m{/}xms) {
935 my ($max, $min) = split m{/}xms, $val;
936 $thres{$key}{max} = $max;
937 $thres{$key}{min} = $min;
940 $thres{$key}{max} = $val;
949 # Gets the output from SNMP result according to the OIDs checked
950 sub get_snmp_output {
951 my ($result,$oidref) = @_;
955 foreach my $oid (keys %{ $result }) {
957 $short =~ s{\s}{}gxms; # remove whitespace
958 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
960 if (exists $oidref->{$short}) {
961 $temp[$id]{$oidref->{$short}} = $result->{$oid};
965 # Remove any empty indexes
966 foreach my $out (@temp) {
976 # Map the controller or other item in-place
978 my ($key, $val, $list) = @_;
980 foreach my $lst (@{ $list }) {
981 if (!exists $lst->{$key}) {
988 # Return the URL for official Dell documentation for a specific
990 sub documentation_url {
993 # create model short form, e.g. "r710"
994 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
996 # special case for blades (e.g. M600, M710), they have common
998 $model =~ s{\A m\d+ \z}{m}xms;
1000 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1003 # Return the URL for warranty information for a server with a given
1004 # serial number (servicetag)
1008 # Dell support sites for different parts of the world
1011 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1012 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1013 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1016 # warranty URLs for different country codes
1020 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1021 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1022 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1023 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1024 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1025 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1026 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1027 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1028 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1029 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1030 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1031 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1032 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1033 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1034 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1035 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1036 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1037 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1038 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1039 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1041 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1042 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1043 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1044 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1046 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1047 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1048 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1050 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1053 if (exists $url{$opt{htmlinfo}}) {
1054 return $url{$opt{htmlinfo}} . $tag;
1057 return $url{XX} . $tag;
1062 # This helper function returns the corresponding value of a hash key,
1063 # but takes into account that the key may not exist
1065 my $key = shift || return undef;
1067 return exists $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1072 #---------------------------------------------------------------------
1074 #---------------------------------------------------------------------
1076 #-----------------------------------------
1077 # Check global health status
1078 #-----------------------------------------
1084 # Checks global status, i.e. both storage and chassis
1086 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1087 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1088 if (!defined $result) {
1089 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1092 $health = $status2nagios{$snmp_status{$result->{$systemStateGlobalSystemStatus}}};
1096 # NB! This does not check storage, only chassis...
1098 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1100 next if m/\A SEVERITY;COMPONENT/xms;
1101 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1102 $health = $status2nagios{$1};
1113 #-----------------------------------------
1114 # STORAGE: Check controllers
1115 #-----------------------------------------
1116 sub check_controllers {
1117 return if blacklisted('ctrl', 'all');
1126 my $firmware = undef;
1128 my $minstdr = undef; # Minimum required Storport driver version
1129 my $stdr = undef; # Storport driver version
1135 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1136 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1137 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1138 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1139 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1140 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1141 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1142 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1143 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1144 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1145 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1148 # We use get_table() here for the odd case where a server has
1149 # two or more controllers, and where some OIDs are missing on
1150 # one of the controllers.
1151 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1152 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1154 # No controllers is OK
1155 return if !defined $result;
1157 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1160 @output = @{ run_omreport('storage controller') };
1174 foreach my $out (@output) {
1176 # $id = $out->{controllerNumber} - 1;
1177 $name = $out->{controllerName};
1178 $state = get_hashval($out->{controllerState}, \%ctrl_state);
1179 $status = $snmp_status{$out->{controllerComponentStatus}};
1180 $minfw = exists $out->{controllerMinFWVersion}
1181 ? $out->{controllerMinFWVersion} : undef;
1182 $mindr = exists $out->{controllerMinDriverVersion}
1183 ? $out->{controllerMinDriverVersion} : undef;
1184 $firmware = exists $out->{controllerFWVersion}
1185 ? $out->{controllerFWVersion} : 'N/A';
1186 $driver = exists $out->{controllerDriverVersion}
1187 ? $out->{controllerDriverVersion} : 'N/A';
1188 $minstdr = exists $out->{'controllerMinRequiredStorportVer'}
1189 ? $out->{controllerMinRequiredStorportVer} : undef;
1190 $stdr = exists $out->{controllerStorportDriverVersion}
1191 ? $out->{controllerStorportDriverVersion} : undef;
1192 $nexus = convert_nexus($out->{controllerNexusID});
1197 $name = $out->{Name};
1198 $state = $out->{State};
1199 $status = $out->{Status};
1200 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1201 ? $out->{'Minimum Required Firmware Version'} : undef;
1202 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1203 ? $out->{'Minimum Required Driver Version'} : undef;
1204 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1205 ? $out->{'Firmware Version'} : 'N/A';
1206 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1207 ? $out->{'Driver Version'} : 'N/A';
1208 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1209 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1210 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1211 $stdr = (exists $out->{'Storport Driver Version'}
1212 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1213 ? $out->{'Storport Driver Version'} : undef;
1217 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1218 push @controllers, $id;
1220 # Collecting some storage info
1221 $sysinfo{'controller'}{$id}{'id'} = $nexus;
1222 $sysinfo{'controller'}{$id}{'name'} = $name;
1223 $sysinfo{'controller'}{$id}{'driver'} = $driver;
1224 $sysinfo{'controller'}{$id}{'firmware'} = $firmware;
1225 $sysinfo{'controller'}{$id}{'storport'} = $stdr;
1229 $snmp_controller{$out->{controllerNumber}} = $nexus;
1232 next CTRL if blacklisted('ctrl', $nexus);
1234 # Special case: old firmware
1235 if (!blacklisted('ctrl_fw', $id) && defined $minfw) {
1237 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1238 $id, $name, $firmware;
1239 report('storage', $msg, $E_WARNING, $nexus);
1241 # Special case: old driver
1242 if (!blacklisted('ctrl_driver', $id) && defined $mindr) {
1244 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1245 $id, $name, $driver;
1246 report('storage', $msg, $E_WARNING, $nexus);
1248 # Special case: old storport driver
1249 if (!blacklisted('ctrl_stdr', $id) && defined $minstdr) {
1251 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1253 report('storage', $msg, $E_WARNING, $nexus);
1256 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1257 and (defined $minfw or defined $mindr or defined $minstdr))) {
1258 my $msg = sprintf 'Controller %d [%s] is %s',
1260 report('storage', $msg, $E_OK, $nexus);
1264 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1266 report('storage', $msg, $status2nagios{$status}, $nexus);
1273 #-----------------------------------------
1274 # STORAGE: Check physical drives
1275 #-----------------------------------------
1276 sub check_physical_disks {
1277 return if $#controllers == -1;
1278 return if blacklisted('pdisk', 'all');
1288 my $vendor = undef; # disk vendor
1289 my $product = undef; # product ID
1290 my $capacity = undef; # disk length (size) in bytes
1291 my $media = undef; # media type (e.g. HDD, SSD)
1292 my $bus = undef; # bus protocol (e.g. SAS, SATA)
1298 '1.3.6.1.4.1.674.10893.1.20.130.4.1.1' => 'arrayDiskNumber',
1299 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1300 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1301 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1302 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1303 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1304 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1305 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1306 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1307 '1.3.6.1.4.1.674.10893.1.20.130.4.1.21' => 'arrayDiskBusType',
1308 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1309 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1310 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1311 '1.3.6.1.4.1.674.10893.1.20.130.4.1.35' => 'arrayDiskMediaType',
1312 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1313 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1316 if ($opt{use_get_table}) {
1317 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1318 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1319 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1321 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1322 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1323 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1325 if (defined $result) {
1326 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1327 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1331 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1334 if (!defined $result) {
1335 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1336 $snmp_session->close;
1340 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1343 foreach my $c (@controllers) {
1344 # This blacklists disks with broken firmware, which includes
1345 # illegal XML characters that makes openmanage choke on itself
1346 next if blacklisted('ctrl_pdisk', $c);
1348 push @output, @{ run_omreport("storage pdisk controller=$c") };
1349 map_item('ctrl', $c, \@output);
1364 3 => 'Fibre Channel',
1382 22 => 'Replacing', # FIXME: this one is not defined in the OM 6.2.0.1 MIBs
1386 28 => 'Diagnostics',
1387 34 => 'Predictive failure',
1388 35 => 'Initializing',
1391 41 => 'Unsupported',
1392 53 => 'Incompatible',
1395 # Check physical disks on each of the controllers
1397 foreach my $out (@output) {
1399 $name = $out->{arrayDiskName};
1400 if (exists $out->{arrayDiskEnclosureID}) {
1401 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskEnclosureID},
1402 $out->{arrayDiskTargetID});
1405 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskTargetID});
1407 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state);
1408 $status = $snmp_status{$out->{arrayDiskComponentStatus}};
1409 $fpred = $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1411 $nexus = convert_nexus($out->{arrayDiskNexusID});
1412 $vendor = $out->{arrayDiskVendor};
1413 $product = $out->{arrayDiskProductID};
1414 $bus = exists $out->{arrayDiskBusType}
1415 ? get_hashval($out->{arrayDiskBusType}, \%bus_type) : undef;
1416 $media = exists $out->{arrayDiskMediaType}
1417 ? get_hashval($out->{arrayDiskMediaType}, \%media_type) : undef;
1418 $capacity = $out->{arrayDiskLengthInMB} * 1024**2;
1419 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1420 $ctrl = $snmp_controller{$out->{arrayDiskEnclosureConnectionControllerNumber}};
1422 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1423 $ctrl = $snmp_controller{$out->{arrayDiskChannelConnectionControllerNumber}};
1426 # last resort... use the nexus id
1428 $ctrl =~ s{\A (\d+) : .* \z}{$1}xms;
1433 $name = $out->{'Name'};
1434 $state = $out->{'State'};
1435 $status = $out->{'Status'};
1436 $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
1437 $progr = ' [' . $out->{'Progress'} . ']';
1438 $ctrl = $out->{'ctrl'};
1439 $nexus = join q{:}, $out->{ctrl}, $id;
1440 $vendor = $out->{'Vendor ID'};
1441 $product = $out->{'Product ID'};
1442 $media = $out->{'Media'};
1443 $bus = $out->{'Bus Protocol'};
1444 $capacity = $out->{'Capacity'};
1445 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1448 next PDISK if blacklisted('pdisk', $nexus);
1451 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1452 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1454 # Calculate human readable capacity
1455 $capacity = ceil($capacity / 1000**3) >= 1000
1456 ? sprintf '%.1fTB', ($capacity / 1000**4)
1457 : sprintf '%.0fGB', ($capacity / 1000**3);
1458 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1459 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1460 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1461 $capacity = '100GB' if $capacity eq '99GB'; # quick fix for 100GB disks
1463 # Capitalize only the first letter of the vendor name
1464 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1466 # Remove unnecessary trademark rubbish from vendor name
1467 $vendor =~ s{\(tm\)\z}{}xms;
1469 # bus and media aren't always defined
1471 if (defined $bus && defined $media) { $busmedia = "$bus-$media "; }
1472 elsif (defined $bus && ! defined $media) { $busmedia = "$bus "; }
1473 elsif (! defined $bus && defined $media) { $busmedia = "$media "; }
1475 # Special case: Failure predicted
1477 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1478 $name, $vendor, $product, $capacity, $ctrl;
1479 $msg .= " ($state)" if $state ne 'Predictive failure';
1480 report('storage', $msg,
1481 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1483 # Special case: Rebuilding / Replacing
1484 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1485 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1486 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1487 report('storage', $msg, $E_WARNING, $nexus);
1490 elsif ($status ne 'Ok') {
1491 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1492 $name, $vendor, $product, $capacity, $ctrl, $state;
1493 report('storage', $msg, $status2nagios{$status}, $nexus);
1497 my $msg = sprintf '%s [%s%s] on ctrl %d is %s',
1498 $name, $busmedia, $capacity, $ctrl, $state;
1499 report('storage', $msg, $E_OK, $nexus);
1506 #-----------------------------------------
1507 # STORAGE: Check logical drives
1508 #-----------------------------------------
1509 sub check_virtual_disks {
1510 return if $#controllers == -1;
1511 return if blacklisted('vdisk', 'all');
1528 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1529 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1530 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1531 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1532 '1.3.6.1.4.1.674.10893.1.20.140.1.1.17' => 'virtualDiskTargetID',
1533 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1534 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1537 if ($opt{use_get_table}) {
1538 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1539 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1542 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1545 # No logical drives is OK
1546 return if !defined $result;
1548 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1551 foreach my $c (@controllers) {
1552 push @output, @{ run_omreport("storage vdisk controller=$c") };
1553 map_item('ctrl', $c, \@output);
1566 16 => 'Regenerating',
1569 32 => 'Reconstructing',
1570 35 => 'Initializing',
1571 36 => 'Background Initialization',
1572 38 => 'Resynching Paused',
1573 52 => 'Permanently Degraded',
1574 54 => 'Degraded Redundancy',
1579 1 => 'Concatenated',
1586 19 => 'Concatenated RAID-1',
1590 # Check virtual disks on each of the controllers
1592 foreach my $out (@output) {
1594 $id = $out->{virtualDiskTargetID};
1595 $dev = $out->{virtualDiskDeviceName};
1596 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state);
1597 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout);
1598 $status = $snmp_status{$out->{virtualDiskComponentStatus}};
1599 $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
1600 $progr = q{}; # can't get this from SNMP(?)
1601 $nexus = convert_nexus($out->{virtualDiskNexusID});
1605 $dev = $out->{'Device Name'};
1606 $state = $out->{State};
1607 $status = $out->{Status};
1608 $layout = $out->{Layout};
1609 $size = $out->{Size};
1610 $progr = ' [' . $out->{Progress} . ']';
1611 $size =~ s{\A (.*GB).* \z}{$1}xms;
1612 $nexus = join q{:}, $out->{ctrl}, $id;
1613 $ctrl = $out->{ctrl};
1616 next VDISK if blacklisted('vdisk', $nexus);
1619 # The device name is undefined sometimes
1620 $dev = q{} if !defined $dev;
1622 # Special case: Regenerating
1623 if ($state eq 'Regenerating') {
1624 my $msg = sprintf q{Logical drive '%s' [%s, %s] is %s%s},
1625 $dev, $layout, $size, $state, $progr;
1626 report('storage', $msg, $E_WARNING, $nexus);
1629 elsif ($status ne 'Ok') {
1630 my $msg = sprintf q{Logical drive '%s' [%s, %s] needs attention: %s},
1631 $dev, $layout, $size, $state;
1632 report('storage', $msg, $status2nagios{$status}, $nexus);
1636 my $msg = sprintf q{Logical drive '%s' [%s, %s] is %s},
1637 $dev, $layout, $size, $state;
1638 report('storage', $msg, $E_OK, $nexus);
1645 #-----------------------------------------
1646 # STORAGE: Check cache batteries
1647 #-----------------------------------------
1648 sub check_cache_battery {
1649 return if $#controllers == -1;
1650 return if blacklisted('bat', 'all');
1657 my $learn = undef; # learn state
1658 my $pred = undef; # battery's ability to be charged
1664 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1665 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1666 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1667 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1668 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1669 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1672 if ($opt{use_get_table}) {
1673 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
1674 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
1676 $result = $snmp_session->get_table(-baseoid => $batteryTable);
1677 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
1679 if (defined $result) {
1680 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
1684 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1687 # No cache battery is OK
1688 return if !defined $result;
1690 @output = @{ get_snmp_output($result, \%bat_oid) };
1693 foreach my $c (@controllers) {
1694 push @output, @{ run_omreport("storage battery controller=$c") };
1695 map_item('ctrl', $c, \@output);
1705 7 => 'Reconditioning',
1713 # Specifies the learn state activity of the battery
1723 # This property displays the battery's ability to be charged
1726 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1727 2 => 'Ready', # The battery can be charged to full capacity
1728 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1729 # battery cannot be determined until the Learn cycle is complete
1732 # Check battery on each of the controllers
1734 foreach my $out (@output) {
1736 $status = $snmp_status{$out->{batteryComponentStatus}};
1737 $state = get_hashval($out->{batteryState}, \%bat_state);
1738 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state);
1739 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap);
1740 $ctrl = $out->{batteryConnectionControllerNumber} - 1;
1741 $nexus = convert_nexus($out->{batteryNexusID});
1743 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1747 $state = $out->{'State'};
1748 $status = $out->{'Status'};
1749 $learn = $out->{'Learn State'};
1750 $pred = $out->{'Predicted Capacity Status'};
1751 $ctrl = $out->{'ctrl'};
1752 $nexus = join q{:}, $out->{ctrl}, $id;
1755 next BATTERY if blacklisted('bat', $nexus);
1757 # Special case: Charging
1758 if ($state eq 'Charging') {
1759 if ($pred eq 'Failed') {
1760 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [replace battery]',
1761 $id, $ctrl, $state, $pred;
1762 report('storage', $msg, $E_CRITICAL, $nexus);
1765 next BATTERY if blacklisted('bat_charge', $nexus);
1766 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1767 $id, $ctrl, $state, $pred;
1768 report('storage', $msg, $E_WARNING, $nexus);
1771 # Special case: Learning (battery learns its capacity)
1772 elsif ($state eq 'Learning') {
1773 if ($learn eq 'Failed') {
1774 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s)',
1775 $id, $ctrl, $state, $learn;
1776 report('storage', $msg, $E_CRITICAL, $nexus);
1779 next BATTERY if blacklisted('bat_charge', $nexus);
1780 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1781 $id, $ctrl, $state, $learn;
1782 report('storage', $msg, $E_WARNING, $nexus);
1785 # Special case: Power Low (first part of recharge cycle)
1786 elsif ($state eq 'Power Low') {
1787 next BATTERY if blacklisted('bat_charge', $nexus);
1788 my $msg = sprintf 'Cache battery %d in controller %d is %s [probably harmless]',
1790 report('storage', $msg, $E_WARNING, $nexus);
1792 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1793 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1794 next BATTERY if blacklisted('bat_charge', $nexus);
1795 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1796 $id, $ctrl, $state, $status;
1797 report('storage', $msg, $E_WARNING, $nexus);
1800 elsif ($status ne 'Ok') {
1801 my $msg = sprintf 'Cache battery %d in controller %d needs attention: %s (%s)',
1802 $id, $ctrl, $state, $status;
1803 report('storage', $msg, $status2nagios{$status}, $nexus);
1807 my $msg = sprintf 'Cache battery %d in controller %d is %s',
1809 report('storage', $msg, $E_OK, $nexus);
1816 #-----------------------------------------
1817 # STORAGE: Check connectors (channels)
1818 #-----------------------------------------
1819 sub check_connectors {
1820 return if $#controllers == -1;
1821 return if blacklisted('conn', 'all');
1835 '1.3.6.1.4.1.674.10893.1.20.130.2.1.1' => 'channelNumber',
1836 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1837 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1838 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1839 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1840 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1843 if ($opt{use_get_table}) {
1844 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
1845 $result = $snmp_session->get_table(-baseoid => $channelTable);
1848 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1851 if (!defined $result) {
1852 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1853 $snmp_session->close;
1857 @output = @{ get_snmp_output($result, \%conn_oid) };
1860 foreach my $c (@controllers) {
1861 push @output, @{ run_omreport("storage connector controller=$c") };
1862 map_item('ctrl', $c, \@output);
1880 3 => 'Fibre Channel',
1887 # Check connectors on each of the controllers
1889 foreach my $out (@output) {
1891 $id = $out->{channelNumber} - 1;
1892 $name = $out->{channelName};
1893 $status = $snmp_status{$out->{channelComponentStatus}};
1894 $state = get_hashval($out->{channelState}, \%conn_state);
1895 $type = get_hashval($out->{channelBusType}, \%conn_bustype);
1896 $nexus = convert_nexus($out->{channelNexusID});
1898 $ctrl =~ s{(\d+):\d+}{$1}xms;
1902 $name = $out->{'Name'};
1903 $state = $out->{'State'};
1904 $status = $out->{'Status'};
1905 $type = $out->{'Connector Type'};
1906 $ctrl = $out->{ctrl};
1907 $nexus = join q{:}, $out->{ctrl}, $id;
1910 next CHANNEL if blacklisted('conn', $nexus);
1912 my $msg = sprintf '%s [%s] on controller %d is %s',
1913 $name, $type, $ctrl, $state;
1914 report('storage', $msg, $status2nagios{$status}, $nexus);
1920 #-----------------------------------------
1921 # STORAGE: Check enclosures
1922 #-----------------------------------------
1923 sub check_enclosures {
1924 return if blacklisted('encl', 'all');
1931 my $firmware = undef;
1938 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
1939 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
1940 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
1941 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
1942 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
1943 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
1944 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
1947 if ($opt{use_get_table}) {
1948 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
1949 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
1952 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
1955 # No enclosures is OK
1956 return if !defined $result;
1958 @output = @{ get_snmp_output($result, \%encl_oid) };
1961 foreach my $c (@controllers) {
1962 push @output, @{ run_omreport("storage enclosure controller=$c") };
1963 map_item('ctrl', $c, \@output);
1978 foreach my $out (@output) {
1980 $id = $out->{enclosureNumber} - 1;
1981 $name = $out->{enclosureName};
1982 $state = get_hashval($out->{enclosureState}, \%encl_state);
1983 $status = $snmp_status{$out->{enclosureComponentStatus}};
1984 $firmware = exists $out->{enclosureFirmwareVersion}
1985 ? $out->{enclosureFirmwareVersion} : 'N/A';
1986 $nexus = convert_nexus($out->{enclosureNexusID});
1988 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
1992 $name = $out->{Name};
1993 $state = $out->{State};
1994 $status = $out->{Status};
1995 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1996 ? $out->{'Firmware Version'} : 'N/A';
1997 $nexus = join q{:}, $out->{ctrl}, $id;
1998 $ctrl = $out->{ctrl};
2001 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
2002 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
2004 # store enclosure data for future use
2005 push @enclosures, { 'id' => $id,
2006 'ctrl' => $out->{ctrl},
2008 'nexus' => $nexus };
2012 $snmp_enclosure{$out->{enclosureNumber}}{id} = $id;
2013 $snmp_enclosure{$out->{enclosureNumber}}{name} = $name;
2014 $snmp_enclosure{$out->{enclosureNumber}}{nexus} = $nexus;
2017 # Collecting some storage info
2018 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
2019 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
2020 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
2022 next ENCLOSURE if blacklisted('encl', $nexus);
2024 my $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
2025 $nexus, $name, $ctrl, $state;
2026 report('storage', $msg, $status2nagios{$status}, $nexus);
2032 #-----------------------------------------
2033 # STORAGE: Check enclosure fans
2034 #-----------------------------------------
2035 sub check_enclosure_fans {
2036 return if $#controllers == -1;
2037 return if blacklisted('encl_fan', 'all');
2045 my $encl_id = undef;
2046 my $encl_name = undef;
2052 '1.3.6.1.4.1.674.10893.1.20.130.7.1.1' => 'fanNumber',
2053 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2054 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2055 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2056 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2057 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2058 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2059 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2062 if ($opt{use_get_table}) {
2063 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2064 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2066 $result = $snmp_session->get_table(-baseoid => $fanTable);
2067 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2069 if (defined $result) {
2070 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2074 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2077 # No enclosure fans is OK
2078 return if !defined $result;
2080 @output = @{ get_snmp_output($result, \%fan_oid) };
2083 foreach my $enc (@enclosures) {
2084 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2085 map_item('ctrl', $enc->{ctrl}, \@output);
2086 map_item('encl_id', $enc->{id}, \@output);
2087 map_item('encl_name', $enc->{name}, \@output);
2102 # Check fans on each of the enclosures
2104 foreach my $out (@output) {
2106 $id = $out->{fanNumber} - 1;
2107 $name = $out->{fanName};
2108 $state = get_hashval($out->{fanState}, \%fan_state);
2109 $status = $snmp_status{$out->{fanComponentStatus}};
2110 $speed = $out->{fanProbeCurrValue};
2111 #$encl_id = $out->{fanConnectionEnclosureNumber} - 1;
2112 $encl_name = $out->{fanConnectionEnclosureName};
2114 $encl_id = $snmp_enclosure{$out->{fanConnectionEnclosureNumber}}{nexus};
2117 # foreach my $e (@enclosures) {
2118 # print $e->{nexus}, "\n";
2119 # if ($e->{id} == $out->{fanConnectionEnclosureNumber} - 1) {
2120 # $encl_id = $e->{nexus};
2125 $nexus = convert_nexus($out->{fanNexusID});
2129 $name = $out->{'Name'};
2130 $state = $out->{'State'};
2131 $status = $out->{'Status'};
2132 $speed = $out->{'Speed'};
2133 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2134 $encl_name = $out->{encl_name};
2135 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2138 next FAN if blacklisted('encl_fan', $nexus);
2141 if ($status ne 'Ok') {
2142 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2143 $name, $encl_id, $encl_name, $state;
2144 report('storage', $msg, $status2nagios{$status}, $nexus);
2148 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2149 $name, $encl_id, $encl_name, $state, $speed;
2150 report('storage', $msg, $E_OK, $nexus);
2157 #-----------------------------------------
2158 # STORAGE: Check enclosure power supplies
2159 #-----------------------------------------
2160 sub check_enclosure_pwr {
2161 return if $#controllers == -1;
2162 return if blacklisted('encl_ps', 'all');
2169 my $encl_id = undef;
2170 my $encl_name = undef;
2176 '1.3.6.1.4.1.674.10893.1.20.130.9.1.1' => 'powerSupplyNumber',
2177 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2178 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2179 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2180 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2181 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2182 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2185 if ($opt{use_get_table}) {
2186 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2187 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2189 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2190 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2192 if (defined $result) {
2193 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2197 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2200 # No enclosure power supplies is OK
2201 return if !defined $result;
2203 @output = @{ get_snmp_output($result, \%ps_oid) };
2206 foreach my $enc (@enclosures) {
2207 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2208 map_item('ctrl', $enc->{ctrl}, \@output);
2209 map_item('encl_id', $enc->{id}, \@output);
2210 map_item('encl_name', $enc->{name}, \@output);
2219 5 => 'Not Installed',
2225 # Check power supplies on each of the enclosures
2227 foreach my $out (@output) {
2229 $id = $out->{powerSupplyNumber};
2230 $name = $out->{powerSupplyName};
2231 $state = get_hashval($out->{powerSupplyState}, \%ps_state);
2232 $status = $snmp_status{$out->{powerSupplyComponentStatus}};
2233 #$encl_id = $out->{powerSupplyConnectionEnclosureNumber} - 1;
2234 $encl_id = $snmp_enclosure{$out->{powerSupplyConnectionEnclosureNumber}}{nexus};
2235 $encl_name = $out->{powerSupplyConnectionEnclosureName};
2236 $nexus = convert_nexus($out->{powerSupplyNexusID});
2240 $name = $out->{'Name'};
2241 $state = $out->{'State'};
2242 $status = $out->{'Status'};
2243 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2244 $encl_name = $out->{encl_name};
2245 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2248 next PS if blacklisted('encl_ps', $nexus);
2251 if ($status ne 'Ok') {
2252 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2253 $name, $encl_id, $encl_name, $state;
2254 report('storage', $msg, $status2nagios{$status}, $nexus);
2258 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2259 $name, $encl_id, $encl_name, $state;
2260 report('storage', $msg, $E_OK, $nexus);
2267 #-----------------------------------------
2268 # STORAGE: Check enclosure temperatures
2269 #-----------------------------------------
2270 sub check_enclosure_temp {
2271 return if $#controllers == -1;
2272 return if blacklisted('encl_temp', 'all');
2279 my $reading = undef;
2281 my $max_warn = undef;
2282 my $max_crit = undef;
2283 my $min_warn = undef;
2284 my $min_crit = undef;
2285 my $encl_id = undef;
2286 my $encl_name = undef;
2292 '1.3.6.1.4.1.674.10893.1.20.130.11.1.1' => 'temperatureProbeNumber',
2293 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2294 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2295 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2296 '1.3.6.1.4.1.674.10893.1.20.130.11.1.7' => 'temperatureProbeMinWarning',
2297 '1.3.6.1.4.1.674.10893.1.20.130.11.1.8' => 'temperatureProbeMinCritical',
2298 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2299 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2300 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2301 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2302 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2303 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2304 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2307 if ($opt{use_get_table}) {
2308 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2309 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2311 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2312 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2314 if (defined $result) {
2315 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2319 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2322 # No enclosure temperature probes is OK
2323 return if !defined $result;
2325 @output = @{ get_snmp_output($result, \%temp_oid) };
2328 foreach my $enc (@enclosures) {
2329 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2330 map_item('ctrl', $enc->{ctrl}, \@output);
2331 map_item('encl_id', $enc->{id}, \@output);
2332 map_item('encl_name', $enc->{name}, \@output);
2347 # Check temperature probes on each of the enclosures
2349 foreach my $out (@output) {
2351 $id = $out->{temperatureProbeNumber} - 1;
2352 $name = $out->{temperatureProbeName};
2353 $state = get_hashval($out->{temperatureProbeState}, \%temp_state);
2354 $status = $snmp_status{$out->{temperatureProbeComponentStatus}};
2355 $unit = $out->{temperatureProbeUnit};
2356 $reading = exists $out->{temperatureProbeCurValue}
2357 ? $out->{temperatureProbeCurValue} : '[N/A]';
2358 $max_warn = exists $out->{temperatureProbeMaxWarning}
2359 ? $out->{temperatureProbeMaxWarning} : '[N/A]';
2360 $max_crit = exists $out->{temperatureProbeMaxCritical}
2361 ? $out->{temperatureProbeMaxCritical} : '[N/A]';
2362 $min_warn = exists $out->{temperatureProbeMinWarning}
2363 ? $out->{temperatureProbeMinWarning} : '[N/A]';
2364 $min_crit = exists $out->{temperatureProbeMinCritical}
2365 ? $out->{temperatureProbeMinCritical} : '[N/A]';
2366 #$encl_id = $out->{temperatureConnectionEnclosureNumber} - 1;
2367 $encl_id = $snmp_enclosure{$out->{temperatureConnectionEnclosureNumber}}{nexus};
2368 $encl_name = $out->{temperatureConnectionEnclosureName};
2369 $nexus = convert_nexus($out->{temperatureProbeNexusID});
2373 $name = $out->{'Name'};
2374 $state = $out->{'State'};
2375 $status = $out->{'Status'};
2377 $reading = $out->{'Reading'};
2378 $max_warn = $out->{'Maximum Warning Threshold'};
2379 $max_crit = $out->{'Maximum Failure Threshold'};
2380 $min_warn = $out->{'Minimum Warning Threshold'};
2381 $min_crit = $out->{'Minimum Failure Threshold'};
2382 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2383 $encl_name = $out->{encl_name};
2384 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2387 next TEMP if blacklisted('encl_temp', $nexus);
2389 # Make sure these values are integers
2390 $reading =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $reading = '[N/A]';
2391 $max_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_warn = '[N/A]';
2392 $max_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_crit = '[N/A]';
2393 $min_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_warn = '[N/A]';
2394 $min_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_crit = '[N/A]';
2396 # Inactive temp probes
2397 if ($status eq 'Unknown' and $state eq 'Inactive') {
2398 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2399 $name, $encl_id, $encl_name, $state;
2400 report('storage', $msg, $E_OK, $nexus);
2402 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2403 my $msg = sprintf '%s in enclosure %s [%s] is critically high at %d C',
2404 $name, $encl_id, $encl_name, $reading;
2405 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2406 report('chassis', $msg, $err, $nexus);
2408 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2409 my $msg = sprintf '%s in enclosure %s [%s] is too high at %d C',
2410 $name, $encl_id, $encl_name, $reading;
2411 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2412 report('chassis', $msg, $err, $nexus);
2414 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2415 my $msg = sprintf '%s in enclosure %s [%s] is critically low at %d C',
2416 $name, $encl_id, $encl_name, $reading;
2417 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2418 report('chassis', $msg, $err, $nexus);
2420 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2421 my $msg = sprintf '%s in enclosure %s [%s] is too low at %d C',
2422 $name, $encl_id, $encl_name, $reading;
2423 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2424 report('chassis', $msg, $err, $nexus);
2427 elsif ($status ne 'Ok') {
2428 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2429 $name, $encl_id, $encl_name, $state;
2430 if (defined $reading && $reading =~ m{\A -?\d+ \z}xms) {
2431 # take into account that with certain states the
2432 # reading doesn't exist or is not an integer
2433 $msg .= sprintf ' at %s C', $reading;
2434 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2435 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2438 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2439 $min_warn, $min_crit, $max_warn, $max_crit;
2442 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2443 report('storage', $msg, $err, $nexus);
2447 my $msg = sprintf '%s in enclosure %s [%s]',
2448 $name, $encl_id, $encl_name;
2449 if (defined $reading && $reading ne '[N/A]') {
2450 # take into account that with certain states the
2451 # reading doesn't exist or is not an integer
2452 $msg .= sprintf ' reads %d C', $reading;
2453 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2454 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2457 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2458 $min_warn, $min_crit, $max_warn, $max_crit;
2462 $msg .= sprintf ' is %s', $state;
2464 report('storage', $msg, $E_OK, $nexus);
2467 # Collect performance data
2468 if (defined $opt{perfdata} && $reading ne '[N/A]') {
2469 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2470 my $label = "enclosure_${encl_id}_${name}";
2472 $mini =~ s{enclosure_(.+?)_temp_(.+?)}{e$1t$2}xms;
2486 #-----------------------------------------
2487 # STORAGE: Check enclosure management modules (EMM)
2488 #-----------------------------------------
2489 sub check_enclosure_emms {
2490 return if $#controllers == -1;
2491 return if blacklisted('encl_emm', 'all');
2498 my $encl_id = undef;
2499 my $encl_name = undef;
2505 '1.3.6.1.4.1.674.10893.1.20.130.13.1.1' => 'enclosureManagementModuleNumber',
2506 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2507 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2508 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2509 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2510 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2511 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2514 if ($opt{use_get_table}) {
2515 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2516 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2518 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2519 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2521 if (defined $result) {
2522 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2526 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2529 # No enclosure EMMs is OK
2530 return if !defined $result;
2532 @output = @{ get_snmp_output($result, \%emms_oid) };
2535 foreach my $enc (@enclosures) {
2536 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2537 map_item('ctrl', $enc->{ctrl}, \@output);
2538 map_item('encl_id', $enc->{id}, \@output);
2539 map_item('encl_name', $enc->{name}, \@output);
2550 5 => 'Not Installed',
2555 # Check EMMs on each of the enclosures
2557 foreach my $out (@output) {
2559 $id = $out->{enclosureManagementModuleNumber} - 1;
2560 $name = $out->{enclosureManagementModuleName};
2561 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state);
2562 $status = $snmp_status{$out->{enclosureManagementModuleComponentStatus}};
2563 #$encl_id = $out->{enclosureManagementModuleConnectionEnclosureNumber} - 1;
2564 $encl_id = $snmp_enclosure{$out->{enclosureManagementModuleConnectionEnclosureNumber}}{nexus};
2565 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
2566 $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
2570 $name = $out->{'Name'};
2571 $state = $out->{'State'};
2572 $status = $out->{'Status'};
2573 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2574 $encl_name = $out->{encl_name};
2575 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2578 next EMM if blacklisted('encl_emm', $nexus);
2581 if ($status =~ m{\A Other|Unknown \z}xms and $state eq 'Not Installed') {
2582 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2583 $name, $encl_id, $encl_name, $state;
2584 report('storage', $msg, $E_OK, $nexus);
2587 elsif ($status ne 'Ok') {
2588 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2589 $name, $encl_id, $encl_name, $state;
2590 report('storage', $msg, $status2nagios{$status}, $nexus);
2594 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2595 $name, $encl_id, $encl_name, $state;
2596 report('storage', $msg, $E_OK, $nexus);
2603 #-----------------------------------------
2604 # CHASSIS: Check memory modules
2605 #-----------------------------------------
2607 return if blacklisted('dimm', 'all');
2611 my $location = undef;
2620 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2621 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2622 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2623 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2624 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2627 if ($opt{use_get_table}) {
2628 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
2629 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
2632 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2635 if (!defined $result) {
2636 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2637 $snmp_session->close;
2641 @output = @{ get_snmp_output($result, \%dimm_oid) };
2644 @output = @{ run_omreport("$omopt_chassis memory") };
2647 # Note: These values are bit masks, so combination values are
2648 # possible. If value is 0 (zero), memory device has no faults.
2651 1 => 'ECC single bit correction warning rate exceeded',
2652 2 => 'ECC single bit correction failure rate exceeded',
2653 4 => 'ECC multibit fault encountered',
2654 8 => 'ECC single bit correction logging disabled',
2655 16 => 'device disabled because of spare activation',
2659 foreach my $out (@output) {
2660 @failures = (); # Initialize
2662 $index = $out->{memoryDeviceIndex};
2663 $status = $snmp_status{$out->{memoryDeviceStatus}};
2664 $location = $out->{memoryDeviceLocationName};
2665 $size = sprintf '%d MB', $out->{memoryDeviceSize}/1024;
2666 $modes = $out->{memoryDeviceFailureModes};
2668 foreach my $mask (sort keys %failure_mode) {
2669 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2674 $index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
2675 $status = $out->{'Status'};
2676 $location = $out->{'Connector Name'};
2677 $size = $out->{'Size'};
2678 if (defined $size) {
2679 $size =~ s{\s\s}{ }gxms;
2681 # Run 'omreport chassis memory index=X' to get the failures
2682 if ($status ne 'Ok' && defined $index) {
2683 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2684 if (m/\A Failures; (.+?) \z/xms) {
2685 chop(my $fail = $1);
2686 push @failures, split m{\.}xms, $fail;
2691 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2693 # calculate total memory
2694 my $msize = defined $size ? $size : 0;
2695 $msize =~ s{\A (\d+) \s MB}{$1}xms;
2696 $count{mem} += $msize;
2698 next DIMM if blacklisted('dimm', $index);
2700 # Ignore empty memory slots
2701 next DIMM if !defined $index;
2704 if ($status ne 'Ok') {
2706 if (scalar @failures == 0) {
2707 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2708 $index, $location, $size, $status;
2711 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2712 $index, $location, $size, (join q{, }, @failures);
2715 report('chassis', $msg, $status2nagios{$status}, $index);
2719 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2720 $index, $location, $size, $status;
2721 report('chassis', $msg, $E_OK, $index);
2728 #-----------------------------------------
2729 # CHASSIS: Check fans
2730 #-----------------------------------------
2732 return if blacklisted('fan', 'all');
2736 my $reading = undef;
2737 my $location = undef;
2738 my $max_crit = undef;
2739 my $max_warn = undef;
2745 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2746 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2747 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2748 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2749 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2750 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2753 if ($opt{use_get_table}) {
2754 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
2755 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
2758 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2761 if ($blade && !defined $result) {
2764 elsif (!$blade && !defined $result) {
2765 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2766 $snmp_session->close;
2770 @output = @{ get_snmp_output($result, \%cool_oid) };
2773 @output = @{ run_omreport("$omopt_chassis fans") };
2777 foreach my $out (@output) {
2779 $index = $out->{coolingDeviceIndex};
2780 $status = $snmp_probestatus{$out->{coolingDeviceStatus}};
2781 $reading = $out->{coolingDeviceReading};
2782 $location = $out->{coolingDeviceLocationName};
2783 $max_crit = exists $out->{coolingDeviceUpperCriticalThreshold}
2784 ? $out->{coolingDeviceUpperCriticalThreshold} : 0;
2785 $max_warn = exists $out->{coolingDeviceUpperNonCriticalThreshold}
2786 ? $out->{coolingDeviceUpperNonCriticalThreshold} : 0;
2789 $index = $out->{'Index'};
2790 $status = $out->{'Status'};
2791 $reading = $out->{'Reading'};
2792 $location = $out->{'Probe Name'};
2793 $max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
2794 ? $out->{'Maximum Failure Threshold'} : 0;
2795 $max_warn = $out->{'Maximum Warning Threshold'} ne '[N/A]'
2796 ? $out->{'Maximum Warning Threshold'} : 0;
2797 $reading =~ s{\A (\d+).* \z}{$1}xms;
2798 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2799 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2802 next FAN if blacklisted('fan', $index);
2805 if ($status ne 'Ok') {
2806 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2807 $index, $location, $status;
2808 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2809 report('chassis', $msg, $err, $index);
2812 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2813 $index, $location, $reading;
2814 report('chassis', $msg, $E_OK, $index);
2817 # Collect performance data
2818 if (defined $opt{perfdata}) {
2819 my $pname = lc $location;
2820 $pname =~ s{\s}{_}gxms;
2821 $pname =~ s{proc_}{cpu#}xms;
2823 label => "fan_${index}_${pname}",
2835 #-----------------------------------------
2836 # CHASSIS: Check power supplies
2837 #-----------------------------------------
2838 sub check_powersupplies {
2839 return if blacklisted('ps', 'all');
2844 my $err_type = undef;
2852 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2853 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2854 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2855 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2856 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2859 if ($opt{use_get_table}) {
2860 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
2861 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
2864 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2867 # No instrumented PSU is OK (blades, low-end servers)
2868 return 0 if !defined $result;
2870 @output = @{ get_snmp_output($result, \%ps_oid) };
2873 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2883 6 => 'Uninterruptible Power Supply',
2893 1 => 'Presence detected',
2894 2 => 'Failure detected',
2895 4 => 'Predictive Failure',
2897 16 => 'AC lost or out-of-range',
2898 32 => 'AC out-of-range but present',
2899 64 => 'Configuration error',
2902 my %ps_config_error_type
2904 1 => 'Vendor mismatch',
2905 2 => 'Revision mismatch',
2906 3 => 'Processor missing',
2910 foreach my $out (@output) {
2912 @states = (); # contains states for the PS
2914 $index = $out->{powerSupplyIndex} - 1;
2915 $status = $snmp_status{$out->{powerSupplyStatus}};
2916 $type = get_hashval($out->{powerSupplyType}, \%ps_type);
2917 $err_type = defined $out->{powerSupplyConfigurationErrorType}
2918 ? $ps_config_error_type{$out->{powerSupplyConfigurationErrorType}} : undef;
2920 # get the combined state from the StatusReading OID
2921 foreach my $mask (sort keys %ps_state) {
2922 if (($out->{powerSupplySensorState} & $mask) != 0) {
2923 push @states, $ps_state{$mask};
2927 # If configuration error, also include the error type
2928 if (defined $err_type) {
2929 push @states, $err_type;
2932 # Finally, construct the state string
2933 $state = join q{, }, @states;
2936 $index = $out->{'Index'};
2937 $status = $out->{'Status'};
2938 $type = $out->{'Type'};
2939 $state = $out->{'Online Status'};
2942 next PS if blacklisted('ps', $index);
2945 if ($status ne 'Ok') {
2946 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2947 $index, $type, $state;
2948 report('chassis', $msg, $status2nagios{$status}, $index);
2951 my $msg = sprintf 'Power Supply %d [%s]: %s',
2952 $index, $type, $state;
2953 report('chassis', $msg, $E_OK, $index);
2960 #-----------------------------------------
2961 # CHASSIS: Check temperatures
2962 #-----------------------------------------
2963 sub check_temperatures {
2964 return if blacklisted('temp', 'all');
2968 my $reading = undef;
2969 my $location = undef;
2970 my $max_crit = undef;
2971 my $max_warn = undef;
2972 my $min_warn = undef;
2973 my $min_crit = undef;
2975 my $discrete = undef;
2978 # Getting custom temperature thresholds (user option)
2979 my %warn_threshold = %{ custom_temperature_thresholds('w') };
2980 my %crit_threshold = %{ custom_temperature_thresholds('c') };
2985 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
2986 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
2987 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
2988 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
2989 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
2990 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
2991 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
2992 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
2993 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
2994 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
2996 # this didn't work well for some reason
2997 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2999 # Getting values using the table
3000 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
3001 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
3003 if (!defined $result) {
3004 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
3005 $snmp_session->close;
3009 @output = @{ get_snmp_output($result, \%temp_oid) };
3012 @output = @{ run_omreport("$omopt_chassis temps") };
3017 1 => 'Other', # type is other than following values
3018 2 => 'Unknown', # type is unknown
3019 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
3020 16 => 'Discrete', # type is temperature probe with discrete reading
3024 foreach my $out (@output) {
3026 $index = $out->{temperatureProbeIndex} - 1;
3027 $status = $snmp_probestatus{$out->{temperatureProbeStatus}};
3028 $location = $out->{temperatureProbeLocationName};
3029 $reading = exists $out->{temperatureProbeReading}
3030 ? $out->{temperatureProbeReading} / 10 : '[N/A]';
3031 $max_crit = exists $out->{temperatureProbeUpperCriticalThreshold}
3032 ? $out->{temperatureProbeUpperCriticalThreshold} / 10 : '[N/A]';
3033 $max_warn = exists $out->{temperatureProbeUpperNonCriticalThreshold}
3034 ? $out->{temperatureProbeUpperNonCriticalThreshold} / 10 : '[N/A]';
3035 $min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
3036 ? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
3037 $min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
3038 ? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
3039 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
3040 $discrete = exists $out->{temperatureProbeDiscreteReading}
3041 ? $out->{temperatureProbeDiscreteReading} : '[N/A]';
3042 # workaround for bad temp probes
3043 if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
3048 $index = $out->{'Index'};
3049 $status = $out->{'Status'};
3050 $reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
3051 $location = $out->{'Probe Name'};
3052 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
3053 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\.0\s+C}{}xms;
3054 $min_crit = $out->{'Minimum Failure Threshold'}; $min_crit =~ s{\.0\s+C}{}xms;
3055 $min_warn = $out->{'Minimum Warning Threshold'}; $min_warn =~ s{\.0\s+C}{}xms;
3056 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
3057 $discrete = $reading;
3060 next TEMP if blacklisted('temp', $index);
3063 if ($type eq 'Discrete') {
3064 my $msg = sprintf 'Temperature probe %d [%s] is %s',
3065 $index, $location, $discrete;
3066 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3067 report('chassis', $msg, $err, $index);
3070 # First check according to custom thresholds
3071 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
3072 # Custom critical MAX
3073 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3074 $index, $location, $reading, $crit_threshold{$index}{max};
3075 report('chassis', $msg, $E_CRITICAL, $index);
3077 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
3078 # Custom warning MAX
3079 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
3080 $index, $location, $reading, $warn_threshold{$index}{max};
3081 report('chassis', $msg, $E_WARNING, $index);
3083 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
3084 # Custom critical MIN
3085 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3086 $index, $location, $reading, $crit_threshold{$index}{min};
3087 report('chassis', $msg, $E_CRITICAL, $index);
3089 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
3090 # Custom warning MIN
3091 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
3092 $index, $location, $reading, $warn_threshold{$index}{min};
3093 report('chassis', $msg, $E_WARNING, $index);
3095 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
3096 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
3097 $index, $location, $reading;
3098 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3099 report('chassis', $msg, $err, $index);
3101 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
3102 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
3103 $index, $location, $reading;
3104 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3105 report('chassis', $msg, $err, $index);
3107 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
3108 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
3109 $index, $location, $reading;
3110 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3111 report('chassis', $msg, $err, $index);
3113 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
3114 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
3115 $index, $location, $reading;
3116 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3117 report('chassis', $msg, $err, $index);
3121 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
3122 $index, $location, $reading;
3123 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
3124 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
3127 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
3128 $min_warn, $min_crit, $max_warn, $max_crit;
3130 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3131 report('chassis', $msg, $err, $index);
3134 # Collect performance data
3135 if (defined $opt{perfdata}) {
3136 my $pname = lc $location;
3137 $pname =~ s{\s}{_}gxms;
3138 $pname =~ s{_temp\z}{}xms;
3139 $pname =~ s{proc_}{cpu#}xms;
3141 label => "temp_${index}_${pname}",
3154 #-----------------------------------------
3155 # CHASSIS: Check processors
3156 #-----------------------------------------
3157 sub check_processors {
3158 return if blacklisted('cpu', 'all');
3171 # NOTE: For some reason, older models don't have the
3172 # "Processor Device Status" OIDs. We check both the newer
3173 # (preferred) OIDs and the old ones.
3177 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3178 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3179 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3180 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3181 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3182 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3183 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3184 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3185 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3186 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3189 if ($opt{use_get_table}) {
3190 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3191 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3193 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3194 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3196 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3199 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3202 if (!defined $result) {
3203 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3204 $snmp_session->close;
3208 @output = @{ get_snmp_output($result, \%cpu_oid) };
3211 @output = @{ run_omreport("$omopt_chassis processors") };
3216 1 => 'Other', # other than following values
3217 2 => 'Unknown', # unknown
3218 3 => 'Enabled', # enabled
3219 4 => 'User Disabled', # disabled by user via BIOS setup
3220 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3226 1 => 'Internal Error', # Internal Error
3227 2 => 'Thermal Trip', # Thermal Trip
3228 32 => 'Configuration Error', # Configuration Error
3229 128 => 'Present', # Processor Present
3230 256 => 'Disabled', # Processor Disabled
3231 512 => 'Terminator Present', # Terminator Present
3232 1024 => 'Throttled', # Processor Throttled
3235 # Mapping between family numbers from SNMP and actual CPU family
3238 1 => 'Other', 2 => 'Unknown',
3239 3 => '8086', 4 => '80286',
3240 5 => '386', 6 => '486',
3241 7 => '8087', 8 => '80287',
3242 9 => '80387', 10 => '80487',
3243 11 => 'Pentium', 12 => 'Pentium Pro',
3244 13 => 'Pentium II', 14 => 'Pentium with MMX',
3245 15 => 'Celeron', 16 => 'Pentium II Xeon',
3246 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3247 19 => 'Pentium III', 20 => 'Itanium',
3248 21 => 'Xeon', 22 => 'Pentium 4',
3249 23 => 'Xeon MP', 24 => 'Itanium 2',
3250 25 => 'K5', 26 => 'K6',
3251 27 => 'K6-2', 28 => 'K6-3',
3252 29 => 'Athlon', 30 => 'AMD2900',
3253 31 => 'K6-2+', 32 => 'Power PC',
3254 33 => 'Power PC 601', 34 => 'Power PC 603',
3255 35 => 'Power PC 603+', 36 => 'Power PC 604',
3256 37 => 'Power PC 620', 38 => 'Power PC x704',
3257 39 => 'Power PC 750', 40 => 'Core Duo',
3258 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3259 43 => 'Intel Atom', 44 => undef,
3260 45 => undef, 46 => undef,
3261 47 => undef, 48 => 'Alpha',
3262 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3263 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3264 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3265 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3266 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3267 59 => 'Opteron 6100', 60 => 'Opteron 4100',
3268 61 => undef, 62 => undef,
3269 63 => undef, 64 => 'MIPS',
3270 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3271 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3272 69 => 'MIPS R10000', 70 => undef,
3273 71 => undef, 72 => undef,
3274 73 => undef, 74 => undef,
3275 75 => undef, 76 => undef,
3276 77 => undef, 78 => undef,
3277 79 => undef, 80 => 'SPARC',
3278 81 => 'SuperSPARC', 82 => 'microSPARC II',
3279 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3280 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3281 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3282 89 => undef, 90 => undef,
3283 91 => undef, 92 => undef,
3284 93 => undef, 94 => undef,
3285 95 => undef, 96 => '68040',
3286 97 => '68xxx', 98 => '68000',
3287 99 => '68010', 100 => '68020',
3288 101 => '68030', 102 => undef,
3289 103 => undef, 104 => undef,
3290 105 => undef, 106 => undef,
3291 107 => undef, 108 => undef,
3292 109 => undef, 110 => undef,
3293 111 => undef, 112 => 'Hobbit',
3294 113 => undef, 114 => undef,
3295 115 => undef, 116 => undef,
3296 117 => undef, 118 => undef,
3297 119 => undef, 120 => 'Crusoe TM5000',
3298 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3299 123 => undef, 124 => undef,
3300 125 => undef, 126 => undef,
3301 127 => undef, 128 => 'Weitek',
3302 129 => undef, 130 => 'Celeron M',
3303 131 => 'Athlon 64', 132 => 'Opteron',
3304 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3305 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3306 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3307 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3308 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3309 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3310 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3311 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3312 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3313 151 => undef, 152 => undef,
3314 153 => undef, 154 => undef,
3315 155 => undef, 156 => undef,
3316 157 => undef, 158 => undef,
3317 159 => undef, 160 => 'V30',
3318 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3319 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3320 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3321 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3322 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3323 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3324 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3325 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3326 177 => 'M2', 178 => undef,
3327 179 => 'Pentium 4 HT', 180 => 'AS400',
3328 181 => undef, 182 => 'Athlon XP',
3329 183 => 'Athlon MP', 184 => 'Duron',
3330 185 => 'Pentium M', 186 => 'Celeron D',
3331 187 => 'Pentium D', 188 => 'Pentium Extreme',
3332 189 => 'Core Solo', 190 => 'Core2',
3333 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3334 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3335 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3336 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3337 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3338 201 => 'G4', 202 => 'G5',
3339 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3340 205 => 'Core i5', 206 => 'Core i3',
3341 207 => undef, 208 => undef,
3342 209 => undef, 210 => 'C7-M',
3343 211 => 'C7-D', 212 => 'C7',
3344 213 => 'Eden', 214 => 'Multi-Core Xeon',
3345 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3346 217 => 'VIA Nano', 218 => 'Dual-Core Xeon 5xxx',
3347 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3348 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3349 223 => 'Multi-Core Xeon 7xxx', 224 => 'Multi-Core Xeon 3400',
3350 225 => undef, 226 => undef,
3351 227 => undef, 228 => undef,
3352 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3353 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3354 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3355 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3356 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3357 239 => 'AMD Sempron M', 240 => undef,
3358 241 => undef, 242 => undef,
3359 243 => undef, 244 => undef,
3360 245 => undef, 246 => undef,
3361 247 => undef, 248 => undef,
3362 249 => undef, 250 => 'i860',
3367 foreach my $out (@output) {
3369 $index = exists $out->{processorDeviceStatusIndex}
3370 ? $out->{processorDeviceStatusIndex} - 1
3371 : $out->{processorDeviceIndex} - 1;
3372 $status = exists $out->{processorDeviceStatusStatus}
3373 ? $snmp_status{$out->{processorDeviceStatusStatus}}
3374 : $snmp_status{$out->{processorDeviceStatus}};
3375 if (exists $out->{processorDeviceStatusReading}) {
3376 my @states = (); # contains states for the CPU
3378 # get the combined state from the StatusReading OID
3379 foreach my $mask (sort keys %cpu_reading) {
3380 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3381 push @states, $cpu_reading{$mask};
3385 # Finally, create the state string
3386 $state = join q{, }, @states;
3389 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state);
3391 $man = $out->{processorDeviceManufacturerName};
3392 $family = (exists $out->{processorDeviceFamily}
3393 and exists $cpu_family{$out->{processorDeviceFamily}})
3394 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3395 $speed = $out->{processorDeviceCurrentSpeed};
3396 $brand = $out->{processorDeviceBrandName};
3399 $index = $out->{'Index'};
3400 $status = $out->{'Status'};
3401 $state = $out->{'State'};
3402 $brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
3403 $family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
3404 $man = exists $out->{'Processor Manufacturer'} ? $out->{'Processor Manufacturer'} : undef;
3405 $speed = exists $out->{'Current Speed'} ? $out->{'Current Speed'} : undef;
3408 next CPU if blacklisted('cpu', $index);
3410 # Ignore unoccupied CPU slots (omreport)
3411 next CPU if (defined $out->{'Processor Manufacturer'}
3412 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3413 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3415 # Ignore unoccupied CPU slots (snmp)
3416 if ($snmp and exists $out->{processorDeviceStatusReading}
3417 and $out->{processorDeviceStatusReading} == 0) {
3423 if (defined $brand) {
3424 $brand =~ s{\s\s+}{ }gxms;
3425 $brand =~ s{\((R|tm)\)}{}gxms;
3426 $brand =~ s{\s(CPU|Processor)}{}xms;
3427 $brand =~ s{\s\@}{}xms;
3429 elsif (defined $family and defined $man and defined $speed) {
3430 $speed =~ s{\A (\d+) .*}{$1}xms;
3431 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3438 if ($status ne 'Ok') {
3439 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3440 $index, $brand, $state;
3441 report('chassis', $msg, $status2nagios{$status}, $index);
3445 my $msg = sprintf 'Processor %d [%s] is %s',
3446 $index, $brand, $state;
3447 report('chassis', $msg, $E_OK, $index);
3454 #-----------------------------------------
3455 # CHASSIS: Check voltage probes
3456 #-----------------------------------------
3458 return if blacklisted('volt', 'all');
3462 my $reading = undef;
3463 my $location = undef;
3469 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3470 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3471 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3472 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3473 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3476 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3477 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3479 if (!defined $result) {
3480 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3481 $snmp_session->close;
3485 @output = @{ get_snmp_output($result, \%volt_oid) };
3488 @output = @{ run_omreport("$omopt_chassis volts") };
3491 my %volt_discrete_reading
3498 foreach my $out (@output) {
3500 $index = $out->{voltageProbeIndex} - 1;
3501 $status = $snmp_probestatus{$out->{voltageProbeStatus}};
3502 $reading = exists $out->{voltageProbeReading}
3503 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3504 : get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading);
3505 $location = $out->{voltageProbeLocationName};
3508 $index = $out->{'Index'};
3509 $status = $out->{'Status'};
3510 $reading = $out->{'Reading'};
3511 $location = $out->{'Probe Name'};
3514 next VOLT if blacklisted('volt', $index);
3517 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3518 $index, $location, $reading;
3519 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3520 report('chassis', $msg, $err, $index);
3526 #-----------------------------------------
3527 # CHASSIS: Check batteries
3528 #-----------------------------------------
3529 sub check_batteries {
3530 return if blacklisted('bp', 'all');
3534 my $reading = undef;
3535 my $location = undef;
3541 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3542 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3543 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3544 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3547 if ($opt{use_get_table}) {
3548 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3549 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3552 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3555 # No batteries is OK
3556 return 0 if !defined $result;
3558 @output = @{ get_snmp_output($result, \%bat_oid) };
3561 @output = @{ run_omreport("$omopt_chassis batteries") };
3566 1 => 'Predictive Failure',
3568 4 => 'Presence Detected',
3572 foreach my $out (@output) {
3574 $index = $out->{batteryIndex} - 1;
3575 $status = $snmp_status{$out->{batteryStatus}};
3576 $reading = get_hashval($out->{batteryReading}, \%bat_reading);
3577 $location = $out->{batteryLocationName};
3580 $index = $out->{'Index'};
3581 $status = $out->{'Status'};
3582 $reading = $out->{'Reading'};
3583 $location = $out->{'Probe Name'};
3586 next BATTERY if blacklisted('bp', $index);
3589 my $msg = sprintf 'Battery probe %d [%s] is %s',
3590 $index, $location, $reading;
3591 report('chassis', $msg, $status2nagios{$status}, $index);
3597 #-----------------------------------------
3598 # CHASSIS: Check amperage probes (power monitoring)
3599 #-----------------------------------------
3600 sub check_pwrmonitoring {
3601 return if blacklisted('amp', 'all');
3605 my $reading = undef;
3606 my $location = undef;
3607 my $max_crit = undef;
3608 my $max_warn = undef;
3616 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3617 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3618 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3619 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3620 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3621 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3622 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3623 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3626 if ($opt{use_get_table}) {
3627 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
3628 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
3631 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3634 # No pwrmonitoring is OK
3635 return 0 if !defined $result;
3637 @output = @{ get_snmp_output($result, \%amp_oid) };
3640 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3643 my %amp_type # Amperage probe types
3645 1 => 'amperageProbeTypeIsOther', # other than following values
3646 2 => 'amperageProbeTypeIsUnknown', # unknown
3647 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3648 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3649 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3650 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3651 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3652 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3653 9 => 'amperageProbeTypeIsIO', # I/O probe
3654 10 => 'amperageProbeTypeIsCore', # Core probe
3655 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3656 12 => 'amperageProbeTypeIsBattery', # Battery probe
3657 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3658 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3659 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3660 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3661 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3662 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3663 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3664 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3675 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3676 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3677 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3678 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3679 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3683 foreach my $out (@output) {
3685 $index = $out->{amperageProbeIndex} - 1;
3686 $status = $snmp_status{$out->{amperageProbeStatus}};
3687 $type = get_hashval($out->{amperageProbeType}, \%amp_type);
3688 $reading = $type eq 'amperageProbeTypeIsDiscrete'
3689 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
3690 : $out->{amperageProbeReading};
3691 $location = $out->{amperageProbeLocationName};
3692 $max_crit = exists $out->{amperageProbeUpperCriticalThreshold}
3693 ? $out->{amperageProbeUpperCriticalThreshold} : 0;
3694 $max_warn = exists $out->{amperageProbeUpperNonCriticalThreshold}
3695 ? $out->{amperageProbeUpperNonCriticalThreshold} : 0;
3696 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3697 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3699 # workaround for broken probes
3700 if (!defined $reading) {
3701 $type = 'amperageProbeTypeIsDiscrete';
3706 # calculate proper values and set unit for ampere probes
3707 if ($unit eq 'hA' and $type ne 'amperageProbeTypeIsDiscrete') {
3715 $index = $out->{'Index'};
3716 next AMP if (!defined $index || $index !~ m/^\d+$/x);
3717 $status = $out->{'Status'};
3718 $reading = $out->{'Reading'};
3719 $location = $out->{'Probe Name'};
3720 $max_crit = $out->{'Failure Threshold'} ne '[N/A]'
3721 ? $out->{'Failure Threshold'} : 0;
3722 $max_warn = $out->{'Warning Threshold'} ne '[N/A]'
3723 ? $out->{'Warning Threshold'} : 0;
3724 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3726 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3727 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3730 next AMP if blacklisted('amp', $index);
3731 next AMP if $index !~ m{\A \d+ \z}xms;
3734 if (defined $type and $type eq 'amperageProbeTypeIsDiscrete') {
3735 my $msg = sprintf 'Amperage probe %d [%s] is %s',
3736 $index, $location, $reading;
3737 report('chassis', $msg, $status2nagios{$status}, $index);
3740 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3741 $index, $location, $reading, $unit;
3742 report('chassis', $msg, $status2nagios{$status}, $index);
3745 # Collect performance data
3746 if (defined $opt{perfdata}) {
3747 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3748 #next AMP if $type eq 'amperageProbeTypeIsDiscrete';
3749 my $label = join q{_}, 'pwr_mon', $index, lc $location;
3750 $label =~ s{\s}{_}gxms;
3753 mini => "p${index}" . lc $unit,
3761 # Collect EXTRA performance data not found at first run. This is a
3763 if (defined $opt{perfdata} && !$snmp) {
3769 foreach (@perfdata) {
3770 if ($_->{label} =~ m/\A pwr_mon_(\d+)/xms) {
3776 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3778 if ($line eq 'Location;Reading') {
3786 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s [AW] \z/xms) {
3789 $aname =~ s{\s}{_}gxms;
3791 # don't use an existing index
3792 while (exists $used{$index}) { ++$index; }
3795 label => "pwr_mon_${index}_${aname}",
3796 mini => "p${index}a",
3810 #-----------------------------------------
3811 # CHASSIS: Check intrusion
3812 #-----------------------------------------
3813 sub check_intrusion {
3814 return if blacklisted('intr', 'all');
3818 my $reading = undef;
3824 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3825 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3826 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3829 if ($opt{use_get_table}) {
3830 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
3831 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
3834 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3837 # No intrusion is OK
3838 return 0 if !defined $result;
3840 @output = @{ get_snmp_output($result, \%int_oid) };
3843 @output = @{ run_omreport("$omopt_chassis intrusion") };
3848 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3849 2 => 'Breached', # chassis currently breached
3850 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3851 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3855 foreach my $out (@output) {
3857 $index = $out->{intrusionIndex} - 1;
3858 $status = $snmp_status{$out->{intrusionStatus}};
3859 $reading = get_hashval($out->{intrusionReading}, \%int_reading);
3862 $index = $out->{'Index'};
3863 $status = $out->{'Status'};
3864 $reading = $out->{'State'};
3867 next INTRUSION if blacklisted('intr', $index);
3870 if ($status ne 'Ok') {
3871 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3873 report('chassis', $msg, $E_WARNING, $index);
3877 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3878 $index, $status, $reading;
3879 report('chassis', $msg, $E_OK, $index);
3886 #-----------------------------------------
3887 # CHASSIS: Check alert log
3888 #-----------------------------------------
3889 sub check_alertlog {
3890 return if $snmp; # Not supported with SNMP
3892 my @output = @{ run_omreport("$omopt_system alertlog") };
3893 foreach my $out (@output) {
3894 ++$count{alert}{$out->{Severity}};
3897 # Create error messages and set exit value if appropriate
3899 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
3900 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3902 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
3903 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
3904 report('other', $msg, $err);
3909 #-----------------------------------------
3910 # CHASSIS: Check ESM log overall health
3911 #-----------------------------------------
3912 sub check_esmlog_health {
3916 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
3917 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
3918 if (!defined $result) {
3919 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
3920 $snmp_session->error;
3921 report('other', $msg, $E_UNKNOWN);
3923 $health = $snmp_status{$result->{$systemStateEventLogStatus}};
3926 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
3927 if (m/\A Health;(.+) \z/xms) {
3935 # If the overall health of the ESM log is other than "Ok", the
3936 # fill grade of the log is more than 80% and the log should be
3938 if ($health eq 'Ok') {
3939 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
3940 report('other', $msg, $E_OK);
3942 elsif ($health eq 'Critical') {
3943 my $msg = sprintf 'ESM log is 100%% full';
3944 report('other', $msg, $status2nagios{$health});
3947 my $msg = sprintf 'ESM log is more than 80%% full';
3948 report('other', $msg, $status2nagios{$health});
3954 #-----------------------------------------
3955 # CHASSIS: Check ESM log
3956 #-----------------------------------------
3963 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
3965 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
3968 return if !defined $result;
3970 @output = @{ get_snmp_output($result, \%esm_oid) };
3971 foreach my $out (@output) {
3972 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
3976 @output = @{ run_omreport("$omopt_system esmlog") };
3977 foreach my $out (@output) {
3978 ++$count{esm}{$out->{Severity}};
3982 # Create error messages and set exit value if appropriate
3984 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
3985 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3987 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
3988 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
3989 report('other', $msg, $err);
3995 # Handy function for checking all storage components
3998 check_controllers();
3999 check_physical_disks();
4000 check_virtual_disks();
4001 check_cache_battery();
4004 check_enclosure_fans();
4005 check_enclosure_pwr();
4006 check_enclosure_temp();
4007 check_enclosure_emms();
4013 #---------------------------------------------------------------------
4015 #---------------------------------------------------------------------
4018 # Fetch output from 'omreport chassis info', put in sysinfo hash
4020 sub get_omreport_chassis_info {
4021 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
4022 my @lines = <$INFO>;
4025 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag)/xms;
4026 my ($key, $val) = split /;/xms;
4027 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4028 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4029 if ($key eq 'Chassis Model' or $key eq 'Model') {
4030 $sysinfo{model} = $val;
4032 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
4033 $sysinfo{serial} = $val;
4041 # Fetch output from 'omreport chassis bios', put in sysinfo hash
4043 sub get_omreport_chassis_bios {
4044 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
4045 my @lines = <$BIOS>;
4049 my ($key, $val) = split /;/xms;
4050 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4051 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4052 $sysinfo{bios} = $val if $key eq 'Version';
4053 $sysinfo{biosdate} = $val if $key eq 'Release Date';
4060 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
4062 sub get_omreport_system_operatingsystem {
4063 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
4068 my ($key, $val) = split /;/xms;
4069 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4070 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4071 if ($key eq 'Operating System') {
4072 $sysinfo{osname} = $val;
4074 elsif ($key eq 'Operating System Version') {
4075 $sysinfo{osver} = $val;
4083 # Fetch output from 'omreport about', put in sysinfo hash
4085 sub get_omreport_about {
4086 if (open my $OM, '-|', "$omreport about -fmt ssv") {
4090 if (m/\A Version;(.+) \z/xms) {
4100 # Fetch chassis info via SNMP, put in sysinfo hash
4102 sub get_snmp_chassis_info {
4105 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
4106 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
4109 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
4110 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
4112 if (defined $result) {
4113 foreach my $oid (keys %{ $result }) {
4114 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
4115 $sysinfo{model} = $result->{$oid};
4116 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
4118 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
4119 $sysinfo{serial} = $result->{$oid};
4124 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
4125 $snmp_session->error;
4126 report('other', $msg, $E_UNKNOWN);
4132 # Fetch BIOS info via SNMP, put in sysinfo hash
4134 sub get_snmp_chassis_bios {
4137 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
4138 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
4141 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
4142 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
4144 if (defined $result) {
4145 foreach my $oid (keys %{ $result }) {
4146 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
4147 $sysinfo{biosdate} = $result->{$oid};
4148 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
4150 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
4151 $sysinfo{bios} = $result->{$oid};
4156 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
4157 $snmp_session->error;
4158 report('other', $msg, $E_UNKNOWN);
4164 # Fetch OS info via SNMP, put in sysinfo hash
4166 sub get_snmp_system_operatingsystem {
4169 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
4170 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
4173 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
4174 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
4176 if (defined $result) {
4177 foreach my $oid (keys %{ $result }) {
4178 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
4179 $sysinfo{osname} = ($result->{$oid});
4181 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
4182 $sysinfo{osver} = $result->{$oid};
4187 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
4188 $snmp_session->error;
4189 report('other', $msg, $E_UNKNOWN);
4195 # Fetch OMSA version via SNMP, put in sysinfo hash
4197 sub get_snmp_about {
4198 # systemManagementSoftwareGlobalVersionName
4199 my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
4200 my $result = $snmp_session->get_request(-varbindlist => [$oid]);
4202 if (defined $result) {
4203 $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
4204 ? $result->{$oid} : 'unknown';
4207 my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
4208 report('other', $msg, $E_UNKNOWN);
4214 # Collects some information about the system
4218 # Get system model and serial number
4219 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4221 # Get BIOS information. Only if needed
4222 if ( $opt{okinfo} >= 1
4224 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4225 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4228 # Get OMSA information. Only if needed
4229 if ($opt{okinfo} >= 3 or $opt{debug}) {
4230 $snmp ? get_snmp_about() : get_omreport_about();
4233 # Return now if debug
4234 return if $opt{debug};
4236 # Get OS information. Only if needed
4237 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4238 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4245 # Helper function for running omreport when the results are strictly
4247 sub run_omreport_info {
4248 my $command = shift;
4252 # Run omreport and fetch output
4253 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4255 # Parse output, store in array
4256 for ((split /\n/xms, $rawtext)) {
4257 if (m/\A Error/xms) {
4258 my $msg = "Problem running 'omreport $command': $_";
4259 report('other', $msg, $E_UNKNOWN);
4261 next if !m/;/xms; # ignore lines with less than two fields
4262 my @vals = split m/;/xms;
4263 $output{$vals[0]} = $vals[1];
4266 # Finally, return the collected information
4270 # Get various firmware information (BMC, RAC)
4271 sub get_firmware_info {
4272 my @snmp_output = ();
4273 my %nrpe_output = ();
4278 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4279 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4280 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4283 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4284 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4286 # Some don't have this OID, this is ok
4287 if (!defined $result) {
4291 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4294 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4297 my %fw_type # Firmware types
4299 1 => 'other', # other than following values
4300 2 => 'unknown', # unknown
4301 3 => 'systemBIOS', # System BIOS
4302 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4303 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4304 6 => 'systemBackPlane', # System (Primary) Backplane
4305 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4306 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4307 9 => 'frontPanel', # Front Panel Controller
4308 10 => 'baseboardManagementController', # Baseboard Management Controller
4309 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4310 12 => 'sensorData', # Sensor Data Records
4311 13 => 'peripheralBay', # Peripheral Bay Backplane
4312 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4313 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4314 16 => 'rac', # Remote Access Controller
4315 17 => 'imc' # Integrated Management Controller
4320 foreach my $out (@snmp_output) {
4321 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4322 $sysinfo{'bmc'} = 1;
4323 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4325 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|imc \z}xms) {
4326 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4327 $sysinfo{'rac'} = 1;
4328 $sysinfo{'rac_name'} = $name;
4329 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4334 foreach my $key (keys %nrpe_output) {
4335 next if !defined $nrpe_output{$key};
4336 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4337 $sysinfo{'bmc'} = 1;
4338 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4340 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4342 $sysinfo{'rac'} = 1;
4343 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4344 $sysinfo{'rac_name'} = $name;
4354 #=====================================================================
4356 #=====================================================================
4358 # Here we do the actual checking of components
4359 # Check global status if applicable
4361 $globalstatus = check_global();
4364 # Do multiple selected checks
4365 if ($check{storage}) { check_storage(); }
4366 if ($check{memory}) { check_memory(); }
4367 if ($check{fans}) { check_fans(); }
4368 if ($check{power}) { check_powersupplies(); }
4369 if ($check{temp}) { check_temperatures(); }
4370 if ($check{cpu}) { check_processors(); }
4371 if ($check{voltage}) { check_volts(); }
4372 if ($check{batteries}) { check_batteries(); }
4373 if ($check{amperage}) { check_pwrmonitoring(); }
4374 if ($check{intrusion}) { check_intrusion(); }
4375 if ($check{alertlog}) { check_alertlog(); }
4376 if ($check{esmlog}) { check_esmlog(); }
4377 if ($check{esmhealth}) { check_esmlog_health(); }
4380 #---------------------------------------------------------------------
4382 #---------------------------------------------------------------------
4393 # Get system information
4396 # Get firmware info if requested via option
4397 if ($opt{okinfo} >= 1) {
4398 get_firmware_info();
4401 # Close SNMP session
4403 $snmp_session->close;
4408 print " System: $sysinfo{model}\n";
4409 print " ServiceTag: $sysinfo{serial}";
4410 print q{ } x (25 - length $sysinfo{serial}), "OMSA version: $sysinfo{om}\n";
4411 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4412 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Plugin version: $VERSION\n";
4413 if ($#report_storage >= 0) {
4414 print "-----------------------------------------------------------------------------\n";
4415 print " Storage Components \n";
4416 print "=============================================================================\n";
4417 print " STATE | ID | MESSAGE TEXT \n";
4418 print "---------+----------+--------------------------------------------------------\n";
4419 foreach (@report_storage) {
4420 my ($msg, $level, $nexus) = @{$_};
4421 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4422 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4423 $nagios_alert_count{$reverse_exitcode{$level}}++;
4426 if ($#report_chassis >= 0) {
4427 print "-----------------------------------------------------------------------------\n";
4428 print " Chassis Components \n";
4429 print "=============================================================================\n";
4430 print " STATE | ID | MESSAGE TEXT \n";
4431 print "---------+------+------------------------------------------------------------\n";
4432 foreach (@report_chassis) {
4433 my ($msg, $level, $nexus) = @{$_};
4434 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4435 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
4436 $nagios_alert_count{$reverse_exitcode{$level}}++;
4439 if ($#report_other >= 0) {
4440 print "-----------------------------------------------------------------------------\n";
4441 print " Other messages \n";
4442 print "=============================================================================\n";
4443 print " STATE | MESSAGE TEXT \n";
4444 print "---------+-------------------------------------------------------------------\n";
4445 foreach (@report_other) {
4446 my ($msg, $level, $nexus) = @{$_};
4447 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
4448 $nagios_alert_count{$reverse_exitcode{$level}}++;
4453 my $c = 0; # counter to determine linebreaks
4455 # Run through each message, sorted by severity level
4457 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
4458 my ($msg, $level, $nexus) = @{ $_ };
4459 next ALERT if $level == $E_OK;
4461 if (defined $opt{only}) {
4462 # If user wants only critical alerts
4463 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
4465 # If user wants only warning alerts
4466 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
4469 # Prefix with service tag if specified with option '-i|--info'
4471 if (defined $opt{htmlinfo}) {
4472 $msg = '[<a href="' . warranty_url($sysinfo{serial})
4473 . "\">$sysinfo{serial}</a>] " . $msg;
4476 $msg = "[$sysinfo{serial}] " . $msg;
4480 # Prefix with nagios level if specified with option '--state'
4481 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
4483 # Prefix with one-letter nagios level if specified with option '--short-state'
4484 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
4486 ($c++ == 0) ? print $msg : print $linebreak, $msg;
4488 $nagios_alert_count{$reverse_exitcode{$level}}++;
4492 # Determine our exit code
4494 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
4495 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
4496 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
4498 # Global status via SNMP.. extra safety check
4499 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
4500 print "OOPS! Something is wrong with this server, but I don't know what. ";
4501 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
4502 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
4503 print "please file a bug report.\n";
4508 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
4510 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
4511 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
4512 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
4513 'memory' => "MEMORY OK - $count{dimm} memory modules, $count{mem} MB total memory",
4514 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
4515 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
4516 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
4517 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
4518 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
4519 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
4520 '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",
4521 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
4522 'esmhealth' => "ESM LOG OK - less than 80% used",
4525 print $okmsg{$opt{only}};
4527 elsif ($exit_code == $E_OK && !$opt{debug}) {
4528 if (defined $opt{htmlinfo}) {
4529 printf q{OK - System: '<a href="%s">%s</a>', SN: '<a href="%s">%s</a>'},
4530 documentation_url($sysinfo{model}), $sysinfo{model},
4531 warranty_url($sysinfo{serial}), $sysinfo{serial};
4534 printf q{OK - System: '%s', SN: '%s'},
4535 $sysinfo{model}, $sysinfo{serial};
4538 if ($check{memory}) {
4540 if ($count{mem} >= 1024) {
4541 $count{mem} /= 1024;
4544 printf ', %d %s ram (%d dimms)', $count{mem}, $unit, $count{dimm};
4547 print ', not checking memory';
4550 if ($check{storage}) {
4551 printf ', %d logical drives, %d physical drives',
4552 $count{vdisk}, $count{pdisk};
4555 print ', not checking storage';
4558 if ($opt{okinfo} >= 1) {
4560 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4562 if ($sysinfo{rac}) {
4563 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4565 if ($sysinfo{bmc}) {
4566 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4570 if ($opt{okinfo} >= 2) {
4571 if ($check{storage}) {
4572 my @storageprint = ();
4573 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4574 chomp $sysinfo{controller}{$id}{driver};
4575 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
4576 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4577 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4578 if (defined $sysinfo{controller}{$id}{storport}) {
4579 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
4581 push @storageprint, $msg;
4583 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4584 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
4585 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4586 $sysinfo{enclosure}{$id}->{firmware};
4590 foreach my $line (@storageprint) {
4591 print $linebreak, $line;
4596 if ($opt{okinfo} >= 3) {
4597 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4602 if ($opt{extinfo}) {
4604 if (defined $opt{htmlinfo}) {
4605 printf '------ SYSTEM: <a href="%s">%s</a>, SN: <a href="%s">%s</a>',
4606 documentation_url($sysinfo{model}), $sysinfo{model},
4607 warranty_url($sysinfo{serial}), $sysinfo{serial};
4610 printf '------ SYSTEM: %s, SN: %s',
4611 $sysinfo{model}, $sysinfo{serial};
4614 if (defined $opt{postmsg}) {
4616 if (-f $opt{postmsg}) {
4617 open my $POST, '<', $opt{postmsg}
4618 or ( print $linebreak
4619 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4620 and exit $E_UNKNOWN );
4626 $post = $opt{postmsg};
4628 if (defined $post) {
4630 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4631 $post =~ s{[%]m}{$sysinfo{model}}gxms;
4632 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4633 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4634 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4635 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4636 $post =~ s{[%]p}{$count{pdisk}}gxms;
4637 $post =~ s{[%]l}{$count{vdisk}}gxms;
4638 $post =~ s{[%]n}{$linebreak}gxms;
4639 $post =~ s{[%]{2}}{%}gxms;
4645 # Reset the WARN signal
4646 $SIG{__WARN__} = 'DEFAULT';
4648 # Print any perl warnings that have occured
4649 if (@perl_warnings) {
4650 foreach (@perl_warnings) {
4652 print "${linebreak}INTERNAL ERROR: @$_";
4654 $exit_code = $E_UNKNOWN;
4657 # Print performance data
4658 if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
4659 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4662 # Sort routine for performance data
4664 my %order = ( fan => 0, pwr => 1, tem => 2, enc => 3, );
4665 return ($order{(substr $a->{label}, 0, 3)} cmp $order{(substr $b->{label}, 0, 3)}) ||
4666 $a->{label} cmp $b->{label};
4669 # Print performance data sorted
4670 my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
4671 print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
4674 # Print a linebreak at the end
4675 print "\n" if !$opt{debug};
4677 # Exit with proper exit code