5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2008-2011 Trond H. Amundsen
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 # General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 require 5.006; # Perl v5.6.0 or newer is required
29 use POSIX qw(isatty ceil);
30 use Getopt::Long qw(:config no_ignore_case);
32 # Global (package) variables used throughout the code
33 use vars qw( $NAME $VERSION $AUTHOR $CONTACT $E_OK $E_WARNING $E_CRITICAL
34 $E_UNKNOWN $FW_LOCK $USAGE $HELP $LICENSE
35 $snmp_session $snmp_error $omreport $globalstatus $global
36 $linebreak $omopt_chassis $omopt_system $blade
38 %check %opt %reverse_exitcode %status2nagios
39 %snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
40 %blacklist %nagios_alert_count %count %snmp_enclosure %snmp_controller
41 @perl_warnings @controllers @enclosures @perfdata
42 @report_storage @report_chassis @report_other
45 #---------------------------------------------------------------------
46 # Initialization and global variables
47 #---------------------------------------------------------------------
49 # Collect perl warnings in an array
50 $SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
52 # Version and similar info
53 $NAME = 'check_openmanage';
54 $VERSION = '3.7.0-beta8';
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 -f, --configfile Configuration file
78 -p, --perfdata Output performance data [default=no]
79 -t, --timeout Plugin timeout in seconds [default=30]
80 -c, --critical Custom temperature critical limits
81 -w, --warning Custom temperature warning limits
82 -F, --fahrenheit Use Fahrenheit for temperature [default=no]
83 -d, --debug Debug output, reports everything
84 -h, --help Display this help text
85 -V, --version Display version info
89 -H, --hostname Hostname or IP (required for SNMP)
90 -C, --community SNMP community string [default=public]
91 -P, --protocol SNMP protocol version [default=2]
92 --port SNMP port number [default=161]
93 -6, --ipv6 Use IPv6 instead of IPv4 [default=no]
94 --tcp Use TCP instead of UDP [default=no]
98 -i, --info Prefix any alerts with the service tag
99 -e, --extinfo Append system info to alerts
100 -s, --state Prefix alerts with alert state
101 -S, --short-state Prefix alerts with alert state abbreviated
102 -o, --okinfo Verbosity when check result is OK
103 -B, --show-blacklist Show blacklistings in OK output
104 -I, --htmlinfo HTML output with clickable links
106 CHECK CONTROL AND BLACKLISTING:
108 -a, --all Check everything, even log content
109 -b, --blacklist Blacklist missing and/or failed components
110 --only Only check a certain component or alert type
111 --check Fine-tune which components are checked
112 --no-storage Don't check storage
114 For more information and advanced options, see the manual page or URL:
115 http://folk.uio.no/trondham/software/check_openmanage.html
118 # Version and license text
119 $LICENSE = <<"END_LICENSE";
121 Copyright (C) 2008-2011 $AUTHOR
122 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
123 This is free software: you are free to change and redistribute it.
124 There is NO WARRANTY, to the extent permitted by law.
126 Written by $AUTHOR <$CONTACT>
129 # Options with default values
130 %opt = ( 'blacklist' => [], # blacklisting
131 'check' => [], # check control
132 'critical' => [], # temperature critical limits
133 'warning' => [], # temperature warning limits
134 'tempunit' => 'C', # temperature unit
135 'fahrenheit' => 0, # Use fahrenheit
136 'configfile' => undef, # configuration file
137 'timeout' => 30, # default timeout is 30 seconds
138 'debug' => 0, # debugging / verbose output
139 'help' => 0, # display help output
140 'perfdata' => undef, # output performance data
141 'info' => 0, # display servicetag
142 'extinfo' => 0, # display extra info
143 'htmlinfo' => undef, # html tags in output
144 'postmsg' => undef, # post message
145 'state' => 0, # display alert type
146 'short-state' => 0, # display alert type (short)
147 'okinfo' => 0, # default "ok" output level
148 'show_blacklist' => 0, # show blacklisted components
149 'linebreak' => undef, # specify linebreak
150 'version' => 0, # plugin version info
151 'all' => 0, # check everything
152 'only' => undef, # only one component
153 'no_storage' => 0, # don't check storage
154 'omreport' => undef, # omreport path
155 'port' => 161, # default SNMP port
156 'hostname' => undef, # hostname or IP
157 'community' => 'public', # SMNP v1 or v2c
158 'protocol' => 2, # default SNMP protocol 2c
159 'ipv6' => 0, # default is IPv4
160 'tcp' => 0, # default is UDP
161 'username' => undef, # SMNP v3
162 'authpassword' => undef, # SMNP v3
163 'authkey' => undef, # SMNP v3
164 'authprotocol' => undef, # SMNP v3
165 'privpassword' => undef, # SMNP v3
166 'privkey' => undef, # SMNP v3
167 'privprotocol' => undef, # SMNP v3
168 'use_get_table' => 0, # hack for SNMPv3 on Windows with net-snmp
172 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
173 'check=s' => \@{ $opt{check} },
174 'c|critical=s' => \@{ $opt{critical} },
175 'w|warning=s' => \@{ $opt{warning} },
176 'tempunit=s' => \$opt{tempunit},
177 'F|fahrenheit' => \$opt{fahrenheit},
178 'f|configfile=s' => \$opt{configfile},
179 't|timeout=i' => \$opt{timeout},
180 'd|debug' => \$opt{debug},
181 'h|help' => \$opt{help},
182 'V|version' => \$opt{version},
183 'p|perfdata:s' => \$opt{perfdata},
184 'i|info' => \$opt{info},
185 'e|extinfo' => \$opt{extinfo},
186 'I|htmlinfo:s' => \$opt{htmlinfo},
187 'postmsg=s' => \$opt{postmsg},
188 's|state' => \$opt{state},
189 'S|short-state' => \$opt{shortstate},
190 'o|ok-info=i' => \$opt{okinfo},
191 'B|show-blacklist' => \$opt{show_blacklist},
192 'linebreak=s' => \$opt{linebreak},
193 'a|all' => \$opt{all},
194 'only=s' => \$opt{only},
195 'no-storage' => \$opt{no_storage},
196 'omreport=s' => \$opt{omreport},
197 'port=i' => \$opt{port},
198 'H|hostname=s' => \$opt{hostname},
199 'C|community=s' => \$opt{community},
200 'P|protocol=i' => \$opt{protocol},
201 '6|ipv6' => \$opt{ipv6},
203 'U|username=s' => \$opt{username},
204 'authpassword=s' => \$opt{authpassword},
205 'authkey=s' => \$opt{authkey},
206 'authprotocol=s' => \$opt{authprotocol},
207 'privpassword=s' => \$opt{privpassword},
208 'privkey=s' => \$opt{privkey},
209 'privprotocol=s' => \$opt{privprotocol},
210 'use-get_table' => \$opt{use_get_table},
211 ) or do { print $USAGE; exit $E_UNKNOWN };
213 # If user requested help
219 # If user requested version info
225 # Initialize blacklist
228 # Check flags, override available with the --check option
229 %check = ( 'storage' => 1, # check storage subsystem
230 'memory' => 1, # check memory (dimms)
231 'fans' => 1, # check fan status
232 'power' => 1, # check power supplies
233 'temp' => 1, # check temperature
234 'cpu' => 1, # check processors
235 'voltage' => 1, # check voltage
236 'batteries' => 1, # check battery probes
237 'amperage' => 1, # check power consumption
238 'intrusion' => 1, # check intrusion detection
239 'sdcard' => 1, # check removable flash media (SD cards)
240 'alertlog' => 0, # check the alert log
241 'esmlog' => 0, # check the ESM log (hardware log)
242 'esmhealth' => 1, # check the ESM log overall health
246 @report_storage = (); # messages with associated nagios level (storage)
247 @report_chassis = (); # messages with associated nagios level (chassis)
248 @report_other = (); # messages with associated nagios level (other)
251 parse_configfile() if defined $opt{configfile};
255 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
260 # If we're using SNMP
261 $snmp = defined $opt{hostname} ? 1 : 0;
263 # SNMP session variables
264 $snmp_session = undef;
267 # The omreport command
271 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
273 # Line break from option
274 if (defined $opt{linebreak}) {
275 if ($opt{linebreak} eq 'REG') {
278 elsif ($opt{linebreak} eq 'HTML') {
279 $linebreak = '<br/>';
282 $linebreak = $opt{linebreak};
286 # Exit with status=UNKNOWN if there is firmware upgrade in progress
287 if (!$snmp && -f $FW_LOCK) {
288 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
292 # List of controllers and enclosures
293 @controllers = (); # controllers
294 @enclosures = (); # enclosures
295 %snmp_enclosure = (); # enclosures
297 # Counters for everything
300 'pdisk' => 0, # number of physical disks
301 'vdisk' => 0, # number of logical drives (virtual disks)
302 'temp' => 0, # number of temperature probes
303 'volt' => 0, # number of voltage probes
304 'amp' => 0, # number of amperage probes
305 'intr' => 0, # number of intrusion probes
306 'dimm' => 0, # number of memory modules
307 'mem' => 0, # total memory
308 'fan' => 0, # number of fan probes
309 'cpu' => 0, # number of CPUs
310 'bat' => 0, # number of batteries
311 'power' => 0, # number of power supplies
312 'sd' => 0, # number of SD cards
314 'Critical' => 0, # critical entries in ESM log
315 'Non-Critical' => 0, # warning entries in ESM log
316 'Ok' => 0, # ok entries in ESM log
319 'Critical' => 0, # critical entries in alert log
320 'Non-Critical' => 0, # warning entries in alert log
321 'Ok' => 0, # ok entries in alert log
328 # Global health status
329 $global = 1; # default is to check global status
330 $globalstatus = $E_OK; # default global health status is "OK"
332 # Nagios error levels reversed
336 $E_WARNING => 'WARNING',
337 $E_CRITICAL => 'CRITICAL',
338 $E_UNKNOWN => 'UNKNOWN',
341 # OpenManage (omreport) and SNMP error levels
344 'Unknown' => $E_CRITICAL,
345 'Critical' => $E_CRITICAL,
346 'Non-Critical' => $E_WARNING,
348 'Non-Recoverable' => $E_CRITICAL,
349 'Other' => $E_CRITICAL,
360 6 => 'Non-Recoverable',
363 # Probe Status via SNMP
366 1 => 'Other', # probe status is not one of the following:
367 2 => 'Unknown', # probe status is unknown (not known or monitored)
368 3 => 'Ok', # probe is reporting a value within the thresholds
369 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
370 5 => 'criticalUpper', # probe has crossed upper critical threshold
371 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
372 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
373 8 => 'criticalLower', # probe has crossed lower critical threshold
374 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
375 10 => 'failed', # probe is not functional
378 # Probe status translated to Nagios alarm levels
381 'Other' => $E_CRITICAL,
382 'Unknown' => $E_CRITICAL,
384 'nonCriticalUpper' => $E_WARNING,
385 'criticalUpper' => $E_CRITICAL,
386 'nonRecoverableUpper' => $E_CRITICAL,
387 'nonCriticalLower' => $E_WARNING,
388 'criticalLower' => $E_CRITICAL,
389 'nonRecoverableLower' => $E_CRITICAL,
390 'failed' => $E_CRITICAL,
393 # System information gathered
396 'bios' => 'N/A', # BIOS version
397 'biosdate' => 'N/A', # BIOS release date
398 'serial' => 'N/A', # serial number (service tag)
399 'model' => 'N/A', # system model
400 'rev' => q{}, # system revision
401 'osname' => 'N/A', # OS name
402 'osver' => 'N/A', # OS version
403 'om' => 'N/A', # OMSA version
404 'bmc' => 0, # HAS baseboard management controller (BMC)
405 'rac' => 0, # HAS remote access controller (RAC)
406 'rac_name' => 'N/A', # remote access controller (RAC)
407 'bmc_fw' => 'N/A', # BMC firmware
408 'rac_fw' => 'N/A', # RAC firmware
411 # Adjust which checks to perform
412 adjust_checks() if defined $opt{check};
414 # Blacklisted components
415 set_blacklist($opt{blacklist}) if defined $opt{blacklist};
417 # If blacklisting is in effect, don't check global health status
418 if (scalar keys %blacklist > 0) {
422 # Take into account new hardware and blades
423 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
424 $omopt_system = 'system'; # default "system" option to omreport
425 $blade = 0; # if this is a blade system
427 # Some initializations and checking before we begin
429 snmp_initialize(); # initialize SNMP
430 snmp_check(); # check that SNMP works
431 snmp_detect_blade(); # detect blade via SNMP
434 # Find the omreport binary
436 # Check help output from omreport, see which options are available.
437 # Also detecting blade via omreport.
438 check_omreport_options();
442 if ($opt{fahrenheit}) {
443 $opt{tempunit} = 'F';
446 # Check tempunit syntax
447 if ($opt{tempunit} !~ m{\A C|F|K|R \z}xms) {
448 print "ERROR: Unknown temperature unit '$opt{tempunit}'\n";
452 #---------------------------------------------------------------------
454 #---------------------------------------------------------------------
456 # Make a regex from a glob pattern. Shamelessly stolen from Perl
457 # Cookbook chapter 6.9
466 $globstr =~ s{(.)} { $patmap{$1} || "\Q$1" }ge;
467 return '\A' . $globstr . '\z';
473 sub parse_configfile {
476 # Regexp for boolean values
477 our $off = qr{\A (0|off|false) \s* \z}ixms;
478 our $on = qr{\A (1|on|true) \s* \z}ixms;
480 # Mapping between command line options and the corresponding
481 # config file options
483 = ( 'info' => 'output_servicetag',
484 'extinfo' => 'output_sysinfo',
485 'state' => 'output_servicestate',
486 'shortstate' => 'output_servicestate_abbr',
487 'show_blacklist' => 'output_blacklist',
488 'htmlinfo' => 'output_html',
489 'okinfo' => 'output_ok_verbosity',
490 'protocol' => 'snmp_version',
491 'community' => 'snmp_community',
492 'port' => 'snmp_port',
493 'ipv6' => 'snmp_use_ipv6',
494 'tcp' => 'snmp_use_tcp',
495 'warning' => 'temp_threshold_warning',
496 'critical' => 'temp_threshold_critical',
497 'all' => 'check_everything',
498 'perfdata' => 'performance_data',
501 # Load the perl module
502 if ( eval { require Config::Tiny; 1 } ) {
503 $tiny = Config::Tiny->new();
506 print "ERROR: Required perl module 'Config::Tiny' not found\n";
510 # Read the config file
511 $tiny = Config::Tiny->read($opt{configfile})
512 or do { report('other', (sprintf q{Couldn't read configuration file: %s}, Config::Tiny->errstr()), $E_UNKNOWN);
515 # Adjust checks according to statements in the configuration file
516 sub configfile_adjust_checks {
519 foreach my $key (keys %check) {
520 my $copt = join '_', 'check', $key;
521 next CHECK_CONFIG if !defined $tiny->{$keyword}->{$copt} or $tiny->{$keyword}->{$copt} eq q{};
522 if ($tiny->{$keyword}->{$copt} =~ m{$on}ixms) {
525 elsif ($tiny->{$keyword}->{$copt} =~ m{$off}ixms) {
529 report('other', "CONFIG ERROR: Rvalue for '$copt' must be boolean (True/False)", $E_UNKNOWN);
535 # Set blacklist according to statements in the configuration file
536 sub configfile_set_blacklist {
538 if (defined $tiny->{$keyword}->{blacklist} and $tiny->{$keyword}->{blacklist} ne q{}) {
539 # set_blacklist() takes an array ref
540 set_blacklist([$tiny->{$keyword}->{blacklist}]);
545 # Set timeout according to statements in the configuration file
546 sub configfile_set_timeout {
548 if (defined $tiny->{$keyword}->{timeout} and $tiny->{$keyword}->{timeout} ne q{}) {
549 if ($tiny->{$keyword}->{timeout} =~ m{\A \d+ \z}xms) { # integer
550 $opt{timeout} = $tiny->{$keyword}->{timeout};
553 report('other', "CONFIG ERROR: Rvalue for 'timeout' must be a positive integer", $E_UNKNOWN);
559 # Set a boolean option
560 sub configfile_set_boolean {
561 my ($keyword, $bool) = @_;
562 my $cbool = $opt2config{$bool};
563 if (defined $tiny->{$keyword}->{$cbool} and $tiny->{$keyword}->{$cbool} ne q{}) {
564 if ($tiny->{$keyword}->{$cbool} =~ m{$on}ixms) {
567 elsif ($tiny->{$keyword}->{$cbool} =~ m{$off}ixms) {
571 report('other', "CONFIG ERROR: Rvalue for '$cbool' must be boolean (True/False)", $E_UNKNOWN);
577 # Set htmlinfo option from config file
578 sub configfile_set_htmlinfo {
580 my $conf = $opt2config{htmlinfo};
581 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
582 if ($tiny->{$keyword}->{$conf} =~ m{$on}ixms) {
585 elsif ($tiny->{$keyword}->{$conf} =~ m{$off}ixms) {
586 $opt{htmlinfo} = undef;
589 $opt{htmlinfo} = $tiny->{$keyword}->{$conf};
595 # Set OK output verbosity
596 sub configfile_set_ok_verbosity {
598 my $conf = $opt2config{okinfo};
599 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
600 if ($tiny->{$keyword}->{$conf} =~ m{\A \d+ \z}xms) {
601 $opt{okinfo} = $tiny->{$keyword}->{$conf};
604 report('other', "CONFIG ERROR: Rvalue for '$conf' must be a positive integer", $E_UNKNOWN);
610 # Set SNMP protocol version from config file
611 sub configfile_set_snmp_version {
613 my $conf = $opt2config{protocol};
614 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
615 if ($tiny->{$keyword}->{$conf} =~ m{\A 1|2|3 \z}xms) {
616 $opt{protocol} = $tiny->{$keyword}->{$conf};
619 report('other', "CONFIG ERROR: Rvalue for '$conf' must be '1', '2' or '3'", $E_UNKNOWN);
625 # Set SNMP community name from config file
626 sub configfile_set_snmp_community {
628 my $conf = $opt2config{community};
629 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
630 $opt{community} = $tiny->{$keyword}->{$conf};
635 # Set SNMP port number from config file
636 sub configfile_set_snmp_port {
638 my $conf = $opt2config{port};
639 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
640 if ($tiny->{$keyword}->{$conf} =~ m{\A \d+ \z}xms) { # integer
641 $opt{port} = $tiny->{$keyword}->{$conf};
644 report('other', "CONFIG ERROR: Rvalue for '$conf' must be a positive integer", $E_UNKNOWN);
650 # Set temperature threshold from config file
651 sub configfile_set_temp_threshold {
654 my $conf = $opt2config{$level};
655 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
656 $opt{$level} = [$tiny->{$keyword}->{$conf}]; # array ref
661 # Set perfdata from config file
662 sub configfile_set_perfdata {
664 my $conf = $opt2config{perfdata};
665 if (defined $tiny->{$keyword}->{$conf} and $tiny->{$keyword}->{$conf} ne q{}) {
666 if ($tiny->{$keyword}->{$conf} =~ m{$on}ixms) {
669 elsif ($tiny->{$keyword}->{$conf} =~ m{$off}ixms) {
670 $opt{perfdata} = undef;
672 elsif ($tiny->{$keyword}->{$conf} =~ m{\A minimal|multiline \z}xms) {
673 $opt{perfdata} = $tiny->{$keyword}->{$conf};
676 report('other', "CONFIG ERROR: Rvalue for '$conf' must be either boolean, 'minimal' or 'multiline'", $E_UNKNOWN);
682 # Sections in the config file to check for statements
685 # First: Populate the sections array with the global section
688 # Second: Populate the sections array with host glob pattern (but
691 foreach my $glob (sort keys %{ $tiny }) {
692 next PATTERN if $glob eq '_'; # global section
693 next PATTERN if $glob eq $opt{hostname}; # exact match
694 my $regex = glob2regex($glob); # make regexp
695 if ($opt{hostname} =~ m{$regex}) {
696 push @sections, $glob;
700 # Third: Populate the sections array with exact hostname
701 if (defined $tiny->{$opt{hostname}}) {
702 push @sections, $opt{hostname};
705 # Loop through the sections array and get options
706 foreach my $sect (@sections) {
707 configfile_adjust_checks($sect);
708 configfile_set_blacklist($sect);
709 configfile_set_timeout($sect);
710 configfile_set_htmlinfo($sect);
711 configfile_set_ok_verbosity($sect);
712 configfile_set_boolean($sect, 'all');
713 configfile_set_boolean($sect, 'info');
714 configfile_set_boolean($sect, 'extinfo');
715 configfile_set_boolean($sect, 'state');
716 configfile_set_boolean($sect, 'shortstate');
717 configfile_set_boolean($sect, 'show_blacklist');
718 configfile_set_boolean($sect, 'ipv6');
719 configfile_set_boolean($sect, 'tcp');
720 configfile_set_snmp_version($sect);
721 configfile_set_snmp_community($sect);
722 configfile_set_snmp_port($sect);
723 configfile_set_temp_threshold($sect, 'warning');
724 configfile_set_temp_threshold($sect, 'critical');
725 configfile_set_perfdata($sect);
732 # Store a message in one of the message arrays
735 my ($type, $msg, $exval, $id) = @_;
736 defined $id or $id = q{};
740 'storage' => \@report_storage,
741 'chassis' => \@report_chassis,
742 'other' => \@report_other,
745 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
749 # Run command, put resulting output lines in an array and return a
750 # pointer to that array
755 open my $CMD, '-|', $command
756 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
760 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
761 and return \@lines };
766 # Run command, put resulting output in a string variable and return it
771 open my $CMD, '-|', $command
772 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
773 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
776 # NOTE: We don't check the return value of close() since omreport
777 # does something weird sometimes.
785 sub snmp_initialize {
786 # Legal SNMP v3 protocols
787 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
788 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
790 # Parameters to Net::SNMP->session()
793 '-port' => $opt{port},
794 '-hostname' => $opt{hostname},
795 '-version' => $opt{protocol},
798 # Setting the domain (IP version and transport protocol)
799 my $transport = $opt{tcp} ? 'tcp' : 'udp';
800 my $ipversion = $opt{ipv6} ? 'ipv6' : 'ipv4';
801 $param{'-domain'} = "$transport/$ipversion";
803 # Parameters for SNMP v3
804 if ($opt{protocol} == 3) {
806 # Username is mandatory
807 if (defined $opt{username}) {
808 $param{'-username'} = $opt{username};
811 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
815 # Authpassword is optional
816 if (defined $opt{authpassword}) {
817 $param{'-authpassword'} = $opt{authpassword};
820 # Authkey is optional
821 if (defined $opt{authkey}) {
822 $param{'-authkey'} = $opt{authkey};
825 # Privpassword is optional
826 if (defined $opt{privpassword}) {
827 $param{'-privpassword'} = $opt{privpassword};
830 # Privkey is optional
831 if (defined $opt{privkey}) {
832 $param{'-privkey'} = $opt{privkey};
835 # Privprotocol is optional
836 if (defined $opt{privprotocol}) {
837 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
838 $param{'-privprotocol'} = $opt{privprotocol};
841 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
842 . "must be one of [des|aes|aes128|3des|3desde]\n";
847 # Authprotocol is optional
848 if (defined $opt{authprotocol}) {
849 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
850 $param{'-authprotocol'} = $opt{authprotocol};
853 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
854 . "must be one of [md5|sha]\n";
859 # Parameters for SNMP v2c or v1
860 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
861 $param{'-community'} = $opt{community};
864 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
868 # Try to initialize the SNMP session
869 if ( eval { require Net::SNMP; 1 } ) {
870 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
871 if (!defined $snmp_session) {
872 printf "SNMP: %s\n", $snmp_error;
877 print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
884 # Checking if SNMP works by probing for "chassisModelName", which all
885 # servers should have
888 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
889 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
891 # Typically if remote host isn't responding
892 if (!defined $result) {
893 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
897 # If OpenManage isn't installed or is not working
898 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
899 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
906 # Detecting blade via SNMP
908 sub snmp_detect_blade {
909 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
910 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
912 # Identify blade. Older models (4th and 5th gen models) and/or old
913 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
914 # similar, we assume that this isn't a blade
915 if (exists $result->{$DellBaseBoardType} && $result->{$DellBaseBoardType} eq '3') {
922 # Locate the omreport binary
925 # If user has specified path to omreport
926 if (defined $opt{omreport} and -x $opt{omreport}) {
927 $omreport = qq{"$opt{omreport}"};
931 # Possible full paths for omreport
934 '/opt/dell/srvadmin/bin/omreport', # default on Linux with OMSA >= 6.2.0
935 '/usr/bin/omreport', # default on Linux with OMSA < 6.2.0
936 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
937 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
938 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
939 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
940 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
941 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
944 # Find the one to use
946 foreach my $bin (@omreport_paths) {
948 $omreport = qq{"$bin"};
953 # Exit with status=UNKNOWN if OM is not installed, or we don't
954 # have permission to execute the binary
955 if (!defined $omreport) {
956 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
963 # Checks output from 'omreport -?' and searches for arguments to
964 # omreport, to accommodate deprecated options "chassis" and "system"
965 # (on newer hardware), as well as blade servers.
967 sub check_omreport_options {
968 foreach (@{ run_command("$omreport -? 2>&1") }) {
969 if (m/\A servermodule /xms) {
970 # If "servermodule" argument to omreport exists, use it
971 # instead of argument "system"
972 $omopt_system = 'servermodule';
974 elsif (m/\A mainsystem /xms) {
975 # If "mainsystem" argument to omreport exists, use it
976 # instead of argument "chassis"
977 $omopt_chassis = 'mainsystem';
979 elsif (m/\A modularenclosure /xms) {
980 # If "modularenclusure" argument to omreport exists, assume
981 # that this is a blade
989 # Read the blacklist option and return a hash containing the
990 # blacklisted components
996 if (scalar @{ $foo } >= 0) {
997 foreach my $black (@{ $foo }) {
1000 open my $BL, '<', $black
1001 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
1003 chomp($tmp = <$BL>);
1013 return {} if $#bl < 0;
1015 # Parse blacklist string, put in hash
1016 foreach my $black (@bl) {
1017 my @comps = split m{/}xms, $black;
1018 foreach my $c (@comps) {
1019 next if $c !~ m/=/xms;
1020 my ($key, $val) = split /=/xms, $c;
1021 my @vals = split /,/xms, $val;
1022 push @{ $blacklist{$key} }, @vals;
1030 # Read the check option and adjust the hash %check, which is a rough
1031 # list of components to be checked
1036 # First, take the '--no-storage' option
1037 if ($opt{no_storage}) {
1038 $check{storage} = 0;
1041 # Adjust checking based on the '--all' option
1043 # Check option usage
1044 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
1045 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
1048 if (scalar @{ $opt{check} } > 0) {
1049 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
1053 # set the check hash to check everything
1054 map { $_ = 1 } values %check;
1059 # Adjust checking based on the '--only' option
1060 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
1061 # Check option usage
1062 if (scalar @{ $opt{check} } > 0) {
1063 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
1066 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
1067 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
1071 # reset the check hash
1072 map { $_ = 0 } values %check;
1074 # adjust the check hash
1075 if ($opt{only} eq 'chassis') {
1076 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage sdcard
1077 batteries amperage intrusion esmhealth);
1080 $check{$opt{only}} = 1;
1086 # Adjust checking based on the '--check' option
1087 if (scalar @{ $opt{check} } >= 0) {
1088 foreach my $check (@{ $opt{check} }) {
1091 open my $CL, '<', $check
1092 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
1093 chomp($tmp = <$CL>);
1105 # Parse checklist string, put in hash
1106 foreach my $check (@cl) {
1107 my @checks = split /,/xms, $check;
1108 foreach my $c (@checks) {
1109 next if $c !~ m/=/xms;
1110 my ($key, $val) = split /=/xms, $c;
1111 $check{$key} = $val;
1115 # Check if we should check global health status
1117 foreach (keys %check) {
1118 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
1119 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
1121 if ($check{$_} == 0) { # found something with checking turned off
1131 # Runs omreport and returns an array of anonymous hashes containing
1133 # Takes one argument: string containing parameters to omreport
1136 my $command = shift;
1140 # Errors that are OK. Some low-end poweredge (and blades) models
1141 # don't have RAID controllers, intrusion detection sensor, or
1142 # redundant/instrumented power supplies etc.
1145 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
1146 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
1147 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
1148 | Invalid\scommand:\spwrmonitoring # Old hardware
1149 | Hardware\sor\sfeature\snot\spresent\. # SD cards
1150 | Invalid\scommand:\sremovableflashmedia # SD cards with old OMSA
1151 | Error\sCorrection; # Memory stuff. Not really an error (new in OMSA 6.4)
1152 # | Current\sprobes\snot\sfound # OMSA + RHEL5.4 bug
1153 # | No\scontrollers\sfound # No RAID controller
1156 # Errors that are OK on blade servers
1159 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
1162 # Run omreport and fetch output
1163 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
1164 return [] if !defined $rawtext;
1166 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
1167 $rawtext =~ s{\n;}{;}gxms if $command eq 'storage controller';
1169 # Workaround for logical connectors where there are extra
1170 # information that isn't possible to parse consistently. Remove
1171 # everything after and including "Path Health"
1172 if ($command =~ m{\A storage\sconnector}xms) {
1173 $rawtext =~ s{Path\sHealth.*}{}xms;
1176 # Report if no controllers found
1177 if ($command eq 'storage controller' and $rawtext =~ m{No\scontrollers\sfound}xms) {
1178 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
1181 # Openmanage sometimes puts a linebreak between "Error" and the
1183 $rawtext =~ s{^Error\s*\n}{Error: }xms;
1185 # Parse output, store in array
1186 for ((split m{\n}xms, $rawtext)) {
1187 if (m{\AError}xms) {
1188 next if m{$ok_errors}xms;
1189 next if ($blade and m{$ok_blade_errors}xms);
1190 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
1193 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
1194 my @vals = split /;/xms;
1195 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed|Connector\sName) \z/xms) {
1200 push @output, { map { $_ => $vals[$i++] } @keys };
1205 # Finally, return the collected information
1210 # Checks if a component is blacklisted. Returns 1 if the component is
1211 # blacklisted, 0 otherwise. Takes two arguments:
1212 # arg1: component name
1213 # arg2: component id or index
1216 my $name = shift; # component name
1217 my $id = shift; # component id
1218 my $ret = 0; # return value
1220 if (defined $blacklist{$name}) {
1221 foreach my $comp (@{ $blacklist{$name} }) {
1222 if (defined $id and ($comp eq $id or uc($comp) eq 'ALL')) {
1231 # Converts the NexusID from SNMP to our version
1234 $nexus =~ s{\A \\}{}xms;
1235 $nexus =~ s{\\}{:}gxms;
1239 # Sets custom temperature thresholds based on user supplied options
1240 sub custom_temperature_thresholds {
1241 my $type = shift; # type of threshold, either w (warning) or c (critical)
1242 my %thres = (); # will contain the thresholds
1243 my @limits = (); # holds the input
1245 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
1247 if (scalar @opt >= 0) {
1248 foreach my $t (@opt) {
1252 or do { report('other', "Couldn't open temperature threshold file $t: $!",
1253 $E_UNKNOWN) and return {} };
1264 # Parse checklist string, put in hash
1265 foreach my $th (@limits) {
1266 my @tmp = split m{,}xms, $th;
1267 foreach my $t (@tmp) {
1268 next if $t !~ m{=}xms;
1269 my ($key, $val) = split m{=}xms, $t;
1270 if ($val =~ m{/}xms) {
1271 my ($max, $min) = split m{/}xms, $val;
1272 $thres{$key}{max} = $max;
1273 $thres{$key}{min} = $min;
1276 $thres{$key}{max} = $val;
1285 # Gets the output from SNMP result according to the OIDs checked
1286 sub get_snmp_output {
1287 my ($result,$oidref) = @_;
1291 foreach my $oid (keys %{ $result }) {
1293 $short =~ s{\s}{}gxms; # remove whitespace
1294 $short =~ s{\A (.+) \. (\d+) \z}{$1}xms; # remove last number
1296 if (exists $oidref->{$short}) {
1297 $temp[$id]{$oidref->{$short}} = $result->{$oid};
1301 # Remove any empty indexes
1302 foreach my $out (@temp) {
1312 # Map the controller or other item in-place
1314 my ($key, $val, $list) = @_;
1316 foreach my $lst (@{ $list }) {
1317 if (!exists $lst->{$key}) {
1318 $lst->{$key} = $val;
1324 # Return the URL for official Dell documentation for a specific
1326 sub documentation_url {
1329 # create model short form, e.g. "r710"
1330 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
1332 # special case for blades (e.g. M600, M710), they have common
1334 $model =~ s{\A m\d+ \z}{m}xms;
1336 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
1339 # Return the URL for warranty information for a server with a given
1340 # serial number (servicetag)
1344 # Dell support sites for different parts of the world
1347 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
1348 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
1349 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1352 # warranty URLs for different country codes
1356 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1357 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1358 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1359 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1360 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1361 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1362 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1363 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1364 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1365 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1366 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1367 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1368 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1369 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1370 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1371 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1372 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1373 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1374 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1375 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1377 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1378 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1379 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1380 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1382 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1383 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1384 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1386 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1389 if (exists $url{$opt{htmlinfo}}) {
1390 return $url{$opt{htmlinfo}} . $tag;
1393 return $url{XX} . $tag;
1398 # This helper function returns the corresponding value of a hash key,
1399 # but takes into account that the key may not exist
1401 my $key = shift || return;
1403 return defined $hash->{$key} ? $hash->{$key} : "Undefined value $key";
1406 # Find component status from hash
1407 sub get_snmp_status {
1408 my $key = shift || return 'Unknown';
1409 return exists $snmp_status{$key} ? $snmp_status{$key} : 'Unknown';
1412 # Find component status from hash
1413 sub get_snmp_probestatus {
1414 my $key = shift || return 'Unknown';
1415 return exists $snmp_probestatus{$key} ? $snmp_probestatus{$key} : 'Unknown';
1418 # Check that a hash entry is defined and not an empty string. Return a
1419 # chosen string (parameter) if these conditions are not met
1420 sub get_nonempty_string {
1421 my $key = shift; # key to check
1422 my $hash = shift; # hash where the key belongs
1423 my $alt = shift; # alternate return value
1424 if (defined $hash->{$key} and $hash->{$key} ne q{}) {
1425 return $hash->{$key};
1430 # Converts from Celsius to something else
1431 sub temp_from_celsius {
1436 return ceil($x * 9/5 + 32);
1438 elsif ($to eq 'K') {
1439 return ceil($x + 273.15);
1441 elsif ($to eq 'R') {
1442 return ceil($x * 9/5 + 32 + 459.67);
1448 #---------------------------------------------------------------------
1450 #---------------------------------------------------------------------
1452 #-----------------------------------------
1453 # Check global health status
1454 #-----------------------------------------
1460 # Checks global status, i.e. both storage and chassis
1462 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1463 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1464 if (!defined $result) {
1465 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1468 $health = $status2nagios{get_snmp_status($result->{$systemStateGlobalSystemStatus})};
1472 # NB! This does not check storage, only chassis...
1474 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1476 next if m/\A SEVERITY;COMPONENT/xms;
1477 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1478 $health = $status2nagios{$1};
1489 #-----------------------------------------
1490 # STORAGE: Check controllers
1491 #-----------------------------------------
1492 sub check_controllers {
1499 my $firmware = undef;
1501 my $minstdr = undef; # Minimum required Storport driver version
1502 my $stdr = undef; # Storport driver version
1508 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1509 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1510 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1511 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1512 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1513 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1514 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1515 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1516 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1517 '1.3.6.1.4.1.674.10893.1.20.130.1.1.55' => 'controllerStorportDriverVersion',
1518 '1.3.6.1.4.1.674.10893.1.20.130.1.1.56' => 'controllerMinRequiredStorportVer',
1521 # We use get_table() here for the odd case where a server has
1522 # two or more controllers, and where some OIDs are missing on
1523 # one of the controllers.
1524 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1525 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1527 if (!defined $result) {
1528 report('storage', 'Storage Error! No controllers found', $E_UNKNOWN);
1532 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1535 @output = @{ run_omreport('storage controller') };
1549 foreach my $out (@output) {
1551 $name = $out->{controllerName} || 'Unknown controller';
1552 $state = get_hashval($out->{controllerState}, \%ctrl_state) || 'Unknown state';
1553 $status = get_snmp_status($out->{controllerComponentStatus});
1554 $minfw = $out->{controllerMinFWVersion} || undef;
1555 $mindr = $out->{controllerMinDriverVersion} || undef;
1556 $firmware = $out->{controllerFWVersion} || 'N/A';
1557 $driver = $out->{controllerDriverVersion} || 'N/A';
1558 $minstdr = $out->{'controllerMinRequiredStorportVer'} || undef;
1559 $stdr = $out->{controllerStorportDriverVersion} || undef;
1560 $nexus = convert_nexus(($out->{controllerNexusID} || 9999));
1563 $nexus = get_nonempty_string('ID', $out, '9999');
1564 $name = get_nonempty_string('Name', $out, 'Unknown controller');
1565 $state = get_nonempty_string('State', $out, 'Unknown state');
1566 $status = get_nonempty_string('Status', $out, 'Unknown');
1567 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1568 ? $out->{'Minimum Required Firmware Version'} : undef;
1569 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1570 ? $out->{'Minimum Required Driver Version'} : undef;
1571 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1572 ? $out->{'Firmware Version'} : 'N/A';
1573 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1574 ? $out->{'Driver Version'} : 'N/A';
1575 $minstdr = (exists $out->{'Minimum Required Storport Driver Version'}
1576 and $out->{'Minimum Required Storport Driver Version'} ne 'Not Applicable')
1577 ? $out->{'Minimum Required Storport Driver Version'} : undef;
1578 $stdr = (exists $out->{'Storport Driver Version'}
1579 and $out->{'Storport Driver Version'} ne 'Not Applicable')
1580 ? $out->{'Storport Driver Version'} : undef;
1583 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1584 push @controllers, $nexus;
1586 # Collecting some storage info
1587 $sysinfo{'controller'}{$nexus}{'id'} = $nexus;
1588 $sysinfo{'controller'}{$nexus}{'name'} = $name;
1589 $sysinfo{'controller'}{$nexus}{'driver'} = $driver;
1590 $sysinfo{'controller'}{$nexus}{'firmware'} = $firmware;
1591 $sysinfo{'controller'}{$nexus}{'storport'} = $stdr;
1593 # Store controller info for future use (SNMP)
1595 $snmp_controller{$out->{controllerNumber}} = $nexus;
1598 next CTRL if blacklisted('ctrl', $nexus);
1600 # Special case: old firmware
1601 if (!blacklisted('ctrl_fw', $nexus) && defined $minfw) {
1603 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1604 $nexus, $name, $firmware;
1605 report('storage', $msg, $E_WARNING, $nexus);
1607 # Special case: old driver
1608 if (!blacklisted('ctrl_driver', $nexus) && defined $mindr) {
1610 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1611 $nexus, $name, $driver;
1612 report('storage', $msg, $E_WARNING, $nexus);
1614 # Special case: old storport driver
1615 if (!blacklisted('ctrl_stdr', $nexus) && defined $minstdr) {
1617 my $msg = sprintf q{Controller %d [%s]: Storport driver '%s' is out of date},
1618 $nexus, $name, $stdr;
1619 report('storage', $msg, $E_WARNING, $nexus);
1622 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1623 and (defined $minfw or defined $mindr or defined $minstdr))) {
1624 my $msg = sprintf 'Controller %d [%s] is %s',
1625 $nexus, $name, $state;
1626 report('storage', $msg, $E_OK, $nexus);
1630 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1631 $nexus, $name, $state;
1632 report('storage', $msg, $status2nagios{$status}, $nexus);
1639 #-----------------------------------------
1640 # STORAGE: Check physical drives
1641 #-----------------------------------------
1642 sub check_physical_disks {
1643 return if $#controllers == -1;
1652 my $vendor = undef; # disk vendor
1653 my $product = undef; # product ID
1654 my $capacity = undef; # disk length (size) in bytes
1655 my $media = undef; # media type (e.g. HDD, SSD)
1656 my $bus = undef; # bus protocol (e.g. SAS, SATA)
1657 my $spare = undef; # spare state (e.g. global hotspare)
1658 my $cert = undef; # if drive is certified or not
1664 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1665 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1666 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1667 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1668 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1669 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1670 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1671 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1672 '1.3.6.1.4.1.674.10893.1.20.130.4.1.21' => 'arrayDiskBusType',
1673 '1.3.6.1.4.1.674.10893.1.20.130.4.1.22' => 'arrayDiskSpareState',
1674 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1675 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1676 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1677 '1.3.6.1.4.1.674.10893.1.20.130.4.1.35' => 'arrayDiskMediaType',
1678 '1.3.6.1.4.1.674.10893.1.20.130.4.1.36' => 'arrayDiskDellCertified',
1679 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1680 '1.3.6.1.4.1.674.10893.1.20.130.6.1.7' => 'arrayDiskChannelConnectionControllerNumber',
1683 if ($opt{use_get_table}) {
1684 my $arrayDiskTable = '1.3.6.1.4.1.674.10893.1.20.130.4';
1685 my $arrayDiskEnclosureConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.5.1.7';
1686 my $arrayDiskChannelConnectionControllerNumber = '1.3.6.1.4.1.674.10893.1.20.130.6.1.7';
1688 $result = $snmp_session->get_table(-baseoid => $arrayDiskTable);
1689 my $ext1 = $snmp_session->get_table(-baseoid => $arrayDiskEnclosureConnectionControllerNumber);
1690 my $ext2 = $snmp_session->get_table(-baseoid => $arrayDiskChannelConnectionControllerNumber);
1692 if (defined $result) {
1693 defined $ext1 && map { $$result{$_} = $$ext1{$_} } keys %{ $ext1 };
1694 defined $ext2 && map { $$result{$_} = $$ext2{$_} } keys %{ $ext2 };
1698 $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1701 if (!defined $result) {
1702 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1703 $snmp_session->close;
1707 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1710 foreach my $c (@controllers) {
1711 # This blacklists disks with broken firmware, which includes
1712 # illegal XML characters that makes openmanage choke on itself
1713 next if blacklisted('ctrl_pdisk', $c);
1715 push @output, @{ run_omreport("storage pdisk controller=$c") };
1716 map_item('ctrl', $c, \@output);
1722 1 => 'VD member', # disk is a member of a virtual disk
1723 2 => 'DG member', # disk is a member of a disk group
1724 3 => 'Global HS', # disk is a global hot spare
1725 4 => 'Dedicated HS', # disk is a dedicated hot spare
1726 5 => 'no', # not a spare
1727 99 => 'n/a', # not applicable
1741 3 => 'Fibre Channel',
1759 22 => 'Replacing', # FIXME: this one is not defined in the OMSA MIBs
1763 28 => 'Diagnostics',
1764 34 => 'Predictive failure',
1765 35 => 'Initializing',
1768 41 => 'Unsupported',
1769 53 => 'Incompatible',
1772 # Check physical disks on each of the controllers
1774 foreach my $out (@output) {
1776 $name = $out->{arrayDiskName} || 'Unknown disk';
1777 $state = get_hashval($out->{arrayDiskState}, \%pdisk_state) || 'Unknown state';
1778 $status = get_snmp_status($out->{arrayDiskComponentStatus});
1779 $fpred = defined $out->{arrayDiskSmartAlertIndication}
1780 && $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1782 $nexus = convert_nexus(($out->{arrayDiskNexusID} || 9999));
1783 $vendor = $out->{arrayDiskVendor} || 'Unknown vendor';
1784 $product = $out->{arrayDiskProductID} || 'Unknown product ID';
1785 $spare = get_hashval($out->{arrayDiskSpareState}, \%spare_state) || q{};
1786 $bus = get_hashval($out->{arrayDiskBusType}, \%bus_type);
1787 $media = get_hashval($out->{arrayDiskMediaType}, \%media_type);
1788 $cert = defined $out->{arrayDiskDellCertified} ? $out->{arrayDiskDellCertified} : 1;
1789 $capacity = exists $out->{arrayDiskLengthInMB}
1790 ? $out->{arrayDiskLengthInMB} * 1024**2 : -1;
1792 # try to find the controller where the disk belongs
1793 if (exists $out->{arrayDiskEnclosureConnectionControllerNumber}) {
1794 # for disks that are attached to an enclosure
1795 $ctrl = $snmp_controller{$out->{arrayDiskEnclosureConnectionControllerNumber}};
1797 elsif (exists $out->{arrayDiskChannelConnectionControllerNumber}) {
1798 # for disks that are not attached to an enclosure
1799 $ctrl = $snmp_controller{$out->{arrayDiskChannelConnectionControllerNumber}};
1802 # last resort... use the nexus id (old/broken hardware)
1804 $ctrl =~ s{\A (\d+) : .* \z}{$1}xms;
1808 $name = get_nonempty_string('Name', $out, 'Unknown disk');
1809 $state = get_nonempty_string('State', $out, 'Unknown state');
1810 $status = get_nonempty_string('Status', $out, 'Unknown');
1811 $fpred = lc(get_nonempty_string('Failure Predicted', $out, q{})) eq 'yes' ? 1 : 0;
1812 $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
1813 $nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
1814 $vendor = get_nonempty_string('Vendor ID', $out, 'Unknown Vendor');
1815 $product = get_nonempty_string('Product ID', $out, 'Unknown Product ID');
1816 $media = get_nonempty_string('Media', $out, undef);
1817 $bus = get_nonempty_string('Bus Protocol', $out, undef);
1818 $spare = get_nonempty_string('Hot Spare', $out, q{});
1819 $cert = get_nonempty_string('Certified', $out, 1);
1820 $ctrl = $out->{ctrl};
1821 $capacity = get_nonempty_string('Capacity', $out, q{});
1822 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1823 if ($capacity eq 'Unavailable') {
1826 if ($cert eq 'Yes' or $cert eq 'Not Applicable') {
1835 next PDISK if blacklisted('pdisk', $nexus);
1837 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1838 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1840 # If the disk is bad, the vendor field may be empty
1841 if ($vendor eq q{}) { $vendor = 'Unknown Vendor'; }
1844 if ($spare eq 'Global') { $spare = 'Global HS'; }
1845 elsif ($spare eq 'Dedicated') { $spare = 'Dedicated HS'; }
1846 elsif ($spare !~ m{\A Global|Dedicated}xms) { $spare = undef; }
1848 # Calculate human readable capacity
1849 if ($capacity == -1) {
1850 # capacity is unknown
1851 $capacity = 'Unknown Size';
1854 $capacity = ceil($capacity / 1000**3) >= 1000
1855 ? sprintf '%.1fTB', ($capacity / 1000**4)
1856 : sprintf '%.0fGB', ($capacity / 1000**3);
1857 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1858 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1859 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1860 $capacity = '100GB' if $capacity eq '99GB'; # quick fix for 100GB disks
1863 # Capitalize only the first letter of the vendor name
1864 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1866 # Remove unnecessary trademark rubbish from vendor name
1867 $vendor =~ s{\(tm\)\z}{}xms;
1869 # bus and media aren't always defined
1871 if (defined $bus && defined $media) { $busmedia = "$bus-$media "; }
1872 elsif (defined $bus && ! defined $media) { $busmedia = "$bus "; }
1873 elsif (! defined $bus && defined $media) { $busmedia = "$media "; }
1875 # Special case: Failure predicted
1877 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1878 $name, $vendor, $product, $capacity, $ctrl;
1879 $msg .= " ($state)" if $state ne 'Predictive failure';
1880 report('storage', $msg,
1881 ($status2nagios{$status} == $E_CRITICAL ? $E_CRITICAL : $E_WARNING), $nexus);
1883 # Special case: Rebuilding / Replacing
1884 elsif ($state =~ m{\A Rebuilding|Replacing \z}xms) {
1885 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s%s',
1886 $name, $vendor, $product, $capacity, $ctrl, $state, $progr;
1887 report('storage', $msg, $E_WARNING, $nexus);
1889 # Special case: Uncertified disk
1890 elsif ($status eq 'Non-Critical' and !$cert) {
1891 if (blacklisted('pdisk_cert', $nexus)) {
1892 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s, Not Certified',
1893 $name, $vendor, $product, $capacity, $ctrl, $state;
1894 report('storage', $msg, $E_OK, $nexus);
1897 my $msg = sprintf '%s [%s %s, %s] on ctrl %d is Not Certified',
1898 $name, $vendor, $product, $capacity, $ctrl;
1899 report('storage', $msg, $E_WARNING, $nexus);
1903 elsif ($status ne 'Ok') {
1904 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1905 $name, $vendor, $product, $capacity, $ctrl, $state;
1906 report('storage', $msg, $status2nagios{$status}, $nexus);
1910 my $msg = sprintf '%s [%s%s] on ctrl %d is %s',
1911 $name, $busmedia, $capacity, $ctrl, $state;
1912 if (defined $spare) { $msg .= " ($spare)"; }
1913 report('storage', $msg, $E_OK, $nexus);
1920 #-----------------------------------------
1921 # STORAGE: Check logical drives
1922 #-----------------------------------------
1923 sub check_virtual_disks {
1924 return if $#controllers == -1;
1940 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1941 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1942 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1943 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1944 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1945 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1948 if ($opt{use_get_table}) {
1949 my $virtualDiskTable = '1.3.6.1.4.1.674.10893.1.20.140.1';
1950 $result = $snmp_session->get_table(-baseoid => $virtualDiskTable);
1953 $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1956 # No logical drives is OK
1957 return if !defined $result;
1959 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1962 foreach my $c (@controllers) {
1963 push @output, @{ run_omreport("storage vdisk controller=$c") };
1964 map_item('ctrl', $c, \@output);
1977 16 => 'Regenerating',
1980 32 => 'Reconstructing',
1981 35 => 'Initializing',
1982 36 => 'Background Initialization',
1983 38 => 'Resynching Paused',
1984 52 => 'Permanently Degraded',
1985 54 => 'Degraded Redundancy',
1990 1 => 'Concatenated',
1993 4 => 'UNSUPPORTED:raid-2',
1994 5 => 'UNSUPPORTED:raid-3',
1995 6 => 'UNSUPPORTED:raid-4',
1998 9 => 'UNSUPPORTED:raid-7',
2000 11 => 'UNSUPPORTED:raid-30',
2002 13 => 'UNSUPPORTED:addSpares',
2003 14 => 'UNSUPPORTED:deleteLogical',
2004 15 => 'UNSUPPORTED:transformLogical',
2005 18 => 'UNSUPPORTED:raid-0-plus-1',
2006 19 => 'Concatenated RAID-1',
2007 20 => 'UNSUPPORTED:concatRaid-5',
2008 21 => 'UNSUPPORTED:noRaid',
2009 22 => 'UNSUPPORTED:volume',
2010 23 => 'UNSUPPORTED:raidMorph',
2015 # Check virtual disks on each of the controllers
2017 foreach my $out (@output) {
2019 $dev = $out->{virtualDiskDeviceName} || 'Unknown device';
2020 $state = get_hashval($out->{virtualDiskState}, \%vdisk_state) || 'Unknown state';
2021 $layout = get_hashval($out->{virtualDiskLayout}, \%vdisk_layout) || 'Unknown layout';
2022 $status = get_snmp_status($out->{virtualDiskComponentStatus});
2023 $size = sprintf '%.2f GB', ($out->{virtualDiskLengthInMB} || 0) / 1024;
2024 $progr = q{}; # not available via SNMP
2025 $nexus = convert_nexus(($out->{virtualDiskNexusID} || 9999));
2028 $dev = get_nonempty_string('Device Name', $out, 'Unknown device');
2029 $state = get_nonempty_string('State', $out, 'Unknown state');
2030 $status = get_nonempty_string('Status', $out, 'Unknown');
2031 $layout = get_nonempty_string('Layout', $out, 'Unknown layout');
2032 $size = get_nonempty_string('Size', $out, 'Unavailable');
2033 $size =~ s{\A (.*GB).* \z}{$1}xms;
2034 $progr = ' [' . get_nonempty_string('Progress', $out, q{}) . ']';
2035 $ctrl = $out->{ctrl};
2036 $nexus = join q{:}, $ctrl, get_nonempty_string('ID', $out, '9999');
2040 next VDISK if blacklisted('vdisk', $nexus);
2042 # The device name is undefined sometimes
2043 $dev = q{} if !defined $dev;
2045 # Special case: Regenerating
2046 if ($state eq 'Regenerating') {
2047 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s%s},
2048 $dev, $layout, $size, $state, $progr;
2049 report('storage', $msg, $E_WARNING, $nexus);
2052 elsif ($status ne 'Ok') {
2053 my $msg = sprintf q{Logical Drive '%s' [%s, %s] needs attention: %s},
2054 $dev, $layout, $size, $state;
2055 report('storage', $msg, $status2nagios{$status}, $nexus);
2059 my $msg = sprintf q{Logical Drive '%s' [%s, %s] is %s},
2060 $dev, $layout, $size, $state;
2061 report('storage', $msg, $E_OK, $nexus);
2068 #-----------------------------------------
2069 # STORAGE: Check cache batteries
2070 #-----------------------------------------
2071 sub check_cache_battery {
2072 return if $#controllers == -1;
2079 my $learn = undef; # learn state
2080 my $pred = undef; # battery's ability to be charged
2086 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
2087 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
2088 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
2089 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
2090 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
2091 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
2094 if ($opt{use_get_table}) {
2095 my $batteryTable = '1.3.6.1.4.1.674.10893.1.20.130.15';
2096 my $batteryConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.16';
2098 $result = $snmp_session->get_table(-baseoid => $batteryTable);
2099 my $ext = $snmp_session->get_table(-baseoid => $batteryConnectionTable);
2101 if (defined $result) {
2102 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2106 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
2109 # No cache battery is OK
2110 return if !defined $result;
2112 @output = @{ get_snmp_output($result, \%bat_oid) };
2115 foreach my $c (@controllers) {
2116 push @output, @{ run_omreport("storage battery controller=$c") };
2117 map_item('ctrl', $c, \@output);
2127 7 => 'Reconditioning',
2135 # Specifies the learn state activity of the battery
2145 # This property displays the battery's ability to be charged
2148 1 => 'Failed', # The battery cannot be charged and needs to be replaced
2149 2 => 'Ready', # The battery can be charged to full capacity
2150 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
2151 # battery cannot be determined until the Learn cycle is complete
2154 # Check battery on each of the controllers
2156 foreach my $out (@output) {
2158 $status = get_snmp_status($out->{batteryComponentStatus});
2159 $state = get_hashval($out->{batteryState}, \%bat_state) || 'Unknown state';
2160 $learn = get_hashval($out->{batteryLearnState}, \%bat_learn_state) || 'Unknown learn state';
2161 $pred = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap) || 'Unknown predicted capacity status';
2162 $ctrl = ($out->{batteryConnectionControllerNumber} || 10000) - 1;
2163 $nexus = convert_nexus(($out->{batteryNexusID} || 9999));
2165 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
2168 $id = get_nonempty_string('ID', $out, 9999);
2169 $state = get_nonempty_string('State', $out, 'Unknown state');
2170 $status = get_nonempty_string('Status', $out, 'Unknown');
2171 $learn = get_nonempty_string('Learn State', $out, 'Unknown learn state');
2172 $pred = get_nonempty_string('Predicted Capacity Status', $out, 'Unknown predicted capacity status');
2173 $ctrl = $out->{'ctrl'};
2174 $nexus = join q{:}, $out->{ctrl}, $id;
2177 next BATTERY if blacklisted('bat', $nexus);
2179 # Special case: Charging
2180 if ($state eq 'Charging') {
2181 if ($pred eq 'Failed') {
2182 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [replace battery]',
2183 $id, $ctrl, $state, $pred;
2184 report('storage', $msg, $E_CRITICAL, $nexus);
2187 next BATTERY if blacklisted('bat_charge', $nexus);
2188 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
2189 $id, $ctrl, $state, $pred;
2190 report('storage', $msg, $E_WARNING, $nexus);
2193 # Special case: Learning (battery learns its capacity)
2194 elsif ($state eq 'Learning') {
2195 if ($learn eq 'Failed') {
2196 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s)',
2197 $id, $ctrl, $state, $learn;
2198 report('storage', $msg, $E_CRITICAL, $nexus);
2201 next BATTERY if blacklisted('bat_charge', $nexus);
2202 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
2203 $id, $ctrl, $state, $learn;
2204 report('storage', $msg, $E_WARNING, $nexus);
2207 # Special case: Power Low (first part of recharge cycle)
2208 elsif ($state eq 'Power Low') {
2209 next BATTERY if blacklisted('bat_charge', $nexus);
2210 my $msg = sprintf 'Cache Battery %d in controller %d is %s [probably harmless]',
2212 report('storage', $msg, $E_WARNING, $nexus);
2214 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
2215 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
2216 next BATTERY if blacklisted('bat_charge', $nexus);
2217 my $msg = sprintf 'Cache Battery %d in controller %d is %s (%s) [probably harmless]',
2218 $id, $ctrl, $state, $status;
2219 report('storage', $msg, $E_WARNING, $nexus);
2223 my $msg = sprintf 'Cache Battery %d in controller %d is %s',
2225 report('storage', $msg, $status2nagios{$status}, $nexus);
2232 #-----------------------------------------
2233 # STORAGE: Check connectors (channels)
2234 #-----------------------------------------
2235 sub check_connectors {
2236 return if $#controllers == -1;
2249 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
2250 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
2251 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
2252 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
2253 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
2256 if ($opt{use_get_table}) {
2257 my $channelTable = '1.3.6.1.4.1.674.10893.1.20.130.2';
2258 $result = $snmp_session->get_table(-baseoid => $channelTable);
2261 $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
2264 if (!defined $result) {
2265 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
2266 $snmp_session->close;
2270 @output = @{ get_snmp_output($result, \%conn_oid) };
2273 foreach my $c (@controllers) {
2274 push @output, @{ run_omreport("storage connector controller=$c") };
2275 map_item('ctrl', $c, \@output);
2293 3 => 'Fibre Channel',
2300 # Check connectors on each of the controllers
2302 foreach my $out (@output) {
2304 $name = $out->{channelName} || 'Unknown channel';
2305 $status = get_snmp_status($out->{channelComponentStatus});
2306 $state = get_hashval($out->{channelState}, \%conn_state) || 'Unknown state';
2307 $type = get_hashval($out->{channelBusType}, \%conn_bustype) || 'Unknown type';
2308 $nexus = convert_nexus(($out->{channelNexusID} || 9999));
2310 $ctrl =~ s{(\d+):\d+}{$1}xms;
2313 $name = get_nonempty_string('Name', $out, 'Unknown channel');
2314 $state = get_nonempty_string('State', $out, 'Unknown state');
2315 $status = get_nonempty_string('Status', $out, 'Unknown');
2316 $type = get_nonempty_string('Connector Type', $out, 'Unknown type');
2317 $ctrl = $out->{ctrl};
2318 $nexus = join q{:}, $out->{ctrl}, $out->{'ID'};
2321 next CHANNEL if blacklisted('conn', $nexus);
2323 my $msg = sprintf '%s [%s] on controller %d is %s',
2324 $name, $type, $ctrl, $state;
2325 report('storage', $msg, $status2nagios{$status}, $nexus);
2331 #-----------------------------------------
2332 # STORAGE: Check enclosures
2333 #-----------------------------------------
2334 sub check_enclosures {
2340 my $firmware = undef;
2342 my $occupied_slots = undef; # number of occupied slots
2343 my $total_slots = undef; # number of total slots
2349 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
2350 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
2351 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
2352 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
2353 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
2354 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
2355 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
2356 '1.3.6.1.4.1.674.10893.1.20.130.3.1.31' => 'enclosureOccupiedSlotCount', # new in OMSA 6.3.0
2357 '1.3.6.1.4.1.674.10893.1.20.130.3.1.32' => 'enclosureTotalSlots', # new in OMSA 6.3.0
2360 if ($opt{use_get_table}) {
2361 my $enclosureTable = '1.3.6.1.4.1.674.10893.1.20.130.3';
2362 $result = $snmp_session->get_table(-baseoid => $enclosureTable);
2365 $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
2368 # No enclosures is OK
2369 return if !defined $result;
2371 @output = @{ get_snmp_output($result, \%encl_oid) };
2374 foreach my $c (@controllers) {
2375 push @output, @{ run_omreport("storage enclosure controller=$c") };
2376 map_item('ctrl', $c, \@output);
2391 foreach my $out (@output) {
2393 $id = ($out->{enclosureNumber} || 10000) - 1;
2394 $name = $out->{enclosureName} || 'Unknown enclosure';
2395 $state = get_hashval($out->{enclosureState}, \%encl_state) || 'Unknown state';
2396 $status = get_snmp_status($out->{enclosureComponentStatus});
2397 $firmware = $out->{enclosureFirmwareVersion} || 'N/A';
2398 $nexus = convert_nexus(($out->{enclosureNexusID} || 9999));
2400 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
2401 # for the next two, a value of 9999 means feature not available
2402 $occupied_slots = defined $out->{enclosureOccupiedSlotCount}
2403 && $out->{enclosureOccupiedSlotCount} != 9999
2404 ? $out->{enclosureOccupiedSlotCount} : undef;
2405 $total_slots = defined $out->{enclosureTotalSlots}
2406 && $out->{enclosureTotalSlots} != 9999
2407 ? $out->{enclosureTotalSlots} : undef;
2410 $id = get_nonempty_string('ID', $out, 9999);
2411 $name = get_nonempty_string('Name', $out, 'Unknown enclosure');
2412 $state = get_nonempty_string('State', $out, 'Unknown state');
2413 $status = get_nonempty_string('Status', $out, 'Unknown');
2414 $firmware = get_nonempty_string('Firmware Version', $out, 'N/A');
2415 $firmware =~ s{Not\sApplicable}{N/A}xms;
2416 $nexus = join q{:}, $out->{ctrl}, $id;
2417 $ctrl = $out->{ctrl};
2420 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
2421 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
2423 # store enclosure data for future use
2425 $snmp_enclosure{$out->{enclosureNumber}}{id} = $id;
2426 $snmp_enclosure{$out->{enclosureNumber}}{name} = $name;
2427 $snmp_enclosure{$out->{enclosureNumber}}{nexus} = $nexus;
2430 push @enclosures, { 'id' => $id,
2431 'ctrl' => $out->{ctrl},
2435 # Collecting some storage info
2436 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
2437 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
2438 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
2440 next ENCLOSURE if blacklisted('encl', $nexus);
2443 if (defined $occupied_slots && defined $total_slots) {
2444 $msg = sprintf 'Enclosure %s [%s, %d/%d slots occupied] on ctrl %d is %s',
2445 $nexus, $name, $occupied_slots, $total_slots, $ctrl, $state;
2448 $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
2449 $nexus, $name, $ctrl, $state;
2451 report('storage', $msg, $status2nagios{$status}, $nexus);
2457 #-----------------------------------------
2458 # STORAGE: Check enclosure fans
2459 #-----------------------------------------
2460 sub check_enclosure_fans {
2461 return if $#controllers == -1;
2468 my $encl_id = undef;
2469 my $encl_name = undef;
2475 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
2476 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
2477 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
2478 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
2479 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
2480 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
2481 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
2484 if ($opt{use_get_table}) {
2485 my $fanTable = '1.3.6.1.4.1.674.10893.1.20.130.7';
2486 my $fanConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.8';
2488 $result = $snmp_session->get_table(-baseoid => $fanTable);
2489 my $ext = $snmp_session->get_table(-baseoid => $fanConnectionTable);
2491 if (defined $result) {
2492 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2496 $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
2499 # No enclosure fans is OK
2500 return if !defined $result;
2502 @output = @{ get_snmp_output($result, \%fan_oid) };
2505 foreach my $enc (@enclosures) {
2506 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
2507 map_item('ctrl', $enc->{ctrl}, \@output);
2508 map_item('encl_id', $enc->{id}, \@output);
2509 map_item('encl_name', $enc->{name}, \@output);
2524 # Check fans on each of the enclosures
2526 foreach my $out (@output) {
2528 $name = $out->{fanName} || 'Unknown fan';
2529 $state = get_hashval($out->{fanState}, \%fan_state) || 'Unknown state';
2530 $status = get_snmp_status($out->{fanComponentStatus});
2531 $speed = $out->{fanProbeCurrValue} || 'N/A';
2532 $encl_name = $out->{fanConnectionEnclosureName} || 'Unknown enclosure';
2533 $encl_id = $snmp_enclosure{$out->{fanConnectionEnclosureNumber}}{nexus};
2534 $nexus = convert_nexus(($out->{fanNexusID} || 9999));
2537 $name = get_nonempty_string('Name', $out, 'Unknown fan');
2538 $state = get_nonempty_string('State', $out, 'Unknown state');
2539 $status = get_nonempty_string('Status', $out, 'Unknown');
2540 $speed = get_nonempty_string('Speed', $out, 'N/A');
2541 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2542 $encl_name = $out->{encl_name};
2543 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2546 next FAN if blacklisted('encl_fan', $nexus);
2549 if ($status ne 'Ok') {
2550 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2551 $name, $encl_id, $encl_name, $state;
2552 report('storage', $msg, $status2nagios{$status}, $nexus);
2556 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
2557 $name, $encl_id, $encl_name, $state, $speed;
2558 report('storage', $msg, $E_OK, $nexus);
2565 #-----------------------------------------
2566 # STORAGE: Check enclosure power supplies
2567 #-----------------------------------------
2568 sub check_enclosure_pwr {
2569 return if $#controllers == -1;
2575 my $encl_id = undef;
2576 my $encl_name = undef;
2582 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
2583 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
2584 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
2585 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
2586 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
2587 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
2590 if ($opt{use_get_table}) {
2591 my $powerSupplyTable = '1.3.6.1.4.1.674.10893.1.20.130.9';
2592 my $powerSupplyConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.10';
2594 $result = $snmp_session->get_table(-baseoid => $powerSupplyTable);
2595 my $ext = $snmp_session->get_table(-baseoid => $powerSupplyConnectionTable);
2597 if (defined $result) {
2598 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2602 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2605 # No enclosure power supplies is OK
2606 return if !defined $result;
2608 @output = @{ get_snmp_output($result, \%ps_oid) };
2611 foreach my $enc (@enclosures) {
2612 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
2613 map_item('ctrl', $enc->{ctrl}, \@output);
2614 map_item('encl_id', $enc->{id}, \@output);
2615 map_item('encl_name', $enc->{name}, \@output);
2624 5 => 'Not Installed',
2630 # Check power supplies on each of the enclosures
2632 foreach my $out (@output) {
2634 $name = $out->{powerSupplyName} || 'Unknown PSU';
2635 $state = get_hashval($out->{powerSupplyState}, \%ps_state) || 'Unknown state';
2636 $status = get_snmp_status($out->{powerSupplyComponentStatus});
2637 $encl_id = $snmp_enclosure{$out->{powerSupplyConnectionEnclosureNumber}}{nexus};
2638 $encl_name = $out->{powerSupplyConnectionEnclosureName} || 'Unknown enclosure';
2639 $nexus = convert_nexus(($out->{powerSupplyNexusID} || 9999));
2642 $name = get_nonempty_string('Name', $out, 'Unknown PSU');
2643 $state = get_nonempty_string('State', $out, 'Unknown state');
2644 $status = get_nonempty_string('Status', $out, 'Unknown');
2645 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2646 $encl_name = $out->{encl_name};
2647 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2650 next PS if blacklisted('encl_ps', $nexus);
2653 if ($status ne 'Ok') {
2654 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2655 $name, $encl_id, $encl_name, $state;
2656 report('storage', $msg, $status2nagios{$status}, $nexus);
2660 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2661 $name, $encl_id, $encl_name, $state;
2662 report('storage', $msg, $E_OK, $nexus);
2669 #-----------------------------------------
2670 # STORAGE: Check enclosure temperatures
2671 #-----------------------------------------
2672 sub check_enclosure_temp {
2673 return if $#controllers == -1;
2679 my $reading = undef;
2681 my $max_warn = undef;
2682 my $max_crit = undef;
2683 my $min_warn = undef;
2684 my $min_crit = undef;
2685 my $encl_id = undef;
2686 my $encl_name = undef;
2692 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2693 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2694 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2695 '1.3.6.1.4.1.674.10893.1.20.130.11.1.7' => 'temperatureProbeMinWarning',
2696 '1.3.6.1.4.1.674.10893.1.20.130.11.1.8' => 'temperatureProbeMinCritical',
2697 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2698 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2699 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2700 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2701 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2702 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2703 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2706 if ($opt{use_get_table}) {
2707 my $temperatureProbeTable = '1.3.6.1.4.1.674.10893.1.20.130.11';
2708 my $temperatureConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.12';
2710 $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2711 my $ext = $snmp_session->get_table(-baseoid => $temperatureConnectionTable);
2713 if (defined $result) {
2714 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2718 $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2721 # No enclosure temperature probes is OK
2722 return if !defined $result;
2724 @output = @{ get_snmp_output($result, \%temp_oid) };
2727 foreach my $enc (@enclosures) {
2728 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2729 map_item('ctrl', $enc->{ctrl}, \@output);
2730 map_item('encl_id', $enc->{id}, \@output);
2731 map_item('encl_name', $enc->{name}, \@output);
2746 # Check temperature probes on each of the enclosures
2748 foreach my $out (@output) {
2750 $name = $out->{temperatureProbeName} || 'Unknown temp probe';
2751 $state = get_hashval($out->{temperatureProbeState}, \%temp_state) || 'Unknown state';
2752 $status = get_snmp_probestatus($out->{temperatureProbeComponentStatus});
2753 $unit = $out->{temperatureProbeUnit} || 'Unknown unit';
2754 $reading = $out->{temperatureProbeCurValue} || '[N/A]';
2755 $max_warn = $out->{temperatureProbeMaxWarning} || '[N/A]';
2756 $max_crit = $out->{temperatureProbeMaxCritical} || '[N/A]';
2757 $min_warn = $out->{temperatureProbeMinWarning} || '[N/A]';
2758 $min_crit = $out->{temperatureProbeMinCritical} || '[N/A]';
2759 $encl_id = $snmp_enclosure{$out->{temperatureConnectionEnclosureNumber}}{nexus};
2760 $encl_name = $out->{temperatureConnectionEnclosureName} || 'Unknown enclosure';
2761 $nexus = convert_nexus(($out->{temperatureProbeNexusID} || 9999));
2764 $name = get_nonempty_string('Name', $out, 'Unknown temp probe');
2765 $state = get_nonempty_string('State', $out, 'Unknown state');
2766 $status = get_nonempty_string('Status', $out, 'Unknown');
2768 $reading = get_nonempty_string('Reading', $out, '[N/A]');
2769 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
2770 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
2771 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
2772 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
2773 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2774 $encl_name = $out->{encl_name};
2775 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2778 next TEMP if blacklisted('encl_temp', $nexus);
2780 # Make sure these values are integers
2781 $reading =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $reading = '[N/A]';
2782 $max_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_warn = '[N/A]';
2783 $max_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $max_crit = '[N/A]';
2784 $min_warn =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_warn = '[N/A]';
2785 $min_crit =~ s{\A \s* (-?\d+) \s* C? \s* \z}{$1}xms or $min_crit = '[N/A]';
2787 # Convert temp units
2788 if ($opt{tempunit} ne 'C') {
2789 $reading = temp_from_celsius($reading, $opt{tempunit});
2790 $max_warn = temp_from_celsius($max_warn, $opt{tempunit});
2791 $max_crit = temp_from_celsius($max_crit, $opt{tempunit});
2792 $min_warn = temp_from_celsius($min_warn, $opt{tempunit});
2793 $min_crit = temp_from_celsius($min_crit, $opt{tempunit});
2796 # Inactive temp probes
2797 if ($status eq 'Unknown' and $state eq 'Inactive') {
2798 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2799 $name, $encl_id, $encl_name, $state;
2800 report('storage', $msg, $E_OK, $nexus);
2802 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2803 my $msg = sprintf '%s in enclosure %s [%s] is critically high at %d %s',
2804 $name, $encl_id, $encl_name, $reading, $opt{tempunit};
2805 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2806 report('chassis', $msg, $err, $nexus);
2808 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2809 my $msg = sprintf '%s in enclosure %s [%s] is too high at %d %s',
2810 $name, $encl_id, $encl_name, $reading, $opt{tempunit};
2811 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2812 report('chassis', $msg, $err, $nexus);
2814 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2815 my $msg = sprintf '%s in enclosure %s [%s] is critically low at %d %s',
2816 $name, $encl_id, $encl_name, $reading, $opt{tempunit};
2817 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2818 report('chassis', $msg, $err, $nexus);
2820 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2821 my $msg = sprintf '%s in enclosure %s [%s] is too low at %d %s',
2822 $name, $encl_id, $encl_name, $reading, $opt{tempunit};
2823 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2824 report('chassis', $msg, $err, $nexus);
2827 elsif ($status ne 'Ok') {
2828 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2829 $name, $encl_id, $encl_name, $state;
2830 if (defined $reading && $reading =~ m{\A -?\d+ \z}xms) {
2831 # take into account that with certain states the
2832 # reading doesn't exist or is not an integer
2833 $msg .= sprintf ' at %s %s', $reading, $opt{tempunit};
2834 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2835 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2838 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2839 $min_warn, $min_crit, $max_warn, $max_crit;
2842 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2843 report('storage', $msg, $err, $nexus);
2847 my $msg = sprintf '%s in enclosure %s [%s]',
2848 $name, $encl_id, $encl_name;
2849 if (defined $reading && $reading ne '[N/A]') {
2850 # take into account that with certain states the
2851 # reading doesn't exist or is not an integer
2852 $msg .= sprintf ' reads %d %s', $reading, $opt{tempunit};
2853 if ($min_warn eq '[N/A]' or $min_crit eq '[N/A]') {
2854 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2857 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2858 $min_warn, $min_crit, $max_warn, $max_crit;
2862 $msg .= sprintf ' is %s', $state;
2864 report('storage', $msg, $E_OK, $nexus);
2867 # Collect performance data
2868 if (defined $opt{perfdata} && $reading ne '[N/A]') {
2870 $index =~ s{\A Temperature\sProbe\s(\d+) \z}{$1}gxms;
2873 id => $opt{perfdata} eq 'minimal' ? "${encl_id}_t${index}" : "${encl_id}_temp_${index}",
2874 unit => $opt{tempunit},
2886 #-----------------------------------------
2887 # STORAGE: Check enclosure management modules (EMM)
2888 #-----------------------------------------
2889 sub check_enclosure_emms {
2890 return if $#controllers == -1;
2896 my $encl_id = undef;
2897 my $encl_name = undef;
2903 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2904 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2905 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2906 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2907 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2908 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2911 if ($opt{use_get_table}) {
2912 my $enclosureManagementModuleTable = '1.3.6.1.4.1.674.10893.1.20.130.13';
2913 my $enclosureManagementModuleConnectionTable = '1.3.6.1.4.1.674.10893.1.20.130.14';
2915 $result = $snmp_session->get_table(-baseoid => $enclosureManagementModuleTable);
2916 my $ext = $snmp_session->get_table(-baseoid => $enclosureManagementModuleConnectionTable);
2918 if (defined $result) {
2919 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
2923 $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2926 # No enclosure EMMs is OK
2927 return if !defined $result;
2929 @output = @{ get_snmp_output($result, \%emms_oid) };
2932 foreach my $enc (@enclosures) {
2933 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2934 map_item('ctrl', $enc->{ctrl}, \@output);
2935 map_item('encl_id', $enc->{id}, \@output);
2936 map_item('encl_name', $enc->{name}, \@output);
2947 5 => 'Not Installed',
2952 # Check EMMs on each of the enclosures
2954 foreach my $out (@output) {
2956 $name = $out->{enclosureManagementModuleName} || 'Unknown EMM';
2957 $state = get_hashval($out->{enclosureManagementModuleState}, \%emms_state) || 'Unknown state';
2958 $status = get_snmp_status($out->{enclosureManagementModuleComponentStatus});
2959 $encl_id = $snmp_enclosure{$out->{enclosureManagementModuleConnectionEnclosureNumber}}{nexus};
2960 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName} || 'Unknown enclosure';
2961 $nexus = convert_nexus(($out->{enclosureManagementModuleNexusID} || 9999));
2964 $name = get_nonempty_string('Name', $out, 'Unknown EMM');
2965 $state = get_nonempty_string('State', $out, 'Unknown state');
2966 $status = get_nonempty_string('Status', $out, 'Unknown');
2967 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2968 $encl_name = $out->{encl_name};
2969 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, get_nonempty_string('ID', $out, '9999');
2972 next EMM if blacklisted('encl_emm', $nexus);
2975 if ($status =~ m{\A Other|Unknown \z}xms and $state eq 'Not Installed') {
2976 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2977 $name, $encl_id, $encl_name, $state;
2978 report('storage', $msg, $E_OK, $nexus);
2981 elsif ($status ne 'Ok') {
2982 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2983 $name, $encl_id, $encl_name, $state;
2984 report('storage', $msg, $status2nagios{$status}, $nexus);
2988 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2989 $name, $encl_id, $encl_name, $state;
2990 report('storage', $msg, $E_OK, $nexus);
2997 #-----------------------------------------
2998 # CHASSIS: Check memory modules
2999 #-----------------------------------------
3003 my $location = undef;
3012 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
3013 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
3014 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
3015 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
3016 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
3019 if ($opt{use_get_table}) {
3020 my $memoryDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.50.1';
3021 $result = $snmp_session->get_table(-baseoid => $memoryDeviceTable);
3024 $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
3027 if (!defined $result) {
3028 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
3029 $snmp_session->close;
3033 @output = @{ get_snmp_output($result, \%dimm_oid) };
3036 @output = @{ run_omreport("$omopt_chassis memory") };
3039 # Note: These values are bit masks, so combination values are
3040 # possible. If value is 0 (zero), memory device has no faults.
3043 1 => 'ECC single bit correction warning rate exceeded',
3044 2 => 'ECC single bit correction failure rate exceeded',
3045 4 => 'ECC multibit fault encountered',
3046 8 => 'ECC single bit correction logging disabled',
3047 16 => 'device disabled because of spare activation',
3051 foreach my $out (@output) {
3052 @failures = (); # Initialize
3054 $index = ($out->{memoryDeviceIndex} || 10000) - 1;
3055 $status = get_snmp_status($out->{memoryDeviceStatus});
3056 $location = $out->{memoryDeviceLocationName} || 'Unknown location';
3057 $size = sprintf '%d MB', ($out->{memoryDeviceSize} || 0)/1024;
3058 $modes = $out->{memoryDeviceFailureModes} || -9999;
3060 foreach my $mask (sort keys %failure_mode) {
3061 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
3064 elsif ($modes == -9999) {
3065 push @failures, q{ERROR: Failure modes not available via SNMP};
3069 my $type = get_nonempty_string('Type', $out, q{});
3070 $index = $type eq '[Not Occupied]' ? undef : get_nonempty_string('Index', $out, 9999);
3071 $status = get_nonempty_string('Status', $out, 'Unknown');
3072 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
3073 $size = get_nonempty_string('Size', $out, 0);
3074 if (defined $size) {
3075 $size =~ s{\s\s}{ }gxms;
3077 # Run 'omreport chassis memory index=X' to get the failures
3078 if ($status ne 'Ok' && defined $index) {
3079 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
3080 if (m/\A Failures; (.+?) \z/xms) {
3081 chop(my $fail = $1);
3082 push @failures, split m{\.}xms, $fail;
3087 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
3089 # calculate total memory
3090 my $msize = defined $size ? $size : 0;
3091 $msize =~ s{\A (\d+) \s MB}{$1}xms;
3092 $count{mem} += $msize;
3094 # Ignore empty memory slots
3095 next DIMM if !defined $index;
3098 next DIMM if blacklisted('dimm', $index);
3100 if ($status ne 'Ok') {
3102 if (scalar @failures == 0) {
3103 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
3104 $index, $location, $size, $status;
3107 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
3108 $index, $location, $size, (join q{, }, @failures);
3111 report('chassis', $msg, $status2nagios{$status}, $index);
3115 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
3116 $index, $location, $size, $status;
3117 report('chassis', $msg, $E_OK, $index);
3124 #-----------------------------------------
3125 # CHASSIS: Check fans
3126 #-----------------------------------------
3130 my $reading = undef;
3131 my $location = undef;
3132 my $max_crit = undef;
3133 my $max_warn = undef;
3139 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
3140 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
3141 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
3142 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
3143 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
3144 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
3147 if ($opt{use_get_table}) {
3148 my $coolingDeviceTable = '1.3.6.1.4.1.674.10892.1.700.12.1';
3149 $result = $snmp_session->get_table(-baseoid => $coolingDeviceTable);
3152 $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
3155 if ($blade && !defined $result) {
3158 elsif (!$blade && !defined $result) {
3159 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
3160 $snmp_session->close;
3164 @output = @{ get_snmp_output($result, \%cool_oid) };
3167 @output = @{ run_omreport("$omopt_chassis fans") };
3171 foreach my $out (@output) {
3173 $index = ($out->{coolingDeviceIndex} || 10000) - 1;
3174 $status = get_snmp_probestatus($out->{coolingDeviceStatus});
3175 $reading = $out->{coolingDeviceReading} || 0;
3176 $location = $out->{coolingDeviceLocationName} || 'Unknown location';
3177 $max_crit = $out->{coolingDeviceUpperCriticalThreshold} || 0;
3178 $max_warn = $out->{coolingDeviceUpperNonCriticalThreshold} || 0;
3181 $index = get_nonempty_string('Index', $out, 9999);
3182 $status = get_nonempty_string('Status', $out, 'Unknown');
3183 $reading = get_nonempty_string('Reading', $out, 0);
3184 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3185 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, 0);
3186 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, 0);
3187 if ($max_crit eq '[N/A]') { $max_crit = 0; }
3188 if ($max_warn eq '[N/A]') { $max_warn = 0; }
3189 $reading =~ s{\A (\d+).* \z}{$1}xms;
3190 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
3191 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
3195 next FAN if blacklisted('fan', $index);
3198 my $msg = sprintf 'Chassis fan %d [%s] reading: %s RPM',
3199 $index, $location, $reading;
3200 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3201 report('chassis', $msg, $err, $index);
3203 # Collect performance data
3204 if (defined $opt{perfdata}) {
3205 my $pname = $location;
3206 $pname =~ s{\s}{_}gxms;
3207 $pname =~ s{proc_}{cpu#}xms;
3208 $pname =~ s{_rpm\z}{}ixms;
3224 #-----------------------------------------
3225 # CHASSIS: Check power supplies
3226 #-----------------------------------------
3227 sub check_powersupplies {
3231 my $err_type = undef;
3239 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
3240 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
3241 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
3242 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
3243 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
3246 if ($opt{use_get_table}) {
3247 my $powerDeviceTable = '1.3.6.1.4.1.674.10892.1.600.12.1';
3248 $result = $snmp_session->get_table(-baseoid => $powerDeviceTable);
3251 $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
3254 # No instrumented PSU is OK (blades, low-end servers)
3255 return 0 if !defined $result;
3257 @output = @{ get_snmp_output($result, \%ps_oid) };
3260 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
3270 6 => 'Uninterruptible Power Supply',
3280 1 => 'Presence detected',
3281 2 => 'Failure detected',
3282 4 => 'Predictive Failure',
3284 16 => 'AC lost or out-of-range',
3285 32 => 'AC out-of-range but present',
3286 64 => 'Configuration error',
3289 my %ps_config_error_type
3291 1 => 'Vendor mismatch',
3292 2 => 'Revision mismatch',
3293 3 => 'Processor missing',
3297 foreach my $out (@output) {
3299 @states = (); # contains states for the PS
3301 $index = ($out->{powerSupplyIndex} || 10000) - 1;
3302 $status = get_snmp_status($out->{powerSupplyStatus});
3303 $type = get_hashval($out->{powerSupplyType}, \%ps_type) || 'Unknown type';
3304 $err_type = get_hashval($out->{powerSupplyConfigurationErrorType}, \%ps_config_error_type);
3306 # get the combined state from the StatusReading OID
3307 my $raw_state = $out->{powerSupplySensorState} || 0;
3308 foreach my $mask (sort keys %ps_state) {
3309 if (($raw_state & $mask) != 0) {
3310 push @states, $ps_state{$mask};
3314 # If configuration error, also include the error type
3315 if (defined $err_type) {
3316 push @states, $err_type;
3319 # Finally, construct the state string
3320 $state = join q{, }, @states;
3323 $index = get_nonempty_string('Index', $out, 9999);
3324 $status = get_nonempty_string('Status', $out, 'Unknown');
3325 $type = get_nonempty_string('Type', $out, 'Unknown type');
3326 $state = get_nonempty_string('Online Status', $out, 'Unknown state');
3330 next PS if blacklisted('ps', $index);
3332 if ($status ne 'Ok') {
3333 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
3334 $index, $type, $state;
3335 report('chassis', $msg, $status2nagios{$status}, $index);
3338 my $msg = sprintf 'Power Supply %d [%s]: %s',
3339 $index, $type, $state;
3340 report('chassis', $msg, $E_OK, $index);
3347 #-----------------------------------------
3348 # CHASSIS: Check temperatures
3349 #-----------------------------------------
3350 sub check_temperatures {
3353 my $reading = undef;
3354 my $location = undef;
3355 my $max_crit = undef;
3356 my $max_warn = undef;
3357 my $min_warn = undef;
3358 my $min_crit = undef;
3360 my $discrete = undef;
3363 # Getting custom temperature thresholds (user option)
3364 my %warn_threshold = %{ custom_temperature_thresholds('w') };
3365 my %crit_threshold = %{ custom_temperature_thresholds('c') };
3370 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
3371 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
3372 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
3373 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
3374 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
3375 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
3376 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
3377 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
3378 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
3379 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
3381 # this didn't work well for some reason
3382 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
3384 # Getting values using the table
3385 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
3386 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
3388 if (!defined $result) {
3389 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
3390 $snmp_session->close;
3394 @output = @{ get_snmp_output($result, \%temp_oid) };
3397 @output = @{ run_omreport("$omopt_chassis temps") };
3402 1 => 'Other', # type is other than following values
3403 2 => 'Unknown', # type is unknown
3404 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
3405 16 => 'Discrete', # type is temperature probe with discrete reading
3409 foreach my $out (@output) {
3411 $index = ($out->{temperatureProbeIndex} || 10000) - 1;
3412 $status = get_snmp_probestatus($out->{temperatureProbeStatus});
3413 $location = $out->{temperatureProbeLocationName} || 'Unknown location';
3414 $type = get_hashval($out->{temperatureProbeType}, \%probe_type);
3415 $reading = $out->{temperatureProbeReading} || '[N/A]';
3416 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} || '[N/A]';
3417 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} || '[N/A]';
3418 $min_crit = $out->{temperatureProbeLowerCriticalThreshold} || '[N/A]';
3419 $min_warn = $out->{temperatureProbeLowerNonCriticalThreshold} || '[N/A]';
3420 $discrete = $out->{temperatureProbeDiscreteReading} || '[N/A]';
3422 # If numeric values, i.e. not discrete
3423 $reading /= 10 if $reading =~ m{\A \d+ \z}xms;
3424 $max_crit /= 10 if $max_crit =~ m{\A \d+ \z}xms;
3425 $max_warn /= 10 if $max_warn =~ m{\A \d+ \z}xms;
3426 $min_crit /= 10 if $min_crit =~ m{\A \d+ \z}xms;
3427 $min_warn /= 10 if $min_warn =~ m{\A \d+ \z}xms;
3429 # workaround for bad temp probes
3430 if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
3435 $index = get_nonempty_string('Index', $out, 9999);
3436 $status = get_nonempty_string('Status', $out, 'Unknown');
3437 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3438 $reading = get_nonempty_string('Reading', $out, '[N/A]');
3439 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, '[N/A]');
3440 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, '[N/A]');
3441 $min_crit = get_nonempty_string('Minimum Failure Threshold', $out, '[N/A]');
3442 $min_warn = get_nonempty_string('Minimum Warning Threshold', $out, '[N/A]');
3444 # Cleaning the temp readings
3445 $reading =~ s{\.0\s+C}{}xms;
3446 $max_crit =~ s{\.0\s+C}{}xms;
3447 $max_warn =~ s{\.0\s+C}{}xms;
3448 $min_crit =~ s{\.0\s+C}{}xms;
3449 $min_warn =~ s{\.0\s+C}{}xms;
3451 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
3452 $discrete = $reading;
3456 next TEMP if blacklisted('temp', $index);
3458 # Convert temp units
3459 if ($opt{tempunit} ne 'C') {
3460 $reading = temp_from_celsius($reading, $opt{tempunit});
3461 $max_warn = temp_from_celsius($max_warn, $opt{tempunit});
3462 $max_crit = temp_from_celsius($max_crit, $opt{tempunit});
3463 $min_warn = temp_from_celsius($min_warn, $opt{tempunit});
3464 $min_crit = temp_from_celsius($min_crit, $opt{tempunit});
3467 if ($type eq 'Discrete') {
3468 my $msg = sprintf 'Temperature probe %d [%s] is %s',
3469 $index, $location, $discrete;
3470 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3471 report('chassis', $msg, $err, $index);
3474 # First check according to custom thresholds
3475 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
3476 # Custom critical MAX
3477 my $msg = sprintf 'Temperature Probe %d [%s] reads %d %s (custom max=%d)',
3478 $index, $location, $reading, $opt{tempunit}, $crit_threshold{$index}{max};
3479 report('chassis', $msg, $E_CRITICAL, $index);
3481 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
3482 # Custom warning MAX
3483 my $msg = sprintf 'Temperature Probe %d [%s] reads %d %s (custom max=%d)',
3484 $index, $location, $reading, $opt{tempunit}, $warn_threshold{$index}{max};
3485 report('chassis', $msg, $E_WARNING, $index);
3487 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
3488 # Custom critical MIN
3489 my $msg = sprintf 'Temperature Probe %d [%s] reads %d %s (custom min=%d)',
3490 $index, $location, $reading, $opt{tempunit}, $crit_threshold{$index}{min};
3491 report('chassis', $msg, $E_CRITICAL, $index);
3493 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
3494 # Custom warning MIN
3495 my $msg = sprintf 'Temperature Probe %d [%s] reads %d %s (custom min=%d)',
3496 $index, $location, $reading, $opt{tempunit}, $warn_threshold{$index}{min};
3497 report('chassis', $msg, $E_WARNING, $index);
3499 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
3500 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d %s',
3501 $index, $location, $reading, $opt{tempunit};
3502 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3503 report('chassis', $msg, $err, $index);
3505 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
3506 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d %s',
3507 $index, $location, $reading, $opt{tempunit};
3508 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3509 report('chassis', $msg, $err, $index);
3511 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
3512 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d %s',
3513 $index, $location, $reading, $opt{tempunit};
3514 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3515 report('chassis', $msg, $err, $index);
3517 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
3518 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d %s',
3519 $index, $location, $reading, $opt{tempunit};
3520 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3521 report('chassis', $msg, $err, $index);
3525 my $msg = sprintf 'Temperature Probe %d [%s] reads %d %s',
3526 $index, $location, $reading, $opt{tempunit};
3527 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
3528 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
3531 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
3532 $min_warn, $min_crit, $max_warn, $max_crit;
3534 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3535 report('chassis', $msg, $err, $index);
3538 # Collect performance data
3539 if (defined $opt{perfdata}) {
3540 my $pname = $location;
3541 $pname =~ s{\s}{_}gxms;
3542 $pname =~ s{_temp\z}{}xms;
3543 $pname =~ s{proc_}{cpu#}xms;
3547 unit => $opt{tempunit},
3560 #-----------------------------------------
3561 # CHASSIS: Check processors
3562 #-----------------------------------------
3563 sub check_processors {
3575 # NOTE: For some reason, older models don't have the
3576 # "Processor Device Status" OIDs. We check both the newer
3577 # (preferred) OIDs and the old ones.
3581 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
3582 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
3583 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
3584 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
3585 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
3586 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
3587 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
3588 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
3589 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
3590 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
3593 if ($opt{use_get_table}) {
3594 my $processorDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.30.1';
3595 my $processorDeviceStatusTable = '1.3.6.1.4.1.674.10892.1.1100.32.1';
3597 $result = $snmp_session->get_table(-baseoid => $processorDeviceTable);
3598 my $ext = $snmp_session->get_table(-baseoid => $processorDeviceStatusTable);
3600 defined $ext && map { $$result{$_} = $$ext{$_} } keys %{ $ext };
3603 $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
3606 if (!defined $result) {
3607 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
3608 $snmp_session->close;
3612 @output = @{ get_snmp_output($result, \%cpu_oid) };
3615 @output = @{ run_omreport("$omopt_chassis processors") };
3620 1 => 'Other', # other than following values
3621 2 => 'Unknown', # unknown
3622 3 => 'Enabled', # enabled
3623 4 => 'User Disabled', # disabled by user via BIOS setup
3624 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
3630 1 => 'Internal Error', # Internal Error
3631 2 => 'Thermal Trip', # Thermal Trip
3632 32 => 'Configuration Error', # Configuration Error
3633 128 => 'Present', # Processor Present
3634 256 => 'Disabled', # Processor Disabled
3635 512 => 'Terminator Present', # Terminator Present
3636 1024 => 'Throttled', # Processor Throttled
3639 # Mapping between family numbers from SNMP and actual CPU family
3642 1 => 'Other', 2 => 'Unknown',
3643 3 => '8086', 4 => '80286',
3644 5 => '386', 6 => '486',
3645 7 => '8087', 8 => '80287',
3646 9 => '80387', 10 => '80487',
3647 11 => 'Pentium', 12 => 'Pentium Pro',
3648 13 => 'Pentium II', 14 => 'Pentium with MMX',
3649 15 => 'Celeron', 16 => 'Pentium II Xeon',
3650 17 => 'Pentium III', 18 => 'Pentium III Xeon',
3651 19 => 'Pentium III', 20 => 'Itanium',
3652 21 => 'Xeon', 22 => 'Pentium 4',
3653 23 => 'Xeon MP', 24 => 'Itanium 2',
3654 25 => 'K5', 26 => 'K6',
3655 27 => 'K6-2', 28 => 'K6-3',
3656 29 => 'Athlon', 30 => 'AMD2900',
3657 31 => 'K6-2+', 32 => 'Power PC',
3658 33 => 'Power PC 601', 34 => 'Power PC 603',
3659 35 => 'Power PC 603+', 36 => 'Power PC 604',
3660 37 => 'Power PC 620', 38 => 'Power PC x704',
3661 39 => 'Power PC 750', 40 => 'Core Duo',
3662 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
3663 43 => 'Intel Atom', 44 => undef,
3664 45 => undef, 46 => undef,
3665 47 => undef, 48 => 'Alpha',
3666 49 => 'Alpha 21064', 50 => 'Alpha 21066',
3667 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
3668 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
3669 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
3670 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
3671 59 => 'Opteron 6100', 60 => 'Opteron 4100',
3672 61 => undef, 62 => undef,
3673 63 => undef, 64 => 'MIPS',
3674 65 => 'MIPS R4000', 66 => 'MIPS R4200',
3675 67 => 'MIPS R4400', 68 => 'MIPS R4600',
3676 69 => 'MIPS R10000', 70 => undef,
3677 71 => undef, 72 => undef,
3678 73 => undef, 74 => undef,
3679 75 => undef, 76 => undef,
3680 77 => undef, 78 => undef,
3681 79 => undef, 80 => 'SPARC',
3682 81 => 'SuperSPARC', 82 => 'microSPARC II',
3683 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
3684 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
3685 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
3686 89 => undef, 90 => undef,
3687 91 => undef, 92 => undef,
3688 93 => undef, 94 => undef,
3689 95 => undef, 96 => '68040',
3690 97 => '68xxx', 98 => '68000',
3691 99 => '68010', 100 => '68020',
3692 101 => '68030', 102 => undef,
3693 103 => undef, 104 => undef,
3694 105 => undef, 106 => undef,
3695 107 => undef, 108 => undef,
3696 109 => undef, 110 => undef,
3697 111 => undef, 112 => 'Hobbit',
3698 113 => undef, 114 => undef,
3699 115 => undef, 116 => undef,
3700 117 => undef, 118 => undef,
3701 119 => undef, 120 => 'Crusoe TM5000',
3702 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
3703 123 => undef, 124 => undef,
3704 125 => undef, 126 => undef,
3705 127 => undef, 128 => 'Weitek',
3706 129 => undef, 130 => 'Celeron M',
3707 131 => 'Athlon 64', 132 => 'Opteron',
3708 133 => 'Sempron', 134 => 'Turion 64 Mobile',
3709 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
3710 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
3711 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
3712 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
3713 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
3714 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
3715 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
3716 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
3717 151 => undef, 152 => undef,
3718 153 => undef, 154 => undef,
3719 155 => undef, 156 => undef,
3720 157 => undef, 158 => undef,
3721 159 => undef, 160 => 'V30',
3722 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
3723 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
3724 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
3725 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
3726 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
3727 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
3728 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
3729 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
3730 177 => 'M2', 178 => undef,
3731 179 => 'Pentium 4 HT', 180 => 'AS400',
3732 181 => undef, 182 => 'Athlon XP',
3733 183 => 'Athlon MP', 184 => 'Duron',
3734 185 => 'Pentium M', 186 => 'Celeron D',
3735 187 => 'Pentium D', 188 => 'Pentium Extreme',
3736 189 => 'Core Solo', 190 => 'Core2',
3737 191 => 'Core2 Duo', 192 => 'Core2 Solo',
3738 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
3739 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
3740 197 => 'Core2 Solo mobile', 198 => 'Core i7',
3741 199 => 'Dual-Core Celeron', 200 => 'IBM390',
3742 201 => 'G4', 202 => 'G5',
3743 203 => 'ESA/390 G6', 204 => 'z/Architectur',
3744 205 => 'Core i5', 206 => 'Core i3',
3745 207 => undef, 208 => undef,
3746 209 => undef, 210 => 'C7-M',
3747 211 => 'C7-D', 212 => 'C7',
3748 213 => 'Eden', 214 => 'Multi-Core Xeon',
3749 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
3750 217 => 'VIA Nano', 218 => 'Dual-Core Xeon 5xxx',
3751 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
3752 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
3753 223 => 'Multi-Core Xeon 7xxx', 224 => 'Multi-Core Xeon 3400',
3754 225 => undef, 226 => undef,
3755 227 => undef, 228 => undef,
3756 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
3757 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
3758 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
3759 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
3760 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
3761 239 => 'AMD Sempron M', 240 => undef,
3762 241 => undef, 242 => undef,
3763 243 => undef, 244 => undef,
3764 245 => undef, 246 => undef,
3765 247 => undef, 248 => undef,
3766 249 => undef, 250 => 'i860',
3771 foreach my $out (@output) {
3773 $index = exists $out->{processorDeviceStatusIndex}
3774 ? ($out->{processorDeviceStatusIndex} || 10000) - 1
3775 : ($out->{processorDeviceIndex} || 10000) - 1;
3776 $status = exists $out->{processorDeviceStatusStatus}
3777 ? get_snmp_status($out->{processorDeviceStatusStatus})
3778 : get_snmp_status($out->{processorDeviceStatus});
3779 if (defined $out->{processorDeviceStatusReading}) {
3780 my @states = (); # contains states for the CPU
3782 # get the combined state from the StatusReading OID
3783 foreach my $mask (sort keys %cpu_reading) {
3784 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
3785 push @states, $cpu_reading{$mask};
3789 # Finally, create the state string
3790 $state = join q{, }, @states;
3793 $state = get_hashval($out->{processorDeviceStatusState}, \%cpu_state) || 'Unknown state';
3795 $man = $out->{processorDeviceManufacturerName} || undef;
3796 $family = (defined $out->{processorDeviceFamily}
3797 and defined $cpu_family{$out->{processorDeviceFamily}})
3798 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
3799 $speed = $out->{processorDeviceCurrentSpeed} || undef;
3800 $brand = $out->{processorDeviceBrandName} || undef;
3803 $index = get_nonempty_string('Index', $out, 9999);
3804 $status = get_nonempty_string('Status', $out, 'Unknown');
3805 $state = get_nonempty_string('State', $out, 'Unknown state');
3806 $brand = get_nonempty_string('Processor Brand', $out, undef);
3807 $family = get_nonempty_string('Processor Family', $out, undef);
3808 $man = get_nonempty_string('Processor Manufacturer', $out, undef);
3809 $speed = get_nonempty_string('Current Speed', $out, undef);
3812 # Ignore unoccupied CPU slots (omreport)
3813 next CPU if (defined $out->{'Processor Manufacturer'}
3814 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
3815 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
3817 # Ignore unoccupied CPU slots (snmp)
3818 if ($snmp and defined $out->{processorDeviceStatusReading}
3819 and $out->{processorDeviceStatusReading} == 0) {
3824 next CPU if blacklisted('cpu', $index);
3826 if (defined $brand) {
3827 $brand =~ s{\s\s+}{ }gxms;
3828 $brand =~ s{\((R|tm)\)}{}gxms;
3829 $brand =~ s{\s(CPU|Processor)}{}xms;
3830 $brand =~ s{\s\@}{}xms;
3832 elsif (defined $family and defined $man and defined $speed) {
3833 $speed =~ s{\A (\d+) .*}{$1}xms;
3834 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
3841 if ($status ne 'Ok') {
3842 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
3843 $index, $brand, $state;
3844 report('chassis', $msg, $status2nagios{$status}, $index);
3848 my $msg = sprintf 'Processor %d [%s] is %s',
3849 $index, $brand, $state;
3850 report('chassis', $msg, $E_OK, $index);
3857 #-----------------------------------------
3858 # CHASSIS: Check voltage probes
3859 #-----------------------------------------
3863 my $reading = undef;
3864 my $location = undef;
3865 my $max_crit = undef;
3866 my $max_warn = undef;
3872 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
3873 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
3874 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
3875 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
3876 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
3879 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
3880 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
3882 if (!defined $result) {
3883 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
3884 $snmp_session->close;
3888 @output = @{ get_snmp_output($result, \%volt_oid) };
3891 @output = @{ run_omreport("$omopt_chassis volts") };
3894 my %volt_discrete_reading
3901 foreach my $out (@output) {
3903 $index = ($out->{voltageProbeIndex} || 10000) - 1;
3904 $status = get_snmp_probestatus($out->{voltageProbeStatus});
3905 $reading = defined $out->{voltageProbeReading}
3906 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3907 : (get_hashval($out->{voltageProbeDiscreteReading}, \%volt_discrete_reading) || 'Unknown reading');
3908 $location = $out->{voltageProbeLocationName} || 'Unknown location';
3909 $max_crit = $out->{voltageProbeUpperCriticalThreshold} || 0;
3910 $max_warn = $out->{voltageProbeUpperNonCriticalThreshold} || 0;
3913 $index = get_nonempty_string('Index', $out, 9999);
3914 $status = get_nonempty_string('Status', $out, 'Unknown');
3915 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
3916 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
3917 $max_crit = get_nonempty_string('Maximum Failure Threshold', $out, 0);
3918 $max_warn = get_nonempty_string('Maximum Warning Threshold', $out, 0);
3920 $max_crit = 0 if $max_crit eq '[N/A]';
3921 $max_warn = 0 if $max_warn eq '[N/A]';
3925 next VOLT if blacklisted('volt', $index);
3927 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3928 $index, $location, $reading;
3929 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3930 report('chassis', $msg, $err, $index);
3932 # Collect performance data
3933 if (defined $opt{perfdata}) {
3934 $reading =~ s{\s+V\z}{}xms; # remove unit
3935 $reading =~ s{\.000\z}{}xms; # if integer
3936 next VOLT if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3937 my $label = join q{_}, $location;
3938 $label =~ s{\s}{_}gxms;
3954 #-----------------------------------------
3955 # CHASSIS: Check batteries
3956 #-----------------------------------------
3957 sub check_batteries {
3960 my $reading = undef;
3961 my $location = undef;
3967 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3968 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3969 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3970 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3973 if ($opt{use_get_table}) {
3974 my $batteryTable = '1.3.6.1.4.1.674.10892.1.600.50.1';
3975 $result = $snmp_session->get_table(-baseoid => $batteryTable);
3978 $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3981 # No batteries is OK
3982 return 0 if !defined $result;
3984 @output = @{ get_snmp_output($result, \%bat_oid) };
3987 @output = @{ run_omreport("$omopt_chassis batteries") };
3992 1 => 'Predictive Failure',
3994 4 => 'Presence Detected',
3998 foreach my $out (@output) {
4000 $index = ($out->{batteryIndex} || 10000) - 1;
4001 $status = get_snmp_status($out->{batteryStatus});
4002 $reading = get_hashval($out->{batteryReading}, \%bat_reading) || 'Unknown reading';
4003 $location = $out->{batteryLocationName} || 'Unknown location';
4006 $index = get_nonempty_string('Index', $out, 9999);
4007 $status = get_nonempty_string('Status', $out, 'Unknown');
4008 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
4009 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
4013 next BATTERY if blacklisted('bp', $index);
4015 my $msg = sprintf 'Battery probe %d [%s] is %s',
4016 $index, $location, $reading;
4017 report('chassis', $msg, $status2nagios{$status}, $index);
4023 #-----------------------------------------
4024 # CHASSIS: Check amperage probes (power monitoring)
4025 #-----------------------------------------
4026 sub check_pwrmonitoring {
4029 my $reading = undef;
4030 my $location = undef;
4031 my $max_crit = undef;
4032 my $max_warn = undef;
4040 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
4041 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
4042 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
4043 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
4044 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
4045 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
4046 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
4047 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
4050 if ($opt{use_get_table}) {
4051 my $amperageProbeTable = '1.3.6.1.4.1.674.10892.1.600.30.1';
4052 $result = $snmp_session->get_table(-baseoid => $amperageProbeTable);
4055 $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
4058 # No pwrmonitoring is OK
4059 return 0 if !defined $result;
4061 @output = @{ get_snmp_output($result, \%amp_oid) };
4064 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
4067 my %amp_type # Amperage probe types
4069 1 => 'amperageProbeTypeIsOther', # other than following values
4070 2 => 'amperageProbeTypeIsUnknown', # unknown
4071 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
4072 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
4073 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
4074 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
4075 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
4076 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
4077 9 => 'amperageProbeTypeIsIO', # I/O probe
4078 10 => 'amperageProbeTypeIsCore', # Core probe
4079 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
4080 12 => 'amperageProbeTypeIsBattery', # Battery probe
4081 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
4082 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
4083 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
4084 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
4085 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
4086 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
4087 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
4088 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
4099 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
4100 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
4101 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
4102 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
4103 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
4107 foreach my $out (@output) {
4109 $index = ($out->{amperageProbeIndex} || 10000) - 1;
4110 $status = get_snmp_probestatus($out->{amperageProbeStatus});
4111 $type = get_hashval($out->{amperageProbeType}, \%amp_type);
4112 $reading = $type eq 'amperageProbeTypeIsDiscrete'
4113 ? get_hashval($out->{amperageProbeDiscreteReading}, \%amp_discrete)
4114 : ($out->{amperageProbeReading} || 0);
4115 $location = $out->{amperageProbeLocationName} || 'Unknown location';
4116 $max_crit = $out->{amperageProbeUpperCriticalThreshold} || 0;
4117 $max_warn = $out->{amperageProbeUpperNonCriticalThreshold} || 0;
4118 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
4119 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
4121 # calculate proper values and set unit for ampere probes
4122 if ($unit eq 'hA' and $type ne 'amperageProbeTypeIsDiscrete') {
4130 $index = get_nonempty_string('Index', $out, 9999);
4131 $status = get_nonempty_string('Status', $out, 'Unknown');
4132 $reading = get_nonempty_string('Reading', $out, 'Unknown reading');
4133 $location = get_nonempty_string('Probe Name', $out, 'Unknown location');
4134 $max_crit = get_nonempty_string('Failure Threshold', $out, 0);
4135 $max_warn = get_nonempty_string('Warning Threshold', $out, 0);
4137 $max_crit = 0 if $max_crit eq '[N/A]';
4138 $max_warn = 0 if $max_warn eq '[N/A]';
4140 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
4141 $unit = $2 || 'unknown';
4142 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
4143 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
4146 next AMP if $index !~ m{\A \d+ \z}xms;
4148 # Special case: Probe is present but unknown. This happens via
4149 # SNMP on some systems where power monitoring capability is
4150 # disabled due to non-redundant and/or non-instrumented power
4152 # E.g. R410 with newer BMC firmware and 1 power supply
4153 if ($snmp && $status eq 'Unknown' && $reading == 0) {
4158 next AMP if blacklisted('amp', $index);
4160 # Special case: Discrete reading
4161 if (defined $type and $type eq 'amperageProbeTypeIsDiscrete') {
4162 my $msg = sprintf 'Amperage probe %d [%s] is %s',
4163 $index, $location, $reading;
4164 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
4165 report('chassis', $msg, $err, $index);
4169 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
4170 $index, $location, $reading, $unit;
4171 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
4172 report('chassis', $msg, $err, $index);
4175 # Collect performance data
4176 if (defined $opt{perfdata}) {
4177 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
4178 my $label = join q{_}, $location;
4179 $label =~ s{\s}{_}gxms;
4192 # Collect EXTRA performance data not found at first run. This is a
4194 if (defined $opt{perfdata} && !$snmp) {
4200 foreach (@perfdata) {
4201 if ($_->{label} =~ m/\A [WA](\d+)/xms) {
4207 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
4209 if ($line eq 'Location;Reading') {
4217 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s ([AW]) \z/xms) {
4221 $aname =~ s{\s}{_}gxms;
4223 # don't use an existing index
4224 while (exists $used{$index}) { ++$index; }
4244 #-----------------------------------------
4245 # CHASSIS: Check intrusion
4246 #-----------------------------------------
4247 sub check_intrusion {
4250 my $reading = undef;
4256 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
4257 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
4258 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
4261 if ($opt{use_get_table}) {
4262 my $intrusionTable = '1.3.6.1.4.1.674.10892.1.300.70.1';
4263 $result = $snmp_session->get_table(-baseoid => $intrusionTable);
4266 $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
4269 # No intrusion is OK
4270 return 0 if !defined $result;
4272 @output = @{ get_snmp_output($result, \%int_oid) };
4275 @output = @{ run_omreport("$omopt_chassis intrusion") };
4280 1 => 'Not Breached', # chassis not breached and no uncleared breaches
4281 2 => 'Breached', # chassis currently breached
4282 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
4283 4 => 'Breach Sensor Failure', # intrusion sensor has failed
4287 foreach my $out (@output) {
4289 $index = ($out->{intrusionIndex} || 10000) - 1;
4290 $status = get_snmp_status($out->{intrusionStatus});
4291 $reading = get_hashval($out->{intrusionReading}, \%int_reading) || 'Unknown reading';
4294 $index = get_nonempty_string('Index', $out, 9999);
4295 $status = get_nonempty_string('Status', $out, 'Unknown');
4296 $reading = get_nonempty_string('State', $out, 'Unknown reading');
4300 next INTRUSION if blacklisted('intr', $index);
4302 if ($status ne 'Ok') {
4303 my $msg = sprintf 'Chassis intrusion %d detected: %s',
4305 report('chassis', $msg, $E_WARNING, $index);
4309 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
4310 $index, $status, $reading;
4311 report('chassis', $msg, $E_OK, $index);
4318 #-----------------------------------------
4319 # CHASSIS: Check SD Card Device
4320 #-----------------------------------------
4325 my $location = undef;
4326 my $capacity = undef;
4327 my $setting = undef;
4333 '1.3.6.1.4.1.674.10892.1.1100.112.1.2.1' => 'sdCardDeviceIndex',
4334 '1.3.6.1.4.1.674.10892.1.1100.112.1.3.1' => 'sdCardDeviceStatus',
4335 '1.3.6.1.4.1.674.10892.1.1100.112.1.4.1' => 'sdCardDeviceType',
4336 '1.3.6.1.4.1.674.10892.1.1100.112.1.7.1' => 'sdCardDeviceLocationName',
4337 '1.3.6.1.4.1.674.10892.1.1100.112.1.8.1' => 'sdCardDeviceCardPresent',
4338 '1.3.6.1.4.1.674.10892.1.1100.112.1.9.1' => 'sdCardDeviceCardState',
4339 '1.3.6.1.4.1.674.10892.1.1100.112.1.10.1' => 'sdCardDeviceCardStorageSize',
4342 if ($opt{use_get_table}) {
4343 my $sdCardDeviceTable = '1.3.6.1.4.1.674.10892.1.1100.112.1';
4344 $result = $snmp_session->get_table(-baseoid => $sdCardDeviceTable);
4347 $result = $snmp_session->get_entries(-columns => [keys %sd_oid]);
4351 return 0 if !defined $result;
4353 @output = @{ get_snmp_output($result, \%sd_oid) };
4356 @output = @{ run_omreport("$omopt_chassis removableflashmedia") };
4359 # Note: These values are bit fields, so combination values are possible.
4362 0 => 'None', # state is none of the following:
4363 1 => 'Present', # device is present
4364 2 => 'IPMI-ready', # device is IPMI ready
4365 4 => 'Full-ready', # device is full ready
4366 8 => 'Offline', # device is offline
4367 16 => 'Failed', # device is failed
4368 32 => 'Active', # device is active
4369 64 => 'Bootable', # device is bootable
4370 128 => 'Write-protected', # device is write-protected
4371 256 => 'Standby', # device is in standby mode
4376 foreach my $out (@output) {
4378 $index = ($out->{sdCardDeviceIndex} || 10000) - 1;
4379 $status = get_snmp_status($out->{sdCardDeviceStatus});
4381 if (defined $out->{sdCardDeviceCardState}) {
4382 my @states = (); # contains states SD card
4384 # get the combined state from the Device Status OID
4385 foreach my $mask (sort keys %sd_state) {
4386 if (($out->{sdCardDeviceCardState} & $mask) != 0) {
4387 push @states, $sd_state{$mask};
4391 # Finally, create the state string
4392 $state = join q{, }, @states;
4394 # special case: absent
4395 if ($out->{sdCardDeviceCardState} % 2 == 0) {
4400 $location = $out->{sdCardDeviceLocationName} || 'Unknown location';
4401 $capacity = sprintf '%s MB', ($out->{sdCardDeviceCardStorageSize} || 'Unknown size');
4405 $status = get_nonempty_string('Status', $out, 'Ok');
4406 $state = get_nonempty_string('State', $out, 'Unknown state');
4407 $location = get_nonempty_string('Connector Name', $out, 'Unknown location');
4408 $capacity = get_nonempty_string('Storage Size', $out, 'Unknown size');
4410 $capacity =~ s{\[Not Available\]}{Unknown Size};
4413 $count{sd}++ if $state ne 'Absent';
4414 next SDCARD if blacklisted('sd', $index);
4416 if ($status ne 'Ok') {
4417 my $msg = sprintf 'SD Card %d needs attention: %s',
4419 report('chassis', $msg, $E_WARNING, $index);
4421 # Special case: Not Present
4422 elsif ($status eq 'Ok' and $state eq 'Absent') {
4423 my $msg = sprintf 'SD Card %d [%s] is %s',
4424 $index, $location, $state;
4425 report('chassis', $msg, $E_OK, $index);
4429 my $msg = sprintf 'SD Card %d [%s, %s] is %s',
4430 $index, $location, $capacity, $state;
4431 report('chassis', $msg, $E_OK, $index);
4438 #-----------------------------------------
4439 # CHASSIS: Check alert log
4440 #-----------------------------------------
4441 sub check_alertlog {
4442 return if $snmp; # Not supported with SNMP
4444 my @output = @{ run_omreport("$omopt_system alertlog") };
4445 foreach my $out (@output) {
4446 ++$count{alert}{$out->{Severity}};
4449 # Create error messages and set exit value if appropriate
4451 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
4452 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4454 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
4455 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
4456 report('other', $msg, $err);
4461 #-----------------------------------------
4462 # CHASSIS: Check ESM log overall health
4463 #-----------------------------------------
4464 sub check_esmlog_health {
4468 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
4469 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
4470 if (!defined $result) {
4471 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
4472 $snmp_session->error;
4473 report('other', $msg, $E_UNKNOWN);
4475 $health = get_snmp_status($result->{$systemStateEventLogStatus});
4478 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
4479 if (m/\A Health;(.+) \z/xms) {
4487 # If the overall health of the ESM log is other than "Ok", the
4488 # fill grade of the log is more than 80% and the log should be
4490 if ($health eq 'Ok') {
4491 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
4492 report('other', $msg, $E_OK);
4494 elsif ($health eq 'Critical') {
4495 my $msg = sprintf 'ESM log is 100%% full';
4496 report('other', $msg, $status2nagios{$health});
4499 my $msg = sprintf 'ESM log is more than 80%% full';
4500 report('other', $msg, $status2nagios{$health});
4506 #-----------------------------------------
4507 # CHASSIS: Check ESM log
4508 #-----------------------------------------
4515 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
4517 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
4520 return if !defined $result;
4522 @output = @{ get_snmp_output($result, \%esm_oid) };
4523 foreach my $out (@output) {
4524 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
4528 @output = @{ run_omreport("$omopt_system esmlog") };
4529 foreach my $out (@output) {
4530 ++$count{esm}{$out->{Severity}};
4534 # Create error messages and set exit value if appropriate
4536 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
4537 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
4539 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
4540 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
4541 report('other', $msg, $err);
4547 # Handy function for checking all storage components
4550 check_controllers();
4551 check_physical_disks();
4552 check_virtual_disks();
4553 check_cache_battery();
4556 check_enclosure_fans();
4557 check_enclosure_pwr();
4558 check_enclosure_temp();
4559 check_enclosure_emms();
4565 #---------------------------------------------------------------------
4567 #---------------------------------------------------------------------
4570 # Fetch output from 'omreport chassis info', put in sysinfo hash
4572 sub get_omreport_chassis_info {
4573 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
4574 my @lines = <$INFO>;
4577 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag|System\sRevision)/xms;
4578 my ($key, $val) = split /;/xms;
4579 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4580 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4581 if ($key eq 'Chassis Model' or $key eq 'Model') {
4582 $sysinfo{model} = $val;
4584 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
4585 $sysinfo{serial} = $val;
4587 if ($key eq 'System Revision') {
4588 $sysinfo{rev} = q{ } . $val;
4596 # Fetch output from 'omreport chassis bios', put in sysinfo hash
4598 sub get_omreport_chassis_bios {
4599 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
4600 my @lines = <$BIOS>;
4604 my ($key, $val) = split /;/xms;
4605 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4606 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4607 $sysinfo{bios} = $val if $key eq 'Version';
4608 $sysinfo{biosdate} = $val if $key eq 'Release Date';
4615 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
4617 sub get_omreport_system_operatingsystem {
4618 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
4623 my ($key, $val) = split /;/xms;
4624 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
4625 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
4626 if ($key eq 'Operating System') {
4627 $sysinfo{osname} = $val;
4629 elsif ($key eq 'Operating System Version') {
4630 $sysinfo{osver} = $val;
4638 # Fetch output from 'omreport about', put in sysinfo hash
4640 sub get_omreport_about {
4641 if (open my $OM, '-|', "$omreport about -fmt ssv") {
4645 if (m/\A Version;(.+) \z/xms) {
4655 # Fetch chassis info via SNMP, put in sysinfo hash
4657 sub get_snmp_chassis_info {
4660 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
4661 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
4662 '1.3.6.1.4.1.674.10892.1.300.10.1.48.1' => 'chassisSystemRevisionName',
4665 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
4666 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
4668 if (defined $result) {
4669 foreach my $oid (keys %{ $result }) {
4670 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
4671 $sysinfo{model} = $result->{$oid};
4672 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
4674 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
4675 $sysinfo{serial} = $result->{$oid};
4677 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisSystemRevisionName') {
4678 $sysinfo{rev} = q{ } . $result->{$oid};
4683 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
4684 $snmp_session->error;
4685 report('other', $msg, $E_UNKNOWN);
4691 # Fetch BIOS info via SNMP, put in sysinfo hash
4693 sub get_snmp_chassis_bios {
4696 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
4697 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
4700 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
4701 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
4703 if (defined $result) {
4704 foreach my $oid (keys %{ $result }) {
4705 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
4706 $sysinfo{biosdate} = $result->{$oid};
4707 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
4709 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
4710 $sysinfo{bios} = $result->{$oid};
4715 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
4716 $snmp_session->error;
4717 report('other', $msg, $E_UNKNOWN);
4723 # Fetch OS info via SNMP, put in sysinfo hash
4725 sub get_snmp_system_operatingsystem {
4728 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
4729 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
4732 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
4733 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
4735 if (defined $result) {
4736 foreach my $oid (keys %{ $result }) {
4737 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
4738 $sysinfo{osname} = ($result->{$oid});
4740 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
4741 $sysinfo{osver} = $result->{$oid};
4746 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
4747 $snmp_session->error;
4748 report('other', $msg, $E_UNKNOWN);
4754 # Fetch OMSA version via SNMP, put in sysinfo hash
4756 sub get_snmp_about {
4757 # systemManagementSoftwareGlobalVersionName
4758 my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
4759 my $result = $snmp_session->get_request(-varbindlist => [$oid]);
4761 if (defined $result) {
4762 $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
4763 ? $result->{$oid} : 'unknown';
4766 my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
4767 report('other', $msg, $E_UNKNOWN);
4773 # Collects some information about the system
4777 # Get system model and serial number
4778 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
4780 # Get BIOS information. Only if needed
4781 if ( $opt{okinfo} >= 1
4783 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
4784 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
4787 # Get OMSA information. Only if needed
4788 if ($opt{okinfo} >= 3 or $opt{debug}) {
4789 $snmp ? get_snmp_about() : get_omreport_about();
4792 # Return now if debug
4793 return if $opt{debug};
4795 # Get OS information. Only if needed
4796 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
4797 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
4804 # Helper function for running omreport when the results are strictly
4806 sub run_omreport_info {
4807 my $command = shift;
4811 # Run omreport and fetch output
4812 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
4814 # Parse output, store in array
4815 for ((split /\n/xms, $rawtext)) {
4816 if (m/\A Error/xms) {
4817 my $msg = "Problem running 'omreport $command': $_";
4818 report('other', $msg, $E_UNKNOWN);
4820 next if !m/;/xms; # ignore lines with less than two fields
4821 my @vals = split m/;/xms;
4822 $output{$vals[0]} = $vals[1];
4825 # Finally, return the collected information
4829 # Get various firmware information (BMC, RAC)
4830 sub get_firmware_info {
4831 my @snmp_output = ();
4832 my %nrpe_output = ();
4837 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
4838 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
4839 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
4842 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
4843 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
4845 # Some don't have this OID, this is ok
4846 if (!defined $result) {
4850 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
4853 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
4856 my %fw_type # Firmware types
4858 1 => 'other', # other than following values
4859 2 => 'unknown', # unknown
4860 3 => 'systemBIOS', # System BIOS
4861 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
4862 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
4863 6 => 'systemBackPlane', # System (Primary) Backplane
4864 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
4865 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
4866 9 => 'frontPanel', # Front Panel Controller
4867 10 => 'baseboardManagementController', # Baseboard Management Controller
4868 11 => 'hotPlugPCI', # Hot Plug PCI Controller
4869 12 => 'sensorData', # Sensor Data Records
4870 13 => 'peripheralBay', # Peripheral Bay Backplane
4871 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
4872 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
4873 16 => 'rac', # Remote Access Controller
4874 17 => 'iDRAC', # Integrated Dell Remote Access Controller
4875 19 => 'unifiedServerConfigurator', # Unified Server Configurator
4876 20 => 'lifecycleController', # Lifecycle Controller
4881 foreach my $out (@snmp_output) {
4882 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
4883 $sysinfo{'bmc'} = 1;
4884 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
4886 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|iDRAC \z}xms) {
4887 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
4888 $sysinfo{'rac'} = 1;
4889 $sysinfo{'rac_name'} = $name;
4890 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
4895 foreach my $key (keys %nrpe_output) {
4896 next if !defined $nrpe_output{$key};
4897 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
4898 $sysinfo{'bmc'} = 1;
4899 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
4901 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
4903 $sysinfo{'rac'} = 1;
4904 $sysinfo{'rac_fw'} = $nrpe_output{$key};
4905 $sysinfo{'rac_name'} = $name;
4915 #=====================================================================
4917 #=====================================================================
4919 # Here we do the actual checking of components
4920 # Check global status if applicable
4922 $globalstatus = check_global();
4925 # Do multiple selected checks
4926 if ($check{storage}) { check_storage(); }
4927 if ($check{memory}) { check_memory(); }
4928 if ($check{fans}) { check_fans(); }
4929 if ($check{power}) { check_powersupplies(); }
4930 if ($check{temp}) { check_temperatures(); }
4931 if ($check{cpu}) { check_processors(); }
4932 if ($check{voltage}) { check_volts(); }
4933 if ($check{batteries}) { check_batteries(); }
4934 if ($check{amperage}) { check_pwrmonitoring(); }
4935 if ($check{intrusion}) { check_intrusion(); }
4936 if ($check{sdcard}) { check_sdcard(); }
4937 if ($check{alertlog}) { check_alertlog(); }
4938 if ($check{esmlog}) { check_esmlog(); }
4939 if ($check{esmhealth}) { check_esmlog_health(); }
4942 #---------------------------------------------------------------------
4944 #---------------------------------------------------------------------
4955 # Get system information
4958 # Get firmware info if requested via option
4959 if ($opt{okinfo} >= 1) {
4960 get_firmware_info();
4963 # Close SNMP session
4965 $snmp_session->close;
4970 # finding the mode of operation
4973 # Setting the domain (IP version and transport protocol)
4974 my $transport = $opt{tcp} ? 'TCP' : 'UDP';
4975 my $ipversion = $opt{ipv6} ? 'IPv6' : 'IPv4';
4976 $mode = "SNMPv$opt{protocol} $transport/$ipversion";
4979 print " System: $sysinfo{model}$sysinfo{rev}";
4980 print q{ } x (25 - length "$sysinfo{model}$sysinfo{rev}"), "OMSA version: $sysinfo{om}\n";
4981 print " ServiceTag: $sysinfo{serial}";
4982 print q{ } x (25 - length $sysinfo{serial}), "Plugin version: $VERSION\n";
4983 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
4984 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Checking mode: $mode\n";
4985 if ($#report_storage >= 0) {
4986 print "-----------------------------------------------------------------------------\n";
4987 print " Storage Components \n";
4988 print "=============================================================================\n";
4989 print " STATE | ID | MESSAGE TEXT \n";
4990 print "---------+----------+--------------------------------------------------------\n";
4991 foreach (@report_storage) {
4992 my ($msg, $level, $nexus) = @{$_};
4993 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
4994 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
4995 $nagios_alert_count{$reverse_exitcode{$level}}++;
4998 if ($#report_chassis >= 0) {
4999 print "-----------------------------------------------------------------------------\n";
5000 print " Chassis Components \n";
5001 print "=============================================================================\n";
5002 print " STATE | ID | MESSAGE TEXT \n";
5003 print "---------+------+------------------------------------------------------------\n";
5004 foreach (@report_chassis) {
5005 my ($msg, $level, $nexus) = @{$_};
5006 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
5007 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
5008 $nagios_alert_count{$reverse_exitcode{$level}}++;
5011 if ($#report_other >= 0) {
5012 print "-----------------------------------------------------------------------------\n";
5013 print " Other messages \n";
5014 print "=============================================================================\n";
5015 print " STATE | MESSAGE TEXT \n";
5016 print "---------+-------------------------------------------------------------------\n";
5017 foreach (@report_other) {
5018 my ($msg, $level, $nexus) = @{$_};
5019 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
5020 $nagios_alert_count{$reverse_exitcode{$level}}++;
5025 my $c = 0; # counter to determine linebreaks
5027 # Run through each message, sorted by severity level
5029 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
5030 my ($msg, $level, $nexus) = @{ $_ };
5031 next ALERT if $level == $E_OK;
5033 if (defined $opt{only}) {
5034 # If user wants only critical alerts
5035 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
5037 # If user wants only warning alerts
5038 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
5041 # Prefix with service tag if specified with option '-i|--info'
5043 if (defined $opt{htmlinfo}) {
5044 $msg = '[<a href="' . warranty_url($sysinfo{serial})
5045 . "\">$sysinfo{serial}</a>] " . $msg;
5048 $msg = "[$sysinfo{serial}] " . $msg;
5052 # Prefix with nagios level if specified with option '--state'
5053 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
5055 # Prefix with one-letter nagios level if specified with option '--short-state'
5056 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
5058 ($c++ == 0) ? print $msg : print $linebreak, $msg;
5060 $nagios_alert_count{$reverse_exitcode{$level}}++;
5064 # Determine our exit code
5066 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
5067 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
5068 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
5070 # Global status via SNMP.. extra safety check
5071 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
5072 print "OOPS! Something is wrong with this server, but I don't know what. ";
5073 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
5074 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
5075 print "please file a bug report.\n";
5080 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
5082 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
5083 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
5084 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
5085 'memory' => "MEMORY OK - $count{dimm} memory modules, $count{mem} MB total memory",
5086 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
5087 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
5088 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
5089 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
5090 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
5091 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
5092 '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",
5093 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
5094 'esmhealth' => "ESM LOG OK - less than 80% used",
5095 'sdcard' => "SD CARDS OK - $count{sd} SD cards installed",
5098 print $okmsg{$opt{only}};
5100 # show blacklisted components
5101 if ($opt{show_blacklist} and %blacklist) {
5103 foreach (keys %blacklist) {
5104 push @blstr, "$_=" . join ',', @{ $blacklist{$_} };
5107 print "----- BLACKLISTED: " . join '/', @blstr;
5110 elsif ($exit_code == $E_OK && !$opt{debug}) {
5111 if (defined $opt{htmlinfo}) {
5112 printf q{OK - System: '<a href="%s">%s%s</a>', SN: '<a href="%s">%s</a>'},
5113 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
5114 warranty_url($sysinfo{serial}), $sysinfo{serial};
5117 printf q{OK - System: '%s%s', SN: '%s'},
5118 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
5121 if ($check{memory}) {
5123 if ($count{mem} >= 1024) {
5124 $count{mem} /= 1024;
5127 printf ', %d %s ram (%d dimms)', $count{mem}, $unit, $count{dimm};
5130 print ', not checking memory';
5133 if ($check{storage}) {
5134 printf ', %d logical drives, %d physical drives',
5135 $count{vdisk}, $count{pdisk};
5138 print ', not checking storage';
5141 # show blacklisted components
5142 if ($opt{show_blacklist} and %blacklist) {
5144 foreach (keys %blacklist) {
5145 push @blstr, "$_=" . join ',', @{ $blacklist{$_} };
5148 print "----- BLACKLISTED: " . join '/', @blstr;
5151 if ($opt{okinfo} >= 1) {
5153 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
5155 if ($sysinfo{rac}) {
5156 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
5158 if ($sysinfo{bmc}) {
5159 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
5163 if ($opt{okinfo} >= 2) {
5164 if ($check{storage}) {
5165 my @storageprint = ();
5166 foreach my $id (sort keys %{ $sysinfo{controller} }) {
5167 chomp $sysinfo{controller}{$id}{driver};
5168 my $msg = sprintf q{----- Ctrl %s [%s]: Fw='%s', Dr='%s'},
5169 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
5170 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
5171 if (defined $sysinfo{controller}{$id}{storport}) {
5172 $msg .= sprintf q{, Storport: '%s'}, $sysinfo{controller}{$id}{storport};
5174 push @storageprint, $msg;
5176 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
5177 push @storageprint, sprintf q{----- Encl %s [%s]: Fw='%s'},
5178 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
5179 $sysinfo{enclosure}{$id}->{firmware};
5183 foreach my $line (@storageprint) {
5184 print $linebreak, $line;
5189 if ($opt{okinfo} >= 3) {
5190 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
5195 if ($opt{extinfo}) {
5197 if (defined $opt{htmlinfo}) {
5198 printf '------ SYSTEM: <a href="%s">%s%s</a>, SN: <a href="%s">%s</a>',
5199 documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
5200 warranty_url($sysinfo{serial}), $sysinfo{serial};
5203 printf '------ SYSTEM: %s%s, SN: %s',
5204 $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
5207 if (defined $opt{postmsg}) {
5209 if (-f $opt{postmsg}) {
5210 open my $POST, '<', $opt{postmsg}
5211 or ( print $linebreak
5212 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
5213 and exit $E_UNKNOWN );
5219 $post = $opt{postmsg};
5221 if (defined $post) {
5223 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
5224 $post =~ s{[%]m}{$sysinfo{model}$sysinfo{rev}}gxms;
5225 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
5226 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
5227 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
5228 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
5229 $post =~ s{[%]p}{$count{pdisk}}gxms;
5230 $post =~ s{[%]l}{$count{vdisk}}gxms;
5231 $post =~ s{[%]n}{$linebreak}gxms;
5232 $post =~ s{[%]{2}}{%}gxms;
5238 # Reset the WARN signal
5239 $SIG{__WARN__} = 'DEFAULT';
5241 # Print any perl warnings that have occured
5242 if (@perl_warnings) {
5243 foreach (@perl_warnings) {
5245 print "${linebreak}INTERNAL ERROR: @$_";
5247 $exit_code = $E_UNKNOWN;
5250 # Print performance data
5251 if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
5252 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
5255 # Sort routine for performance data
5257 my %order = ( 'T' => 0, 'W' => 1, 'A' => 2, 'V' => 3, 'F' => 4, 'E' => 5, );
5259 # sort in this order:
5260 # 1. the type according to the hash "order" above
5261 # 2. the id (index) numerically
5262 # 3. the id (index) alphabetically
5264 return $order{$a->{type}} cmp $order{$b->{type}} ||
5265 ($a->{id} =~ m{\A\d+\z}xms and $a->{id} <=> $b->{id}) ||
5266 ($a->{id} !~ m{\A\d+\z}xms and $a->{id} cmp $b->{id}) ||
5267 $a->{label} cmp $b->{label};
5270 # Print performance data sorted
5271 if ($opt{perfdata} eq 'minimal') {
5272 print join $lb, map { "$_->{type}$_->{id}=$_->{value}$_->{unit};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
5275 print join $lb, map { "$_->{type}$_->{id}_$_->{label}=$_->{value}$_->{unit};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
5279 # Wrapping up and finishing
5281 # Exit with value 3 (unknown) if debug
5285 # Print a linebreak at the end if we have a TTY
5286 isatty(*STDOUT) && print "\n";
5288 # Exit with proper exit code