5 # Monitor Dell server hardware status using Dell OpenManage Server
6 # Administrator, either locally via NRPE, or remotely via SNMP.
10 # Copyright (C) 2009 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 %perfdata %reverse_exitcode %status2nagios
39 %snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
40 %blacklist %nagios_alert_count %count
41 @controllers @enclosures
42 @report_storage @report_chassis @report_other
45 #---------------------------------------------------------------------
46 # Initialization and global variables
47 #---------------------------------------------------------------------
49 # If we don't have a TTY, the plugin is probably run by Nagios. In
50 # that case, redirect all output to STDERR to STDOUT. Nagios ignores
52 if (! isatty(*STDOUT)) {
53 open STDERR, '>&', 'STDOUT'
54 or do { print "ERROR: Couldn't redirect STDERR to STDOUT\n"; exit 2; }
57 # Version and similar info
58 $NAME = 'check_openmanage';
59 $VERSION = '3.5.2-beta2';
60 $AUTHOR = 'Trond H. Amundsen';
61 $CONTACT = 't.h.amundsen@usit.uio.no';
69 # Firmware update lock file [FIXME: location on Windows?]
70 $FW_LOCK = '/var/lock/.spsetup'; # default on Linux
73 $USAGE = <<"END_USAGE";
74 Usage: $NAME [OPTION]...
82 -p, --perfdata Output performance data
83 -t, --timeout Plugin timeout in seconds
84 -c, --critical Customise temperature critical limits
85 -w, --warning Customise temperature warning limits
86 -d, --debug Debug output, reports everything
87 -h, --help Display this help text
88 -V, --version Display version info
92 -H, --hostname Hostname or IP of the server (needed for SNMP)
93 -C, --community SNMP community string
94 -P, --protocol SNMP protocol version
95 --port SNMP port number
99 -i, --info Prefix any alerts with the service tag
100 -e, --extinfo Append system info to alerts
101 -s, --state Prefix alerts with alert state
102 --short-state Prefix alerts with alert state (abbreviated)
103 -o, --okinfo Verbosity when check result is OK
104 --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
113 For more information and advanced options, see the manual page or URL:
114 http://folk.uio.no/trondham/software/check_openmanage.html
117 # Version and license text
118 $LICENSE = <<"END_LICENSE";
120 Copyright (C) 2009 $AUTHOR
121 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
122 This is free software: you are free to change and redistribute it.
123 There is NO WARRANTY, to the extent permitted by law.
125 Written by $AUTHOR <$CONTACT>
128 # Options with default values
129 %opt = ( 'blacklist' => [],
133 'timeout' => 30, # default timeout is 30 seconds
143 'okinfo' => 0, # default "ok" output level
144 'linebreak' => undef,
149 'port' => 161, # default SNMP port
151 'community' => 'public', # SMNP v1 or v2c
153 'username' => undef, # SMNP v3
154 'authpassword' => undef, # SMNP v3
155 'authkey' => undef, # SMNP v3
156 'authprotocol' => undef, # SMNP v3
157 'privpassword' => undef, # SMNP v3
158 'privkey' => undef, # SMNP v3
159 'privprotocol' => undef, # SMNP v3
163 GetOptions('b|blacklist=s' => \@{ $opt{blacklist} },
164 'check=s' => \@{ $opt{check} },
165 'c|critical=s' => \@{ $opt{critical} },
166 'w|warning=s' => \@{ $opt{warning} },
167 't|timeout=i' => \$opt{timeout},
168 'd|debug' => \$opt{debug},
169 'h|help' => \$opt{help},
170 'V|version' => \$opt{version},
171 'p|perfdata:s' => \$opt{perfdata},
172 'i|info' => \$opt{info},
173 'e|extinfo' => \$opt{extinfo},
174 'htmlinfo:s' => \$opt{htmlinfo},
175 'postmsg=s' => \$opt{postmsg},
176 's|state' => \$opt{state},
177 'short-state' => \$opt{shortstate},
178 'o|ok-info=i' => \$opt{okinfo},
179 'l|linebreak=s' => \$opt{linebreak},
180 'a|all' => \$opt{all},
181 'only=s' => \$opt{only},
182 'omreport=s' => \$opt{omreport},
183 'port=i' => \$opt{port},
184 'H|hostname=s' => \$opt{hostname},
185 'C|community=s' => \$opt{community},
186 'P|protocol=i' => \$opt{protocol},
187 'U|username=s' => \$opt{username},
188 'authpassword=s' => \$opt{authpassword},
189 'authkey=s' => \$opt{authkey},
190 'authprotocol=s' => \$opt{authprotocol},
191 'privpassword=s' => \$opt{privpassword},
192 'privkey=s' => \$opt{privkey},
193 'privprotocol=s' => \$opt{privprotocol},
194 ) or do { print $USAGE; exit $E_UNKNOWN };
196 # If user requested help
202 # If user requested version info
210 print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
215 # If we're using SNMP
216 $snmp = defined $opt{hostname} ? 1 : 0;
218 # SNMP session variables
219 $snmp_session = undef;
222 # The omreport command
225 # Check flags, override available with the --check option
226 %check = ( 'storage' => 1, # check storage subsystem
227 'memory' => 1, # check memory (dimms)
228 'fans' => 1, # check fan status
229 'power' => 1, # check power supplies
230 'temp' => 1, # check temperature
231 'cpu' => 1, # check processors
232 'voltage' => 1, # check voltage
233 'batteries' => 1, # check battery probes
234 'amperage' => 1, # check power consumption
235 'intrusion' => 1, # check intrusion detection
236 'alertlog' => 0, # check the alert log
237 'esmlog' => 0, # check the ESM log (hardware log)
238 'esmhealth' => 1, # check the ESM log overall health
242 $linebreak = isatty(*STDOUT) ? "\n" : '<br/>';
244 # Line break from option
245 if (defined $opt{linebreak}) {
246 if ($opt{linebreak} eq 'REG') {
249 elsif ($opt{linebreak} eq 'HTML') {
250 $linebreak = '<br/>';
253 $linebreak = $opt{linebreak};
257 # Exit with status=UNKNOWN if there is firmware upgrade in progress
258 if (!$snmp && -f $FW_LOCK) {
259 print "MONITORING DISABLED - Firmware update in progress ($FW_LOCK exists)\n";
263 # List of controllers and enclosures
264 @controllers = (); # controllers
265 @enclosures = (); # enclosures
268 @report_storage = (); # messages with associated nagios level (storage)
269 @report_chassis = (); # messages with associated nagios level (chassis)
270 @report_other = (); # messages with associated nagios level (other)
272 # Counters for everything
275 'pdisk' => 0, # number of physical disks
276 'vdisk' => 0, # number of logical drives (virtual disks)
277 'temp' => 0, # number of temperature probes
278 'volt' => 0, # number of voltage probes
279 'amp' => 0, # number of amperage probes
280 'intr' => 0, # number of intrusion probes
281 'dimm' => 0, # number of memory modules
282 'fan' => 0, # number of fan probes
283 'cpu' => 0, # number of CPUs
284 'bat' => 0, # number of batteries
285 'power' => 0, # number of power supplies
287 'Critical' => 0, # critical entries in ESM log
288 'Non-Critical' => 0, # warning entries in ESM log
289 'Ok' => 0, # ok entries in ESM log
292 'Critical' => 0, # critical entries in alert log
293 'Non-Critical' => 0, # warning entries in alert log
294 'Ok' => 0, # ok entries in alert log
301 # Global health status
302 $global = 1; # default is to check global status
303 $globalstatus = $E_OK; # default global health status is "OK"
305 # Nagios error levels reversed
309 $E_WARNING => 'WARNING',
310 $E_CRITICAL => 'CRITICAL',
311 $E_UNKNOWN => 'UNKNOWN',
314 # OpenManage (omreport) and SNMP error levels
317 'Unknown' => $E_CRITICAL,
318 'Critical' => $E_CRITICAL,
319 'Non-Critical' => $E_WARNING,
321 'Non-Recoverable' => $E_CRITICAL,
322 'Other' => $E_CRITICAL,
333 6 => 'Non-Recoverable',
336 # Probe Status via SNMP
339 1 => 'Other', # probe status is not one of the following:
340 2 => 'Unknown', # probe status is unknown (not known or monitored)
341 3 => 'Ok', # probe is reporting a value within the thresholds
342 4 => 'nonCriticalUpper', # probe has crossed upper noncritical threshold
343 5 => 'criticalUpper', # probe has crossed upper critical threshold
344 6 => 'nonRecoverableUpper', # probe has crossed upper non-recoverable threshold
345 7 => 'nonCriticalLower', # probe has crossed lower noncritical threshold
346 8 => 'criticalLower', # probe has crossed lower critical threshold
347 9 => 'nonRecoverableLower', # probe has crossed lower non-recoverable threshold
348 10 => 'failed', # probe is not functional
351 # Probe status translated to Nagios alarm levels
354 'Other' => $E_CRITICAL,
355 'Unknown' => $E_CRITICAL,
357 'nonCriticalUpper' => $E_WARNING,
358 'criticalUpper' => $E_CRITICAL,
359 'nonRecoverableUpper' => $E_CRITICAL,
360 'nonCriticalLower' => $E_WARNING,
361 'criticalLower' => $E_CRITICAL,
362 'nonRecoverableLower' => $E_CRITICAL,
363 'failed' => $E_CRITICAL,
366 # System information gathered
369 'bios' => 'N/A', # BIOS version
370 'biosdate' => 'N/A', # BIOS release date
371 'serial' => 'N/A', # serial number (service tag)
372 'model' => 'N/A', # system model
373 'osname' => 'N/A', # OS name
374 'osver' => 'N/A', # OS version
375 'om' => 'N/A', # OMSA version
376 'bmc' => 0, # HAS baseboard management controller (BMC)
377 'rac' => 0, # HAS remote access controller (RAC)
378 'rac_name' => 'N/A', # remote access controller (RAC)
379 'bmc_fw' => 'N/A', # BMC firmware
380 'rac_fw' => 'N/A', # RAC firmware
383 # Adjust which checks to perform
384 adjust_checks() if defined $opt{check};
386 # Blacklisted components
387 %blacklist = defined $opt{blacklist} ? %{ get_blacklist() } : ();
389 # If blacklisting is in effect, don't check global health status
390 if (scalar keys %blacklist > 0) {
394 # Take into account new hardware and blades
395 $omopt_chassis = 'chassis'; # default "chassis" option to omreport
396 $omopt_system = 'system'; # default "system" option to omreport
397 $blade = 0; # if this is a blade system
399 # Some initializations and checking before we begin
401 snmp_initialize(); # initialize SNMP
402 snmp_check(); # check that SNMP works
403 snmp_detect_blade(); # detect blade via SNMP
406 # Find the omreport binary
408 # Check help output from omreport, see which options are available.
409 # Also detecting blade via omreport.
410 check_omreport_options();
414 #---------------------------------------------------------------------
416 #---------------------------------------------------------------------
419 # Store a message in one of the message arrays
422 my ($type, $msg, $exval, $id) = @_;
423 defined $id or $id = q{};
427 'storage' => \@report_storage,
428 'chassis' => \@report_chassis,
429 'other' => \@report_other,
432 return push @{ $type2array{$type} }, [ $msg, $exval, $id ];
437 # Run command, put resulting output lines in an array and return a
438 # pointer to that array
443 open my $CMD, '-|', $command
444 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN)
448 or do { report('other', "Couldn't close filehandle for command '$command': $!", $E_UNKNOWN)
449 and return \@lines };
454 # Run command, put resulting output in a string variable and return it
459 open my $CMD, '-|', $command
460 or do { report('other', "Couldn't run command '$command': $!", $E_UNKNOWN) and return };
461 my $rawtext = do { local $/ = undef; <$CMD> }; # slurping
464 # NOTE: We don't check the return value of close() since omreport
465 # does something weird sometimes.
473 sub snmp_initialize {
474 # Legal SNMP v3 protocols
475 my $snmp_v3_privprotocol = qr{\A des|aes|aes128|3des|3desde \z}xms;
476 my $snmp_v3_authprotocol = qr{\A md5|sha \z}xms;
478 # Parameters to Net::SNMP->session()
481 '-port' => $opt{port},
482 '-hostname' => $opt{hostname},
483 '-version' => $opt{protocol},
486 # Parameters for SNMP v3
487 if ($opt{protocol} == 3) {
489 # Username is mandatory
490 if (defined $opt{username}) {
491 $param{'-username'} = $opt{username};
494 print "SNMP ERROR: With SNMPv3 the username must be specified\n";
498 # Authpassword is optional
499 if (defined $opt{authpassword}) {
500 $param{'-authpassword'} = $opt{authpassword};
503 # Authkey is optional
504 if (defined $opt{authkey}) {
505 $param{'-authkey'} = $opt{authkey};
508 # Privpassword is optional
509 if (defined $opt{privpassword}) {
510 $param{'-privpassword'} = $opt{privpassword};
513 # Privkey is optional
514 if (defined $opt{privkey}) {
515 $param{'-privkey'} = $opt{privkey};
518 # Privprotocol is optional
519 if (defined $opt{privprotocol}) {
520 if ($opt{privprotocol} =~ m/$snmp_v3_privprotocol/xms) {
521 $param{'-privprotocol'} = $opt{privprotocol};
524 print "SNMP ERROR: Unknown privprotocol '$opt{privprotocol}', "
525 . "must be one of [des|aes|aes128|3des|3desde]\n";
530 # Authprotocol is optional
531 if (defined $opt{authprotocol}) {
532 if ($opt{authprotocol} =~ m/$snmp_v3_authprotocol/xms) {
533 $param{'-authprotocol'} = $opt{authprotocol};
536 print "SNMP ERROR: Unknown authprotocol '$opt{authprotocol}', "
537 . "must be one of [md5|sha]\n";
542 # Parameters for SNMP v2c or v1
543 elsif ($opt{protocol} == 2 or $opt{protocol} == 1) {
544 $param{'-community'} = $opt{community};
547 print "SNMP ERROR: Unknown SNMP version '$opt{protocol}'\n";
551 # Try to initialize the SNMP session
552 if ( eval { require Net::SNMP; 1 } ) {
553 ($snmp_session, $snmp_error) = Net::SNMP->session( %param );
554 if (!defined $snmp_session) {
555 printf "SNMP: %s\n", $snmp_error;
560 print "You need perl module Net::SNMP to run $NAME in SNMP mode\n";
567 # Checking if SNMP works by probing for "chassisModelName", which all
568 # servers should have
571 my $chassisModelName = '1.3.6.1.4.1.674.10892.1.300.10.1.9.1';
572 my $result = $snmp_session->get_request(-varbindlist => [$chassisModelName]);
574 # Typically if remote host isn't responding
575 if (!defined $result) {
576 printf "SNMP CRITICAL: %s\n", $snmp_session->error;
580 # If OpenManage isn't installed or is not working
581 if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
582 print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
589 # Detecting blade via SNMP
591 sub snmp_detect_blade {
592 my $DellBaseBoardType = '1.3.6.1.4.1.674.10892.1.300.80.1.7.1.1';
593 my $result = $snmp_session->get_request(-varbindlist => [$DellBaseBoardType]);
595 # Identify blade. Older models (4th and 5th gen models) and/or old
596 # OMSA (4.x) don't have this OID. If we get "noSuchInstance" or
597 # similar, we assume that this isn't a blade
598 if ($result->{$DellBaseBoardType} eq '3') {
605 # Locate the omreport binary
608 # If user has specified path to omreport
609 if (defined $opt{omreport} and -x $opt{omreport}) {
610 $omreport = qq{"$opt{omreport}"};
614 # Possible full paths for omreport
617 '/usr/bin/omreport', # default on Linux
618 '/opt/dell/srvadmin/oma/bin/omreport.sh', # alternate on Linux
619 '/opt/dell/srvadmin/oma/bin/omreport', # alternate on Linux
620 'C:\Program Files (x86)\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x64
621 'C:\Program Files\Dell\SysMgt\oma\bin\omreport.exe', # default on Windows x32
622 'c:\progra~1\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x32
623 'c:\progra~2\dell\sysmgt\oma\bin\omreport.exe', # 8bit legacy default on Windows x64
626 # Find the one to use
628 foreach my $bin (@omreport_paths) {
630 $omreport = qq{"$bin"};
635 # Exit with status=UNKNOWN if OM is not installed, or we don't
636 # have permission to execute the binary
637 if (!defined $omreport) {
638 print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
645 # Checks output from 'omreport -?' and searches for arguments to
646 # omreport, to accommodate deprecated options "chassis" and "system"
647 # (on newer hardware), as well as blade servers.
649 sub check_omreport_options {
650 foreach (@{ run_command("$omreport -? 2>&1") }) {
651 if (m/\A servermodule /xms) {
652 # If "servermodule" argument to omreport exists, use it
653 # instead of argument "system"
654 $omopt_system = 'servermodule';
656 elsif (m/\A mainsystem /xms) {
657 # If "mainsystem" argument to omreport exists, use it
658 # instead of argument "chassis"
659 $omopt_chassis = 'mainsystem';
661 elsif (m/\A modularenclosure /xms) {
662 # If "modularenclusure" argument to omreport exists, assume
663 # that this is a blade
671 # Read the blacklist option and return a hash containing the
672 # blacklisted components
678 if (scalar @{ $opt{blacklist} } >= 0) {
679 foreach my $black (@{ $opt{blacklist} }) {
682 open my $BL, '<', $black
683 or do { report('other', "Couldn't open blacklist file $black: $!", $E_UNKNOWN)
696 return {} if $#bl < 0;
698 # Parse blacklist string, put in hash
699 foreach my $black (@bl) {
700 my @comps = split m{/}xms, $black;
701 foreach my $c (@comps) {
702 next if $c !~ m/=/xms;
703 my ($key, $val) = split /=/xms, $c;
704 my @vals = split /,/xms, $val;
705 $blacklist{$key} = \@vals;
713 # Read the check option and adjust the hash %check, which is a rough
714 # list of components to be checked
719 # Adjust checking based on the '--all' option
722 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
723 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--only" options\n};
726 if (scalar @{ $opt{check} } > 0) {
727 print qq{ERROR: Wrong simultaneous usage of the "--all" and "--check" options\n};
731 # set the check hash to check everything
732 map { $_ = 1 } values %check;
737 # Adjust checking based on the '--only' option
738 if (defined $opt{only} and $opt{only} !~ m{\A critical|warning \z}xms) {
740 if (scalar @{ $opt{check} } > 0) {
741 print qq{ERROR: Wrong simultaneous usage of the "--only" and "--check" options\n};
744 if (! exists $check{$opt{only}} && $opt{only} ne 'chassis') {
745 print qq{ERROR: "$opt{only}" is not a known keyword for the "--only" option\n};
749 # reset the check hash
750 map { $_ = 0 } values %check;
752 # adjust the check hash
753 if ($opt{only} eq 'chassis') {
754 map { $check{$_} = 1 } qw(memory fans power temp cpu voltage
755 batteries amperage intrusion esmhealth);
758 $check{$opt{only}} = 1;
764 # Adjust checking based on the '--check' option
765 if (scalar @{ $opt{check} } >= 0) {
766 foreach my $check (@{ $opt{check} }) {
769 open my $CL, '<', $check
770 or do { report('other', "Couldn't open check file $check: $!", $E_UNKNOWN) and return };
783 # Parse checklist string, put in hash
784 foreach my $check (@cl) {
785 my @checks = split /,/xms, $check;
786 foreach my $c (@checks) {
787 next if $c !~ m/=/xms;
788 my ($key, $val) = split /=/xms, $c;
793 # Check if we should check global health status
795 foreach (keys %check) {
796 next CHECK_KEY if $_ eq 'esmlog'; # not part of global status
797 next CHECK_KEY if $_ eq 'alertlog'; # not part of global status
799 if ($check{$_} == 0) { # found something with checking turned off
809 # Runs omreport and returns an array of anonymous hashes containing
811 # Takes one argument: string containing parameters to omreport
818 # Errors that are OK. Some low-end poweredge (and blades) models
819 # don't have RAID controllers, intrusion detection sensor, or
820 # redundant/instrumented power supplies etc.
823 Intrusion\sinformation\sis\snot\sfound\sfor\sthis\ssystem # No intrusion probe
824 | No\sinstrumented\spower\ssupplies\sfound\son\sthis\ssystem # No instrumented PS (blades/low-end)
825 | No\scontrollers\sfound # No RAID controller
826 | No\sbattery\sprobes\sfound\son\sthis\ssystem # No battery probes
827 | Invalid\scommand:\spwrmonitoring # Older OMSAs lack this command(?)
830 # Errors that are OK on blade servers
833 No\sfan\sprobes\sfound\son\sthis\ssystem # No fan probes
836 # Run omreport and fetch output
837 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
838 return [] if !defined $rawtext;
840 # Workaround for Openmanage BUG introduced in OMSA 5.5.0
841 $rawtext =~ s/\n;/;/gxms if $command eq 'storage controller';
843 # Parse output, store in array
844 for ((split /\n/xms, $rawtext)) {
845 if (m/\A Error/xms) {
846 next if m{$ok_errors}xms;
847 next if ($blade and m{$ok_blade_errors}xms);
848 report('other', "Problem running 'omreport $command': $_", $E_UNKNOWN);
851 next if !m/(.*?;){2}/xms; # ignore lines with less than 3 fields
852 my @vals = split /;/xms;
853 if ($vals[0] =~ m/\A (Index|ID|Severity|Processor|Current\sSpeed) \z/xms) {
858 push @output, { map { $_ => $vals[$i++] } @keys };
863 # Finally, return the collected information
869 # Checks if a component is blacklisted. Returns 1 if the component is
870 # blacklisted, 0 otherwise. Takes two arguments:
871 # arg1: component name
872 # arg2: component id or index
875 my $name = shift; # component name
876 my $id = shift; # component id
877 my $ret = 0; # return value
879 if (defined $blacklist{$name}) {
880 foreach my $comp (@{ $blacklist{$name} }) {
881 if (defined $id and ($comp eq $id or $comp eq 'ALL')) {
890 # Converts the NexusID from SNMP to our version
893 $nexus =~ s{\A \\}{}xms;
894 $nexus =~ s{\\}{:}gxms;
898 # Sets custom temperature thresholds based on user supplied options
899 sub custom_temperature_thresholds {
900 my $type = shift; # type of threshold, either w (warning) or c (critical)
901 my %thres = (); # will contain the thresholds
902 my @limits = (); # holds the input
904 my @opt = $type eq 'w' ? @{ $opt{warning} } : @{ $opt{critical} };
906 if (scalar @opt >= 0) {
907 foreach my $t (@opt) {
911 or do { report('other', "Couldn't open temperature threshold file $t: $!",
912 $E_UNKNOWN) and return {} };
923 # Parse checklist string, put in hash
924 foreach my $th (@limits) {
925 my @tmp = split m{,}xms, $th;
926 foreach my $t (@tmp) {
927 next if $t !~ m{=}xms;
928 my ($key, $val) = split m{=}xms, $t;
929 if ($val =~ m{/}xms) {
930 my ($max, $min) = split m{/}xms, $val;
931 $thres{$key}{max} = $max;
932 $thres{$key}{min} = $min;
935 $thres{$key}{max} = $val;
944 # Gets the output from SNMP result according to the OIDs checked
945 sub get_snmp_output {
946 my ($result,$oidref) = @_;
949 foreach my $oid (keys %{ $result }) {
950 my @dummy = split /\./xms, $oid;
953 my $foo = join q{.}, @dummy;
954 if (exists $oidref->{$foo}) {
955 $output[$id]{$oidref->{$foo}} = $result->{$oid};
962 # Map the controller or other item in-place
964 my ($key, $val, $list) = @_;
966 foreach my $lst (@{ $list }) {
967 if (!exists $lst->{$key}) {
974 # Return the URL for official Dell documentation for a specific
976 sub documentation_url {
979 # create model short form, e.g. "r710"
980 $model =~ s{\A PowerEdge \s (.+?) \z}{lc($1)}exms;
982 # special case for blades (e.g. M600, M710), they have common
984 $model =~ s{\A m\d+ \z}{m}xms;
986 return 'http://support.dell.com/support/edocs/systems/pe' . $model . '/';
989 # Return the URL for warranty information for a server with a given
990 # serial number (servicetag)
994 # Dell support sites for different parts of the world
997 'emea' => 'http://support.euro.dell.com/support/topics/topic.aspx/emea/shared/support/my_systems_info/',
998 'ap' => 'http://supportapj.dell.com/support/topics/topic.aspx/ap/shared/support/my_systems_info/en/details?',
999 'glob' => 'http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?',
1002 # warranty URLs for different country codes
1006 'at' => $supportsite{emea} . 'de/details?c=at&l=de&ServiceTag=', # Austria
1007 'be' => $supportsite{emea} . 'nl/details?c=be&l=nl&ServiceTag=', # Belgium
1008 'cz' => $supportsite{emea} . 'cs/details?c=cz&l=cs&ServiceTag=', # Czech Republic
1009 'de' => $supportsite{emea} . 'de/details?c=de&l=de&ServiceTag=', # Germany
1010 'dk' => $supportsite{emea} . 'da/details?c=dk&l=da&ServiceTag=', # Denmark
1011 'es' => $supportsite{emea} . 'es/details?c=es&l=es&ServiceTag=', # Spain
1012 'fi' => $supportsite{emea} . 'fi/details?c=fi&l=fi&ServiceTag=', # Finland
1013 'fr' => $supportsite{emea} . 'fr/details?c=fr&l=fr&ServiceTag=', # France
1014 'gr' => $supportsite{emea} . 'en/details?c=gr&l=el&ServiceTag=', # Greece
1015 'it' => $supportsite{emea} . 'it/details?c=it&l=it&ServiceTag=', # Italy
1016 'il' => $supportsite{emea} . 'en/details?c=il&l=en&ServiceTag=', # Israel
1017 'me' => $supportsite{emea} . 'en/details?c=me&l=en&ServiceTag=', # Middle East
1018 'no' => $supportsite{emea} . 'no/details?c=no&l=no&ServiceTag=', # Norway
1019 'nl' => $supportsite{emea} . 'nl/details?c=nl&l=nl&ServiceTag=', # The Netherlands
1020 'pl' => $supportsite{emea} . 'pl/details?c=pl&l=pl&ServiceTag=', # Poland
1021 'pt' => $supportsite{emea} . 'en/details?c=pt&l=pt&ServiceTag=', # Portugal
1022 'ru' => $supportsite{emea} . 'ru/details?c=ru&l=ru&ServiceTag=', # Russia
1023 'se' => $supportsite{emea} . 'sv/details?c=se&l=sv&ServiceTag=', # Sweden
1024 'uk' => $supportsite{emea} . 'en/details?c=uk&l=en&ServiceTag=', # United Kingdom
1025 'za' => $supportsite{emea} . 'en/details?c=za&l=en&ServiceTag=', # South Africa
1027 'br' => $supportsite{glob} . 'c=br&l=pt&ServiceTag=', # Brazil
1028 'ca' => $supportsite{glob} . 'c=ca&l=en&ServiceTag=', # Canada
1029 'mx' => $supportsite{glob} . 'c=mx&l=es&ServiceTag=', # Mexico
1030 'us' => $supportsite{glob} . 'c=us&l=en&ServiceTag=', # USA
1032 'au' => $supportsite{ap} . 'c=au&l=en&ServiceTag=', # Australia
1033 'cn' => $supportsite{ap} . 'c=cn&l=zh&ServiceTag=', # China
1034 'in' => $supportsite{ap} . 'c=in&l=en&ServiceTag=', # India
1036 'XX' => $supportsite{glob} . 'ServiceTag=', # default
1039 if (exists $url{$opt{htmlinfo}}) {
1040 return $url{$opt{htmlinfo}} . $tag;
1043 return $url{XX} . $tag;
1049 #---------------------------------------------------------------------
1051 #---------------------------------------------------------------------
1053 #-----------------------------------------
1054 # Check global health status
1055 #-----------------------------------------
1061 # Checks global status, i.e. both storage and chassis
1063 my $systemStateGlobalSystemStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.2.1';
1064 my $result = $snmp_session->get_request(-varbindlist => [$systemStateGlobalSystemStatus]);
1065 if (!defined $result) {
1066 printf "SNMP ERROR [global]: %s\n", $snmp_error;
1069 $health = $status2nagios{$snmp_status{$result->{$systemStateGlobalSystemStatus}}};
1073 # NB! This does not check storage, only chassis...
1075 foreach (@{ run_command("$omreport $omopt_system -fmt ssv") }) {
1077 next if m/\A SEVERITY;COMPONENT/xms;
1078 if (m/\A (.+?);Main\sSystem(\sChassis)? /xms) {
1079 $health = $status2nagios{$1};
1090 #-----------------------------------------
1091 # STORAGE: Check controllers
1092 #-----------------------------------------
1093 sub check_controllers {
1101 my $firmware = undef;
1108 '1.3.6.1.4.1.674.10893.1.20.130.1.1.1' => 'controllerNumber',
1109 '1.3.6.1.4.1.674.10893.1.20.130.1.1.2' => 'controllerName',
1110 '1.3.6.1.4.1.674.10893.1.20.130.1.1.5' => 'controllerState',
1111 '1.3.6.1.4.1.674.10893.1.20.130.1.1.8' => 'controllerFWVersion',
1112 '1.3.6.1.4.1.674.10893.1.20.130.1.1.38' => 'controllerComponentStatus',
1113 '1.3.6.1.4.1.674.10893.1.20.130.1.1.39' => 'controllerNexusID',
1114 '1.3.6.1.4.1.674.10893.1.20.130.1.1.41' => 'controllerDriverVersion',
1115 '1.3.6.1.4.1.674.10893.1.20.130.1.1.44' => 'controllerMinFWVersion',
1116 '1.3.6.1.4.1.674.10893.1.20.130.1.1.45' => 'controllerMinDriverVersion',
1119 # We use get_table() here for the odd case where a server has
1120 # two or more controllers, and where some OIDs are missing on
1121 # one of the controllers.
1122 my $controllerTable = '1.3.6.1.4.1.674.10893.1.20.130.1';
1123 my $result = $snmp_session->get_table(-baseoid => $controllerTable);
1125 # No controllers is OK
1126 return if !defined $result;
1128 @output = @{ get_snmp_output($result, \%ctrl_oid) };
1131 @output = @{ run_omreport('storage controller') };
1145 foreach my $out (@output) {
1147 $id = $out->{'controllerNumber'} - 1;
1148 $name = $out->{'controllerName'};
1149 $state = $ctrl_state{$out->{'controllerState'}};
1150 $status = $snmp_status{$out->{'controllerComponentStatus'}};
1151 $minfw = exists $out->{'controllerMinFWVersion'}
1152 ? $out->{'controllerMinFWVersion'} : undef;
1153 $mindr = exists $out->{'controllerMinDriverVersion'}
1154 ? $out->{'controllerMinDriverVersion'} : undef;
1155 $firmware = exists $out->{controllerFWVersion}
1156 ? $out->{controllerFWVersion} : 'N/A';
1157 $driver = exists $out->{controllerDriverVersion}
1158 ? $out->{controllerDriverVersion} : 'N/A';
1159 $nexus = convert_nexus($out->{controllerNexusID});
1163 $name = $out->{Name};
1164 $state = $out->{State};
1165 $status = $out->{Status};
1166 $minfw = $out->{'Minimum Required Firmware Version'} ne 'Not Applicable'
1167 ? $out->{'Minimum Required Firmware Version'} : undef;
1168 $mindr = $out->{'Minimum Required Driver Version'} ne 'Not Applicable'
1169 ? $out->{'Minimum Required Driver Version'} : undef;
1170 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1171 ? $out->{'Firmware Version'} : 'N/A';
1172 $driver = $out->{'Driver Version'} ne 'Not Applicable'
1173 ? $out->{'Driver Version'} : 'N/A';
1177 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1178 push @controllers, $id;
1180 # Collecting some storage info
1181 $sysinfo{'controller'}{$id}{'id'} = $nexus;
1182 $sysinfo{'controller'}{$id}{'name'} = $name;
1183 $sysinfo{'controller'}{$id}{'driver'} = $driver;
1184 $sysinfo{'controller'}{$id}{'firmware'} = $firmware;
1186 next CTRL if blacklisted('ctrl', $nexus);
1188 # Special case: old firmware
1189 if (!blacklisted('ctrl_fw', $id) && defined $minfw) {
1191 my $msg = sprintf q{Controller %d [%s]: Firmware '%s' is out of date},
1192 $id, $name, $firmware;
1193 report('storage', $msg, $E_WARNING, $nexus);
1195 # Special case: old driver
1196 if (!blacklisted('ctrl_driver', $id) && defined $mindr) {
1198 my $msg = sprintf q{Controller %d [%s]: Driver '%s' is out of date},
1199 $id, $name, $driver;
1200 report('storage', $msg, $E_WARNING, $nexus);
1203 if ($status eq 'Ok' or ($status eq 'Non-Critical'
1204 and (defined $minfw or defined $mindr))) {
1205 my $msg = sprintf 'Controller %d [%s] is %s',
1207 report('storage', $msg, $E_OK, $nexus);
1211 my $msg = sprintf 'Controller %d [%s] needs attention: %s',
1213 report('storage', $msg, $status2nagios{$status}, $nexus);
1220 #-----------------------------------------
1221 # STORAGE: Check physical drives
1222 #-----------------------------------------
1223 sub check_physical_disks {
1224 return if $#controllers == -1;
1234 my $vendor = undef; # disk vendor
1235 my $product = undef; # product ID
1236 my $capacity = undef; # disk length (size) in bytes
1242 '1.3.6.1.4.1.674.10893.1.20.130.4.1.1' => 'arrayDiskNumber',
1243 '1.3.6.1.4.1.674.10893.1.20.130.4.1.2' => 'arrayDiskName',
1244 '1.3.6.1.4.1.674.10893.1.20.130.4.1.3' => 'arrayDiskVendor',
1245 '1.3.6.1.4.1.674.10893.1.20.130.4.1.4' => 'arrayDiskState',
1246 '1.3.6.1.4.1.674.10893.1.20.130.4.1.6' => 'arrayDiskProductID',
1247 '1.3.6.1.4.1.674.10893.1.20.130.4.1.9' => 'arrayDiskEnclosureID',
1248 '1.3.6.1.4.1.674.10893.1.20.130.4.1.10' => 'arrayDiskChannel',
1249 '1.3.6.1.4.1.674.10893.1.20.130.4.1.11' => 'arrayDiskLengthInMB',
1250 '1.3.6.1.4.1.674.10893.1.20.130.4.1.15' => 'arrayDiskTargetID',
1251 '1.3.6.1.4.1.674.10893.1.20.130.4.1.16' => 'arrayDiskLunID',
1252 '1.3.6.1.4.1.674.10893.1.20.130.4.1.24' => 'arrayDiskComponentStatus',
1253 '1.3.6.1.4.1.674.10893.1.20.130.4.1.26' => 'arrayDiskNexusID',
1254 '1.3.6.1.4.1.674.10893.1.20.130.4.1.31' => 'arrayDiskSmartAlertIndication',
1255 '1.3.6.1.4.1.674.10893.1.20.130.5.1.5' => 'arrayDiskEnclosureConnectionEnclosureNumber',
1256 '1.3.6.1.4.1.674.10893.1.20.130.5.1.7' => 'arrayDiskEnclosureConnectionControllerNumber',
1258 my $result = $snmp_session->get_entries(-columns => [keys %pdisk_oid]);
1260 if (!defined $result) {
1261 printf "SNMP ERROR [storage / pdisk]: %s.\n", $snmp_session->error;
1262 $snmp_session->close;
1266 @output = @{ get_snmp_output($result, \%pdisk_oid) };
1269 foreach my $c (@controllers) {
1270 push @output, @{ run_omreport("storage pdisk controller=$c") };
1271 map_item('ctrl', $c, \@output);
1289 28 => 'Diagnostics',
1290 34 => 'Predictive failure',
1291 35 => 'Initializing',
1294 41 => 'Unsupported',
1295 53 => 'Incompatible',
1298 # Check physical disks on each of the controllers
1300 foreach my $out (@output) {
1302 $name = $out->{arrayDiskName};
1303 if ($name =~ m{.*\d+:\d+:\d+\z}xms) {
1304 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskEnclosureID},
1305 $out->{arrayDiskTargetID});
1308 $id = join q{:}, ($out->{arrayDiskChannel}, $out->{arrayDiskTargetID});
1310 $state = $pdisk_state{$out->{arrayDiskState}};
1311 $status = $snmp_status{$out->{arrayDiskComponentStatus}};
1312 $fpred = $out->{arrayDiskSmartAlertIndication} == 2 ? 1 : 0;
1314 $ctrl = exists $out->{arrayDiskEnclosureConnectionControllerNumber}
1315 ? $out->{arrayDiskEnclosureConnectionControllerNumber} - 1
1317 $nexus = convert_nexus($out->{arrayDiskNexusID});
1318 $vendor = $out->{arrayDiskVendor};
1319 $product = $out->{arrayDiskProductID};
1320 $capacity = $out->{arrayDiskLengthInMB} * 1024**2;
1324 $name = $out->{'Name'};
1325 $state = $out->{'State'};
1326 $status = $out->{'Status'};
1327 $fpred = lc($out->{'Failure Predicted'}) eq 'yes' ? 1 : 0;
1328 $progr = ' [' . $out->{'Progress'} . ']';
1329 $ctrl = $out->{'ctrl'};
1330 $nexus = join q{:}, $out->{ctrl}, $id;
1331 $vendor = $out->{'Vendor ID'};
1332 $product = $out->{'Product ID'};
1333 $capacity = $out->{'Capacity'};
1334 $capacity =~ s{\A .*? \((\d+) \s bytes\) \z}{$1}xms;
1337 next PDISK if blacklisted('pdisk', $nexus);
1340 $vendor =~ s{\s+\z}{}xms; # remove trailing whitespace
1341 $product =~ s{\s+\z}{}xms; # remove trailing whitespace
1343 # Calculate human readable capacity
1344 $capacity = ceil($capacity / 1000**3) >= 1000
1345 ? sprintf '%.1fTB', ($capacity / 1000**4)
1346 : sprintf '%.0fGB', ($capacity / 1000**3);
1347 $capacity = '450GB' if $capacity eq '449GB'; # quick fix for 450GB disks
1348 $capacity = '300GB' if $capacity eq '299GB'; # quick fix for 300GB disks
1349 $capacity = '146GB' if $capacity eq '147GB'; # quick fix for 146GB disks
1351 # Capitalize only the first letter of the vendor name
1352 $vendor = (substr $vendor, 0, 1) . lc (substr $vendor, 1, length $vendor);
1354 # Remove unnecessary trademark rubbish from vendor name
1355 $vendor =~ s{\(tm\)\z}{}xms;
1357 # Special case: Failure predicted
1358 if ($status eq 'Non-Critical' and $fpred) {
1359 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: Failure Predicted',
1360 $name, $vendor, $product, $capacity, $ctrl;
1361 report('storage', $msg, $E_WARNING, $nexus);
1363 # Special case: Rebuilding
1364 elsif ($state eq 'Rebuilding') {
1365 my $msg = sprintf '%s [%s] on ctrl %d is %s%s',
1366 $name, $capacity, $ctrl, $state, $progr;
1367 report('storage', $msg, $E_WARNING, $nexus);
1370 elsif ($status ne 'Ok') {
1371 my $msg = sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
1372 $name, $vendor, $product, $capacity, $ctrl, $state;
1373 report('storage', $msg, $status2nagios{$status}, $nexus);
1377 my $msg = sprintf '%s [%s] on ctrl %d is %s',
1378 $name, $capacity, $ctrl, $state;
1379 report('storage', $msg, $E_OK, $nexus);
1386 #-----------------------------------------
1387 # STORAGE: Check logical drives
1388 #-----------------------------------------
1389 sub check_virtual_disks {
1390 return if $#controllers == -1;
1407 '1.3.6.1.4.1.674.10893.1.20.140.1.1.3' => 'virtualDiskDeviceName',
1408 '1.3.6.1.4.1.674.10893.1.20.140.1.1.4' => 'virtualDiskState',
1409 '1.3.6.1.4.1.674.10893.1.20.140.1.1.6' => 'virtualDiskLengthInMB',
1410 '1.3.6.1.4.1.674.10893.1.20.140.1.1.13' => 'virtualDiskLayout',
1411 '1.3.6.1.4.1.674.10893.1.20.140.1.1.17' => 'virtualDiskTargetID',
1412 '1.3.6.1.4.1.674.10893.1.20.140.1.1.20' => 'virtualDiskComponentStatus',
1413 '1.3.6.1.4.1.674.10893.1.20.140.1.1.21' => 'virtualDiskNexusID',
1415 my $result = $snmp_session->get_entries(-columns => [keys %vdisk_oid]);
1417 # No logical drives is OK
1418 return if !defined $result;
1420 @output = @{ get_snmp_output($result, \%vdisk_oid) };
1423 foreach my $c (@controllers) {
1424 push @output, @{ run_omreport("storage vdisk controller=$c") };
1425 map_item('ctrl', $c, \@output);
1438 16 => 'Regenerating',
1441 32 => 'Reconstructing',
1442 35 => 'Initializing',
1443 36 => 'Background Initialization',
1444 38 => 'Resynching Paused',
1445 52 => 'Permanently Degraded',
1446 54 => 'Degraded Redundancy',
1451 1 => 'Concatenated',
1458 19 => 'Concatenated RAID 1',
1462 # Check virtual disks on each of the controllers
1464 foreach my $out (@output) {
1466 $id = $out->{virtualDiskTargetID};
1467 $dev = $out->{virtualDiskDeviceName};
1468 $state = $vdisk_state{$out->{virtualDiskState}};
1469 $status = $snmp_status{$out->{virtualDiskComponentStatus}};
1470 $layout = $vdisk_layout{$out->{virtualDiskLayout}};
1471 $size = sprintf '%.2f GB', $out->{virtualDiskLengthInMB} / 1024;
1472 $progr = q{}; # can't get this from SNMP(?)
1473 $nexus = convert_nexus($out->{virtualDiskNexusID});
1474 $ctrl = $nexus; # We use the nexus id to get the controller id
1475 $ctrl =~ s{\A (\d+):\d+ \z}{$1}xms;
1479 $dev = $out->{'Device Name'};
1480 $state = $out->{State};
1481 $status = $out->{Status};
1482 $layout = $out->{Layout};
1483 $size = $out->{Size};
1484 $progr = ' [' . $out->{Progress} . ']';
1485 $size =~ s{\A (.*GB).* \z}{$1}xms;
1486 $nexus = join q{:}, $out->{ctrl}, $id;
1487 $ctrl = $out->{ctrl};
1490 next VDISK if blacklisted('vdisk', $nexus);
1493 # Special case: Regenerating
1494 if ($state eq 'Regenerating') {
1495 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s%s},
1496 $id, $dev, $layout, $size, $ctrl, $state, $progr;
1497 report('storage', $msg, $E_WARNING, $nexus);
1500 elsif ($status ne 'Ok') {
1501 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d needs attention: %s},
1502 $id, $dev, $layout, $size, $ctrl, $state;
1503 report('storage', $msg, $status2nagios{$status}, $nexus);
1507 my $msg = sprintf q{Logical drive %d '%s' [%s, %s] on ctrl %d is %s},
1508 $id, $dev, $layout, $size, $ctrl, $state;
1509 report('storage', $msg, $E_OK, $nexus);
1516 #-----------------------------------------
1517 # STORAGE: Check cache batteries
1518 #-----------------------------------------
1519 sub check_cache_battery {
1520 return if $#controllers == -1;
1527 my $learn = undef; # learn state
1528 my $pred = undef; # battery's ability to be charged
1534 '1.3.6.1.4.1.674.10893.1.20.130.15.1.4' => 'batteryState',
1535 '1.3.6.1.4.1.674.10893.1.20.130.15.1.6' => 'batteryComponentStatus',
1536 '1.3.6.1.4.1.674.10893.1.20.130.15.1.9' => 'batteryNexusID',
1537 '1.3.6.1.4.1.674.10893.1.20.130.15.1.10' => 'batteryPredictedCapacity',
1538 '1.3.6.1.4.1.674.10893.1.20.130.15.1.12' => 'batteryLearnState',
1539 '1.3.6.1.4.1.674.10893.1.20.130.16.1.5' => 'batteryConnectionControllerNumber',
1541 my $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
1543 # No cache battery is OK
1544 return if !defined $result;
1546 @output = @{ get_snmp_output($result, \%bat_oid) };
1549 foreach my $c (@controllers) {
1550 push @output, @{ run_omreport("storage battery controller=$c") };
1551 map_item('ctrl', $c, \@output);
1561 7 => 'Reconditioning',
1580 1 => 'Failed', # The battery cannot be charged and needs to be replaced
1581 2 => 'Ready', # The battery can be charged to full capacity
1582 4 => 'Unknown', # The battery is completing a Learn cycle. The charge capacity of the
1583 # battery cannot be determined until the Learn cycle is complete
1586 # Check battery on each of the controllers
1588 foreach my $out (@output) {
1590 $state = $bat_state{$out->{batteryState}};
1591 $status = $snmp_status{$out->{batteryComponentStatus}};
1592 $learn = exists $out->{batteryLearnState}
1593 ? $bat_learn_state{$out->{batteryLearnState}} : undef;
1594 $pred = exists $out->{batteryPredictedCapacity}
1595 ? $bat_pred_cap{$out->{batteryPredictedCapacity}} : undef;
1596 $ctrl = $out->{batteryConnectionControllerNumber} - 1;
1597 $nexus = convert_nexus($out->{batteryNexusID});
1599 $id =~ s{\A \d+:(\d+) \z}{$1}xms;
1603 $state = $out->{'State'};
1604 $status = $out->{'Status'};
1605 $learn = $out->{'Learn State'};
1606 $pred = $out->{'Predicted Capacity Status'};
1607 $ctrl = $out->{'ctrl'};
1608 $nexus = join q{:}, $out->{ctrl}, $id;
1611 next BATTERY if blacklisted('bat', $nexus);
1613 # Special case: Charging
1614 if ($state eq 'Charging') {
1615 next BATTERY if blacklisted('bat_charge', $nexus);
1616 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1617 $id, $ctrl, $state, $pred;
1618 report('storage', $msg, $E_WARNING, $nexus);
1620 # Special case: Learning (battery learns its capacity)
1621 elsif ($state eq 'Learning') {
1622 next BATTERY if blacklisted('bat_charge', $nexus);
1623 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1624 $id, $ctrl, $state, $learn;
1625 report('storage', $msg, $E_WARNING, $nexus);
1627 # Special case: Power Low (first part of recharge cycle)
1628 elsif ($state eq 'Power Low') {
1629 next BATTERY if blacklisted('bat_charge', $nexus);
1630 my $msg = sprintf 'Cache battery %d in controller %d is %s [probably harmless]',
1632 report('storage', $msg, $E_WARNING, $nexus);
1634 # Special case: Degraded and Non-Critical (usually part of recharge cycle)
1635 elsif ($state eq 'Degraded' && $status eq 'Non-Critical') {
1636 next BATTERY if blacklisted('bat_charge', $nexus);
1637 my $msg = sprintf 'Cache battery %d in controller %d is %s (%s) [probably harmless]',
1638 $id, $ctrl, $state, $status;
1639 report('storage', $msg, $E_WARNING, $nexus);
1642 elsif ($status ne 'Ok') {
1643 my $msg = sprintf 'Cache battery %d in controller %d needs attention: %s (%s)',
1644 $id, $ctrl, $state, $status;
1645 report('storage', $msg, $status2nagios{$status}, $nexus);
1649 my $msg = sprintf 'Cache battery %d in controller %d is %s',
1651 report('storage', $msg, $E_OK, $nexus);
1658 #-----------------------------------------
1659 # STORAGE: Check connectors (channels)
1660 #-----------------------------------------
1661 sub check_connectors {
1662 return if $#controllers == -1;
1676 '1.3.6.1.4.1.674.10893.1.20.130.2.1.1' => 'channelNumber',
1677 '1.3.6.1.4.1.674.10893.1.20.130.2.1.2' => 'channelName',
1678 '1.3.6.1.4.1.674.10893.1.20.130.2.1.3' => 'channelState',
1679 '1.3.6.1.4.1.674.10893.1.20.130.2.1.8' => 'channelComponentStatus',
1680 '1.3.6.1.4.1.674.10893.1.20.130.2.1.9' => 'channelNexusID',
1681 '1.3.6.1.4.1.674.10893.1.20.130.2.1.11' => 'channelBusType',
1683 my $result = $snmp_session->get_entries(-columns => [keys %conn_oid]);
1685 if (!defined $result) {
1686 printf "SNMP ERROR [storage / channel]: %s.\n", $snmp_session->error;
1687 $snmp_session->close;
1691 @output = @{ get_snmp_output($result, \%conn_oid) };
1694 foreach my $c (@controllers) {
1695 push @output, @{ run_omreport("storage connector controller=$c") };
1696 map_item('ctrl', $c, \@output);
1714 3 => 'Fibre Channel',
1721 # Check connectors on each of the controllers
1723 foreach my $out (@output) {
1725 $id = $out->{channelNumber} - 1;
1726 $name = $out->{channelName};
1727 $state = $conn_state{$out->{channelState}};
1728 $status = $snmp_status{$out->{channelComponentStatus}};
1729 $type = $conn_bustype{$out->{channelBusType}};
1730 $nexus = convert_nexus($out->{channelNexusID});
1732 $ctrl =~ s{(\d+):\d+}{$1}xms;
1736 $name = $out->{'Name'};
1737 $state = $out->{'State'};
1738 $status = $out->{'Status'};
1739 $type = $out->{'Connector Type'};
1740 $ctrl = $out->{ctrl};
1741 $nexus = join q{:}, $out->{ctrl}, $id;
1744 next CHANNEL if blacklisted('conn', $nexus);
1746 my $msg = sprintf '%s [%s] on controller %d is %s',
1747 $name, $type, $ctrl, $state;
1748 report('storage', $msg, $status2nagios{$status}, $nexus);
1754 #-----------------------------------------
1755 # STORAGE: Check enclosures
1756 #-----------------------------------------
1757 sub check_enclosures {
1763 my $firmware = undef;
1770 '1.3.6.1.4.1.674.10893.1.20.130.3.1.1' => 'enclosureNumber',
1771 '1.3.6.1.4.1.674.10893.1.20.130.3.1.2' => 'enclosureName',
1772 '1.3.6.1.4.1.674.10893.1.20.130.3.1.4' => 'enclosureState',
1773 '1.3.6.1.4.1.674.10893.1.20.130.3.1.19' => 'enclosureChannelNumber',
1774 '1.3.6.1.4.1.674.10893.1.20.130.3.1.24' => 'enclosureComponentStatus',
1775 '1.3.6.1.4.1.674.10893.1.20.130.3.1.25' => 'enclosureNexusID',
1776 '1.3.6.1.4.1.674.10893.1.20.130.3.1.26' => 'enclosureFirmwareVersion',
1778 my $result = $snmp_session->get_entries(-columns => [keys %encl_oid]);
1780 # No enclosures is OK
1781 return if !defined $result;
1783 @output = @{ get_snmp_output($result, \%encl_oid) };
1786 foreach my $c (@controllers) {
1787 push @output, @{ run_omreport("storage enclosure controller=$c") };
1788 map_item('ctrl', $c, \@output);
1803 foreach my $out (@output) {
1805 $id = $out->{'enclosureNumber'} - 1;
1806 $name = $out->{'enclosureName'};
1807 $state = $encl_state{$out->{'enclosureState'}};
1808 $status = $snmp_status{$out->{'enclosureComponentStatus'}};
1809 $firmware = exists $out->{enclosureFirmwareVersion}
1810 ? $out->{enclosureFirmwareVersion} : 'N/A';
1811 $nexus = convert_nexus($out->{enclosureNexusID});
1813 $ctrl =~ s{\A (\d+):.* \z}{$1}xms;
1817 $name = $out->{Name};
1818 $state = $out->{State};
1819 $status = $out->{Status};
1820 $firmware = $out->{'Firmware Version'} ne 'Not Applicable'
1821 ? $out->{'Firmware Version'} : 'N/A';
1822 $nexus = join q{:}, $out->{ctrl}, $id;
1823 $ctrl = $out->{ctrl};
1826 $name =~ s{\s+\z}{}xms; # remove trailing whitespace
1827 $firmware =~ s{\s+\z}{}xms; # remove trailing whitespace
1829 # store enclosure data for future use
1830 push @enclosures, { 'id' => $id,
1831 'ctrl' => $out->{ctrl},
1834 # Collecting some storage info
1835 $sysinfo{'enclosure'}{$nexus}{'id'} = $nexus;
1836 $sysinfo{'enclosure'}{$nexus}{'name'} = $name;
1837 $sysinfo{'enclosure'}{$nexus}{'firmware'} = $firmware;
1839 next ENCLOSURE if blacklisted('encl', $nexus);
1841 my $msg = sprintf 'Enclosure %s [%s] on controller %d is %s',
1842 $nexus, $name, $ctrl, $state;
1843 report('storage', $msg, $status2nagios{$status}, $nexus);
1849 #-----------------------------------------
1850 # STORAGE: Check enclosure fans
1851 #-----------------------------------------
1852 sub check_enclosure_fans {
1853 return if $#controllers == -1;
1861 my $encl_id = undef;
1862 my $encl_name = undef;
1868 '1.3.6.1.4.1.674.10893.1.20.130.7.1.1' => 'fanNumber',
1869 '1.3.6.1.4.1.674.10893.1.20.130.7.1.2' => 'fanName',
1870 '1.3.6.1.4.1.674.10893.1.20.130.7.1.4' => 'fanState',
1871 '1.3.6.1.4.1.674.10893.1.20.130.7.1.11' => 'fanProbeCurrValue',
1872 '1.3.6.1.4.1.674.10893.1.20.130.7.1.15' => 'fanComponentStatus',
1873 '1.3.6.1.4.1.674.10893.1.20.130.7.1.16' => 'fanNexusID',
1874 '1.3.6.1.4.1.674.10893.1.20.130.8.1.4' => 'fanConnectionEnclosureName',
1875 '1.3.6.1.4.1.674.10893.1.20.130.8.1.5' => 'fanConnectionEnclosureNumber',
1878 my $result = $snmp_session->get_entries(-columns => [keys %fan_oid]);
1880 # No enclosure fans is OK
1881 return if !defined $result;
1883 @output = @{ get_snmp_output($result, \%fan_oid) };
1886 foreach my $enc (@enclosures) {
1887 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=fans") };
1888 map_item('ctrl', $enc->{ctrl}, \@output);
1889 map_item('encl_id', $enc->{id}, \@output);
1890 map_item('encl_name', $enc->{name}, \@output);
1905 # Check fans on each of the enclosures
1907 foreach my $out (@output) {
1909 $id = $out->{fanNumber} - 1;
1910 $name = $out->{fanName};
1911 $state = $fan_state{$out->{fanState}};
1912 $status = $snmp_status{$out->{fanComponentStatus}};
1913 $speed = $out->{fanProbeCurrValue};
1914 $encl_id = $out->{fanConnectionEnclosureNumber} - 1;
1915 $encl_name = $out->{fanConnectionEnclosureName};
1916 $nexus = convert_nexus($out->{fanNexusID});
1920 $name = $out->{'Name'};
1921 $state = $out->{'State'};
1922 $status = $out->{'Status'};
1923 $speed = $out->{'Speed'};
1924 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
1925 $encl_name = $out->{encl_name};
1926 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
1929 next FAN if blacklisted('encl_fan', $nexus);
1932 if ($status ne 'Ok') {
1933 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
1934 $name, $encl_id, $encl_name, $state;
1935 report('storage', $msg, $status2nagios{$status}, $nexus);
1939 my $msg = sprintf '%s in enclosure %s [%s] is %s (speed=%s)',
1940 $name, $encl_id, $encl_name, $state, $speed;
1941 report('storage', $msg, $E_OK, $nexus);
1948 #-----------------------------------------
1949 # STORAGE: Check enclosure power supplies
1950 #-----------------------------------------
1951 sub check_enclosure_pwr {
1952 return if $#controllers == -1;
1959 my $encl_id = undef;
1960 my $encl_name = undef;
1966 '1.3.6.1.4.1.674.10893.1.20.130.9.1.1' => 'powerSupplyNumber',
1967 '1.3.6.1.4.1.674.10893.1.20.130.9.1.2' => 'powerSupplyName',
1968 '1.3.6.1.4.1.674.10893.1.20.130.9.1.4' => 'powerSupplyState',
1969 '1.3.6.1.4.1.674.10893.1.20.130.9.1.9' => 'powerSupplyComponentStatus',
1970 '1.3.6.1.4.1.674.10893.1.20.130.9.1.10' => 'powerSupplyNexusID',
1971 '1.3.6.1.4.1.674.10893.1.20.130.10.1.4' => 'powerSupplyConnectionEnclosureName',
1972 '1.3.6.1.4.1.674.10893.1.20.130.10.1.5' => 'powerSupplyConnectionEnclosureNumber',
1974 my $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
1976 # No enclosure power supplies is OK
1977 return if !defined $result;
1979 @output = @{ get_snmp_output($result, \%ps_oid) };
1982 foreach my $enc (@enclosures) {
1983 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=pwrsupplies") };
1984 map_item('ctrl', $enc->{ctrl}, \@output);
1985 map_item('encl_id', $enc->{id}, \@output);
1986 map_item('encl_name', $enc->{name}, \@output);
1995 5 => 'Not Installed',
2001 # Check power supplies on each of the enclosures
2003 foreach my $out (@output) {
2005 $id = $out->{powerSupplyNumber};
2006 $name = $out->{powerSupplyName};
2007 $state = $ps_state{$out->{powerSupplyState}};
2008 $status = $snmp_status{$out->{powerSupplyComponentStatus}};
2009 $encl_id = $out->{powerSupplyConnectionEnclosureNumber} - 1;
2010 $encl_name = $out->{powerSupplyConnectionEnclosureName};
2011 $nexus = convert_nexus($out->{powerSupplyNexusID});
2015 $name = $out->{'Name'};
2016 $state = $out->{'State'};
2017 $status = $out->{'Status'};
2018 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2019 $encl_name = $out->{encl_name};
2020 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2023 next PS if blacklisted('encl_ps', $nexus);
2026 if ($status ne 'Ok') {
2027 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2028 $name, $encl_id, $encl_name, $state;
2029 report('storage', $msg, $status2nagios{$status}, $nexus);
2033 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2034 $name, $encl_id, $encl_name, $state;
2035 report('storage', $msg, $E_OK, $nexus);
2042 #-----------------------------------------
2043 # STORAGE: Check enclosure temperatures
2044 #-----------------------------------------
2045 sub check_enclosure_temp {
2046 return if $#controllers == -1;
2053 my $reading = undef;
2055 my $max_warn = undef;
2056 my $max_crit = undef;
2057 my $encl_id = undef;
2058 my $encl_name = undef;
2064 '1.3.6.1.4.1.674.10893.1.20.130.11.1.1' => 'temperatureProbeNumber',
2065 '1.3.6.1.4.1.674.10893.1.20.130.11.1.2' => 'temperatureProbeName',
2066 '1.3.6.1.4.1.674.10893.1.20.130.11.1.4' => 'temperatureProbeState',
2067 '1.3.6.1.4.1.674.10893.1.20.130.11.1.6' => 'temperatureProbeUnit',
2068 '1.3.6.1.4.1.674.10893.1.20.130.11.1.9' => 'temperatureProbeMaxWarning',
2069 '1.3.6.1.4.1.674.10893.1.20.130.11.1.10' => 'temperatureProbeMaxCritical',
2070 '1.3.6.1.4.1.674.10893.1.20.130.11.1.11' => 'temperatureProbeCurValue',
2071 '1.3.6.1.4.1.674.10893.1.20.130.11.1.13' => 'temperatureProbeComponentStatus',
2072 '1.3.6.1.4.1.674.10893.1.20.130.11.1.14' => 'temperatureProbeNexusID',
2073 '1.3.6.1.4.1.674.10893.1.20.130.12.1.4' => 'temperatureConnectionEnclosureName',
2074 '1.3.6.1.4.1.674.10893.1.20.130.12.1.5' => 'temperatureConnectionEnclosureNumber',
2076 my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2078 # No enclosure temperature probes is OK
2079 return if !defined $result;
2081 @output = @{ get_snmp_output($result, \%temp_oid) };
2084 foreach my $enc (@enclosures) {
2085 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=temps") };
2086 map_item('ctrl', $enc->{ctrl}, \@output);
2087 map_item('encl_id', $enc->{id}, \@output);
2088 map_item('encl_name', $enc->{name}, \@output);
2103 # Check temperature probes on each of the enclosures
2105 foreach my $out (@output) {
2107 $id = $out->{temperatureProbeNumber} - 1;
2108 $name = $out->{temperatureProbeName};
2109 $state = $temp_state{$out->{temperatureProbeState}};
2110 $status = $snmp_status{$out->{temperatureProbeComponentStatus}};
2111 $unit = $out->{temperatureProbeUnit};
2112 $reading = $out->{temperatureProbeCurValue};
2113 $max_warn = $out->{temperatureProbeMaxWarning};
2114 $max_crit = $out->{temperatureProbeMaxCritical};
2115 $encl_id = $out->{temperatureConnectionEnclosureNumber} - 1;
2116 $encl_name = $out->{temperatureConnectionEnclosureName};
2117 $nexus = convert_nexus($out->{temperatureProbeNexusID});
2121 $name = $out->{'Name'};
2122 $state = $out->{'State'};
2123 $status = $out->{'Status'};
2125 $reading = $out->{'Reading'}; $reading =~ s{\s*C}{}xms;
2126 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\s*C}{}xms;
2127 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\s*C}{}xms;
2128 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2129 $encl_name = $out->{encl_name};
2130 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2133 next TEMP if blacklisted('encl_temp', $nexus);
2136 if ($status ne 'Ok') {
2137 my $msg = sprintf '%s in enclosure %s [%s] is %s C at %s (%s max)',
2138 $name, $encl_id, $encl_name, $state, $reading, $max_crit;
2139 report('storage', $msg, $status2nagios{$status}, $nexus);
2143 my $msg = sprintf '%s in enclosure %s [%s]: %s C (%s max)',
2144 $name, $encl_id, $encl_name, $reading, $max_crit;
2145 report('storage', $msg, $E_OK, $nexus);
2148 # Collect performance data
2149 if (defined $opt{perfdata}) {
2150 $name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
2151 my $pkey = "enclosure_${encl_id}_${name}";
2152 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2153 $perfdata{$pkey} = $pval;
2160 #-----------------------------------------
2161 # STORAGE: Check enclosure management modules (EMM)
2162 #-----------------------------------------
2163 sub check_enclosure_emms {
2164 return if $#controllers == -1;
2171 my $encl_id = undef;
2172 my $encl_name = undef;
2178 '1.3.6.1.4.1.674.10893.1.20.130.13.1.1' => 'enclosureManagementModuleNumber',
2179 '1.3.6.1.4.1.674.10893.1.20.130.13.1.2' => 'enclosureManagementModuleName',
2180 '1.3.6.1.4.1.674.10893.1.20.130.13.1.4' => 'enclosureManagementModuleState',
2181 '1.3.6.1.4.1.674.10893.1.20.130.13.1.11' => 'enclosureManagementModuleComponentStatus',
2182 '1.3.6.1.4.1.674.10893.1.20.130.13.1.12' => 'enclosureManagementModuleNexusID',
2183 '1.3.6.1.4.1.674.10893.1.20.130.14.1.4' => 'enclosureManagementModuleConnectionEnclosureName',
2184 '1.3.6.1.4.1.674.10893.1.20.130.14.1.5' => 'enclosureManagementModuleConnectionEnclosureNumber',
2186 my $result = $snmp_session->get_entries(-columns => [keys %emms_oid]);
2188 # No enclosure EMMs is OK
2189 return if !defined $result;
2191 @output = @{ get_snmp_output($result, \%emms_oid) };
2194 foreach my $enc (@enclosures) {
2195 push @output, @{ run_omreport("storage enclosure controller=$enc->{ctrl} enclosure=$enc->{id} info=emms") };
2196 map_item('ctrl', $enc->{ctrl}, \@output);
2197 map_item('encl_id', $enc->{id}, \@output);
2198 map_item('encl_name', $enc->{name}, \@output);
2209 5 => 'Not Installed',
2214 # Check temperature probes on each of the enclosures
2216 foreach my $out (@output) {
2218 $id = $out->{enclosureManagementModuleNumber} - 1;
2219 $name = $out->{enclosureManagementModuleName};
2220 $state = $emms_state{$out->{enclosureManagementModuleState}};
2221 $status = $snmp_status{$out->{enclosureManagementModuleComponentStatus}};
2222 $encl_id = $out->{enclosureManagementModuleConnectionEnclosureNumber} - 1;
2223 $encl_name = $out->{enclosureManagementModuleConnectionEnclosureName};
2224 $nexus = convert_nexus($out->{enclosureManagementModuleNexusID});
2228 $name = $out->{'Name'};
2229 $state = $out->{'State'};
2230 $status = $out->{'Status'};
2231 $encl_id = join q{:}, $out->{ctrl}, $out->{'encl_id'};
2232 $encl_name = $out->{encl_name};
2233 $nexus = join q{:}, $out->{ctrl}, $out->{'encl_id'}, $id;
2236 next EMM if blacklisted('encl_emm', $nexus);
2239 if ($status ne 'Ok') {
2240 my $msg = sprintf '%s in enclosure %s [%s] needs attention: %s',
2241 $name, $encl_id, $encl_name, $state;
2242 report('storage', $msg, $status2nagios{$status}, $nexus);
2246 my $msg = sprintf '%s in enclosure %s [%s] is %s',
2247 $name, $encl_id, $encl_name, $state;
2248 report('storage', $msg, $E_OK, $nexus);
2255 #-----------------------------------------
2256 # CHASSIS: Check memory modules
2257 #-----------------------------------------
2261 my $location = undef;
2270 '1.3.6.1.4.1.674.10892.1.1100.50.1.2.1' => 'memoryDeviceIndex',
2271 '1.3.6.1.4.1.674.10892.1.1100.50.1.5.1' => 'memoryDeviceStatus',
2272 '1.3.6.1.4.1.674.10892.1.1100.50.1.8.1' => 'memoryDeviceLocationName',
2273 '1.3.6.1.4.1.674.10892.1.1100.50.1.14.1' => 'memoryDeviceSize',
2274 '1.3.6.1.4.1.674.10892.1.1100.50.1.20.1' => 'memoryDeviceFailureModes',
2276 my $result = $snmp_session->get_entries(-columns => [keys %dimm_oid]);
2278 if (!defined $result) {
2279 printf "SNMP ERROR [memory]: %s.\n", $snmp_session->error;
2280 $snmp_session->close;
2284 @output = @{ get_snmp_output($result, \%dimm_oid) };
2287 @output = @{ run_omreport("$omopt_chassis memory") };
2290 # Note: These values are bit masks, so combination values are
2291 # possible. If value is 0 (zero), memory device has no faults.
2294 1 => 'ECC single bit correction warning rate exceeded',
2295 2 => 'ECC single bit correction failure rate exceeded',
2296 4 => 'ECC multibit fault encountered',
2297 8 => 'ECC single bit correction logging disabled',
2298 16 => 'device disabled because of spare activation',
2302 foreach my $out (@output) {
2303 @failures = (); # Initialize
2305 $index = $out->{memoryDeviceIndex};
2306 $status = $snmp_status{$out->{memoryDeviceStatus}};
2307 $location = $out->{memoryDeviceLocationName};
2308 $size = sprintf '%d MB', $out->{memoryDeviceSize}/1024;
2309 $modes = $out->{memoryDeviceFailureModes};
2311 foreach my $mask (sort keys %failure_mode) {
2312 if (($modes & $mask) != 0) { push @failures, $failure_mode{$mask}; }
2317 $index = $out->{'Type'} eq '[Not Occupied]' ? undef : $out->{'Index'};
2318 $status = $out->{'Status'};
2319 $location = $out->{'Connector Name'};
2320 $size = $out->{'Size'};
2321 if (defined $size) {
2322 $size =~ s{\s\s}{ }gxms;
2324 # Run 'omreport chassis memory index=X' to get the failures
2325 if ($status ne 'Ok' && defined $index) {
2326 foreach (@{ run_command("$omreport $omopt_chassis memory index=$index -fmt ssv") }) {
2327 if (m/\A Failures; (.+?) \z/xms) {
2328 chop(my $fail = $1);
2329 push @failures, split m{\.}xms, $fail;
2334 $location =~ s{\A \s*(.*?)\s* \z}{$1}xms;
2336 next DIMM if blacklisted('dimm', $index);
2338 # Ignore empty memory slots
2339 next DIMM if !defined $index;
2342 if ($status ne 'Ok') {
2344 if (scalar @failures == 0) {
2345 $msg = sprintf 'Memory module %d [%s, %s] needs attention (%s)',
2346 $index, $location, $size, $status;
2349 $msg = sprintf 'Memory module %d [%s, %s] needs attention: %s',
2350 $index, $location, $size, (join q{, }, @failures);
2353 report('chassis', $msg, $status2nagios{$status}, $index);
2357 my $msg = sprintf 'Memory module %d [%s, %s] is %s',
2358 $index, $location, $size, $status;
2359 report('chassis', $msg, $E_OK, $index);
2366 #-----------------------------------------
2367 # CHASSIS: Check fans
2368 #-----------------------------------------
2372 my $reading = undef;
2373 my $location = undef;
2374 my $max_crit = undef;
2375 my $max_warn = undef;
2381 '1.3.6.1.4.1.674.10892.1.700.12.1.2.1' => 'coolingDeviceIndex',
2382 '1.3.6.1.4.1.674.10892.1.700.12.1.5.1' => 'coolingDeviceStatus',
2383 '1.3.6.1.4.1.674.10892.1.700.12.1.6.1' => 'coolingDeviceReading',
2384 '1.3.6.1.4.1.674.10892.1.700.12.1.8.1' => 'coolingDeviceLocationName',
2385 '1.3.6.1.4.1.674.10892.1.700.12.1.10.1' => 'coolingDeviceUpperCriticalThreshold',
2386 '1.3.6.1.4.1.674.10892.1.700.12.1.11.1' => 'coolingDeviceUpperNonCriticalThreshold',
2388 my $result = $snmp_session->get_entries(-columns => [keys %cool_oid]);
2390 if ($blade && !defined $result) {
2393 elsif (!$blade && !defined $result) {
2394 printf "SNMP ERROR [cooling]: %s.\n", $snmp_session->error;
2395 $snmp_session->close;
2399 @output = @{ get_snmp_output($result, \%cool_oid) };
2402 @output = @{ run_omreport("$omopt_chassis fans") };
2406 foreach my $out (@output) {
2408 $index = $out->{coolingDeviceIndex};
2409 $status = $snmp_probestatus{$out->{coolingDeviceStatus}};
2410 $reading = $out->{coolingDeviceReading};
2411 $location = $out->{coolingDeviceLocationName};
2412 $max_crit = exists $out->{coolingDeviceUpperCriticalThreshold}
2413 ? $out->{coolingDeviceUpperCriticalThreshold} : 0;
2414 $max_warn = exists $out->{coolingDeviceUpperNonCriticalThreshold}
2415 ? $out->{coolingDeviceUpperNonCriticalThreshold} : 0;
2418 $index = $out->{'Index'};
2419 $status = $out->{'Status'};
2420 $reading = $out->{'Reading'};
2421 $location = $out->{'Probe Name'};
2422 $max_crit = $out->{'Maximum Failure Threshold'} ne '[N/A]'
2423 ? $out->{'Maximum Failure Threshold'} : 0;
2424 $max_warn = $out->{'Maximum Warning Threshold'} ne '[N/A]'
2425 ? $out->{'Maximum Warning Threshold'} : 0;
2426 $reading =~ s{\A (\d+).* \z}{$1}xms;
2427 $max_warn =~ s{\A (\d+).* \z}{$1}xms;
2428 $max_crit =~ s{\A (\d+).* \z}{$1}xms;
2431 next FAN if blacklisted('fan', $index);
2434 if ($status ne 'Ok') {
2435 my $msg = sprintf 'Chassis fan %d [%s] needs attention: %s',
2436 $index, $location, $status;
2437 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2438 report('chassis', $msg, $err, $index);
2441 my $msg = sprintf 'Chassis fan %d [%s]: %s',
2442 $index, $location, $reading;
2443 report('chassis', $msg, $E_OK, $index);
2446 # Collect performance data
2447 if (defined $opt{perfdata}) {
2448 my $pname = lc $location;
2449 $pname =~ s{\s}{_}gxms;
2450 $pname =~ s{proc_}{cpu#}xms;
2451 my $pkey = join q{_}, 'fan', $index, $pname;
2452 my $pval = join q{;}, "${reading}RPM", $max_warn, $max_crit;
2453 $perfdata{$pkey} = $pval;
2460 #-----------------------------------------
2461 # CHASSIS: Check power supplies
2462 #-----------------------------------------
2463 sub check_powersupplies {
2467 my $err_type = undef;
2475 '1.3.6.1.4.1.674.10892.1.600.12.1.2.1' => 'powerSupplyIndex',
2476 '1.3.6.1.4.1.674.10892.1.600.12.1.5.1' => 'powerSupplyStatus',
2477 '1.3.6.1.4.1.674.10892.1.600.12.1.7.1' => 'powerSupplyType',
2478 '1.3.6.1.4.1.674.10892.1.600.12.1.11.1' => 'powerSupplySensorState',
2479 '1.3.6.1.4.1.674.10892.1.600.12.1.12.1' => 'powerSupplyConfigurationErrorType',
2481 my $result = $snmp_session->get_entries(-columns => [keys %ps_oid]);
2483 # No instrumented PSU is OK (blades, low-end servers)
2484 return 0 if !defined $result;
2486 @output = @{ get_snmp_output($result, \%ps_oid) };
2489 @output = @{ run_omreport("$omopt_chassis pwrsupplies") };
2499 6 => 'Uninterruptible Power Supply',
2509 1 => 'Presence detected',
2510 2 => 'Failure detected',
2511 4 => 'Predictive Failure',
2513 16 => 'AC lost or out-of-range',
2514 32 => 'AC out-of-range but present',
2515 64 => 'Configuration error',
2518 my %ps_config_error_type
2520 1 => 'Vendor mismatch',
2521 2 => 'Revision mismatch',
2522 3 => 'Processor missing',
2526 foreach my $out (@output) {
2528 @states = (); # contains states for the PS
2530 $index = $out->{powerSupplyIndex} - 1;
2531 $status = $snmp_status{$out->{powerSupplyStatus}};
2532 $type = $ps_type{$out->{powerSupplyType}};
2533 $err_type = defined $out->{powerSupplyConfigurationErrorType}
2534 ? $ps_config_error_type{$out->{powerSupplyConfigurationErrorType}} : undef;
2536 # get the combined state from the StatusReading OID
2537 foreach my $mask (sort keys %ps_state) {
2538 if (($out->{powerSupplySensorState} & $mask) != 0) {
2539 push @states, $ps_state{$mask};
2543 # If configuration error, also include the error type
2544 if (defined $err_type) {
2545 push @states, $err_type;
2548 # Finally, construct the state string
2549 $state = join q{, }, @states;
2552 $index = $out->{'Index'};
2553 $status = $out->{'Status'};
2554 $type = $out->{'Type'};
2555 $state = $out->{'Online Status'};
2558 next PS if blacklisted('ps', $index);
2561 if ($status ne 'Ok') {
2562 my $msg = sprintf 'Power Supply %d [%s] needs attention: %s',
2563 $index, $type, $state;
2564 report('chassis', $msg, $status2nagios{$status}, $index);
2567 my $msg = sprintf 'Power Supply %d [%s]: %s',
2568 $index, $type, $state;
2569 report('chassis', $msg, $E_OK, $index);
2576 #-----------------------------------------
2577 # CHASSIS: Check temperatures
2578 #-----------------------------------------
2579 sub check_temperatures {
2582 my $reading = undef;
2583 my $location = undef;
2584 my $max_crit = undef;
2585 my $max_warn = undef;
2586 my $min_warn = undef;
2587 my $min_crit = undef;
2589 my $discrete = undef;
2592 # Getting custom temperature thresholds (user option)
2593 my %warn_threshold = %{ custom_temperature_thresholds('w') };
2594 my %crit_threshold = %{ custom_temperature_thresholds('c') };
2599 '1.3.6.1.4.1.674.10892.1.700.20.1.2.1' => 'temperatureProbeIndex',
2600 '1.3.6.1.4.1.674.10892.1.700.20.1.5.1' => 'temperatureProbeStatus',
2601 '1.3.6.1.4.1.674.10892.1.700.20.1.6.1' => 'temperatureProbeReading',
2602 '1.3.6.1.4.1.674.10892.1.700.20.1.7.1' => 'temperatureProbeType',
2603 '1.3.6.1.4.1.674.10892.1.700.20.1.8.1' => 'temperatureProbeLocationName',
2604 '1.3.6.1.4.1.674.10892.1.700.20.1.10.1' => 'temperatureProbeUpperCriticalThreshold',
2605 '1.3.6.1.4.1.674.10892.1.700.20.1.11.1' => 'temperatureProbeUpperNonCriticalThreshold',
2606 '1.3.6.1.4.1.674.10892.1.700.20.1.12.1' => 'temperatureProbeLowerNonCriticalThreshold',
2607 '1.3.6.1.4.1.674.10892.1.700.20.1.13.1' => 'temperatureProbeLowerCriticalThreshold',
2608 '1.3.6.1.4.1.674.10892.1.700.20.1.16.1' => 'temperatureProbeDiscreteReading',
2610 # this didn't work well for some reason
2611 #my $result = $snmp_session->get_entries(-columns => [keys %temp_oid]);
2613 # Getting values using the table
2614 my $temperatureProbeTable = '1.3.6.1.4.1.674.10892.1.700.20';
2615 my $result = $snmp_session->get_table(-baseoid => $temperatureProbeTable);
2617 if (!defined $result) {
2618 printf "SNMP ERROR [temperatures]: %s.\n", $snmp_session->error;
2619 $snmp_session->close;
2623 @output = @{ get_snmp_output($result, \%temp_oid) };
2626 @output = @{ run_omreport("$omopt_chassis temps") };
2631 1 => 'Other', # type is other than following values
2632 2 => 'Unknown', # type is unknown
2633 3 => 'AmbientESM', # type is Ambient Embedded Systems Management temperature probe
2634 16 => 'Discrete', # type is temperature probe with discrete reading
2638 foreach my $out (@output) {
2640 $index = $out->{temperatureProbeIndex} - 1;
2641 $status = $snmp_probestatus{$out->{temperatureProbeStatus}};
2642 $reading = $out->{temperatureProbeReading} / 10;
2643 $location = $out->{temperatureProbeLocationName};
2644 $max_crit = $out->{temperatureProbeUpperCriticalThreshold} / 10;
2645 $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} / 10;
2646 $min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
2647 ? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
2648 $min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
2649 ? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
2650 $type = $probe_type{$out->{temperatureProbeType}};
2651 $discrete = exists $out->{temperatureProbeDiscreteReading}
2652 ? $out->{temperatureProbeDiscreteReading} : undef;
2655 $index = $out->{'Index'};
2656 $status = $out->{'Status'};
2657 $reading = $out->{'Reading'}; $reading =~ s{\.0\s+C}{}xms;
2658 $location = $out->{'Probe Name'};
2659 $max_crit = $out->{'Maximum Failure Threshold'}; $max_crit =~ s{\.0\s+C}{}xms;
2660 $max_warn = $out->{'Maximum Warning Threshold'}; $max_warn =~ s{\.0\s+C}{}xms;
2661 $min_crit = $out->{'Minimum Failure Threshold'}; $min_crit =~ s{\.0\s+C}{}xms;
2662 $min_warn = $out->{'Minimum Warning Threshold'}; $min_warn =~ s{\.0\s+C}{}xms;
2663 $type = $reading =~ m{\A\d+\z}xms ? 'AmbientESM' : 'Discrete';
2664 $discrete = $reading;
2667 next TEMP if blacklisted('temp', $index);
2670 if ($type eq 'Discrete') {
2671 my $msg = sprintf 'Temperature probe %d (%s): is %s',
2672 $index, $location, $discrete;
2673 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2674 report('chassis', $msg, $err, $index);
2677 # First check according to custom thresholds
2678 if (exists $crit_threshold{$index}{max} and $reading > $crit_threshold{$index}{max}) {
2679 # Custom critical MAX
2680 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2681 $index, $location, $reading, $crit_threshold{$index}{max};
2682 report('chassis', $msg, $E_CRITICAL, $index);
2684 elsif (exists $warn_threshold{$index}{max} and $reading > $warn_threshold{$index}{max}) {
2685 # Custom warning MAX
2686 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom max=%d)',
2687 $index, $location, $reading, $warn_threshold{$index}{max};
2688 report('chassis', $msg, $E_WARNING, $index);
2690 elsif (exists $crit_threshold{$index}{min} and $reading < $crit_threshold{$index}{min}) {
2691 # Custom critical MIN
2692 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2693 $index, $location, $reading, $crit_threshold{$index}{min};
2694 report('chassis', $msg, $E_CRITICAL, $index);
2696 elsif (exists $warn_threshold{$index}{min} and $reading < $warn_threshold{$index}{min}) {
2697 # Custom warning MIN
2698 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C (custom min=%d)',
2699 $index, $location, $reading, $warn_threshold{$index}{min};
2700 report('chassis', $msg, $E_WARNING, $index);
2702 elsif ($status ne 'Ok' and $max_crit ne '[N/A]' and $reading > $max_crit) {
2703 my $msg = sprintf 'Temperature Probe %d [%s] is critically high at %d C',
2704 $index, $location, $reading;
2705 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2706 report('chassis', $msg, $err, $index);
2708 elsif ($status ne 'Ok' and $max_warn ne '[N/A]' and $reading > $max_warn) {
2709 my $msg = sprintf 'Temperature Probe %d [%s] is too high at %d C',
2710 $index, $location, $reading;
2711 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2712 report('chassis', $msg, $err, $index);
2714 elsif ($status ne 'Ok' and $min_crit ne '[N/A]' and $reading < $min_crit) {
2715 my $msg = sprintf 'Temperature Probe %d [%s] is critically low at %d C',
2716 $index, $location, $reading;
2717 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2718 report('chassis', $msg, $err, $index);
2720 elsif ($status ne 'Ok' and $min_warn ne '[N/A]' and $reading < $min_warn) {
2721 my $msg = sprintf 'Temperature Probe %d [%s] is too low at %d C',
2722 $index, $location, $reading;
2723 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2724 report('chassis', $msg, $err, $index);
2728 my $msg = sprintf 'Temperature Probe %d [%s] reads %d C',
2729 $index, $location, $reading;
2730 if ($min_warn eq '[N/A]' and $min_crit eq '[N/A]') {
2731 $msg .= sprintf ' (max=%s/%s)', $max_warn, $max_crit;
2734 $msg .= sprintf ' (min=%s/%s, max=%s/%s)',
2735 $min_warn, $min_crit, $max_warn, $max_crit;
2737 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
2738 report('chassis', $msg, $err, $index);
2741 # Collect performance data
2742 if (defined $opt{perfdata}) {
2743 my $pname = lc $location;
2744 $pname =~ s{\s}{_}gxms;
2745 $pname =~ s{_temp\z}{}xms;
2746 $pname =~ s{proc_}{cpu#}xms;
2747 my $pkey = join q{_}, 'temp', $index, $pname;
2748 my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
2749 $perfdata{$pkey} = $pval;
2757 #-----------------------------------------
2758 # CHASSIS: Check processors
2759 #-----------------------------------------
2760 sub check_processors {
2772 # NOTE: For some reason, older models don't have the
2773 # "Processor Device Status" OIDs. We check both the newer
2774 # (preferred) OIDs and the old ones.
2778 '1.3.6.1.4.1.674.10892.1.1100.30.1.2.1' => 'processorDeviceIndex',
2779 '1.3.6.1.4.1.674.10892.1.1100.30.1.5.1' => 'processorDeviceStatus',
2780 '1.3.6.1.4.1.674.10892.1.1100.30.1.8.1' => 'processorDeviceManufacturerName',
2781 '1.3.6.1.4.1.674.10892.1.1100.30.1.9.1' => 'processorDeviceStatusState',
2782 '1.3.6.1.4.1.674.10892.1.1100.30.1.10.1' => 'processorDeviceFamily',
2783 '1.3.6.1.4.1.674.10892.1.1100.30.1.12.1' => 'processorDeviceCurrentSpeed',
2784 '1.3.6.1.4.1.674.10892.1.1100.30.1.23.1' => 'processorDeviceBrandName',
2785 '1.3.6.1.4.1.674.10892.1.1100.32.1.2.1' => 'processorDeviceStatusIndex',
2786 '1.3.6.1.4.1.674.10892.1.1100.32.1.5.1' => 'processorDeviceStatusStatus',
2787 '1.3.6.1.4.1.674.10892.1.1100.32.1.6.1' => 'processorDeviceStatusReading',
2790 my $result = $snmp_session->get_entries(-columns => [keys %cpu_oid]);
2792 if (!defined $result) {
2793 printf "SNMP ERROR [processors]: %s.\n", $snmp_session->error;
2794 $snmp_session->close;
2798 @output = @{ get_snmp_output($result, \%cpu_oid) };
2801 @output = @{ run_omreport("$omopt_chassis processors") };
2806 1 => 'Other', # other than following values
2807 2 => 'Unknown', # unknown
2808 3 => 'Enabled', # enabled
2809 4 => 'User Disabled', # disabled by user via BIOS setup
2810 5 => 'BIOS Disabled', # disabled by BIOS (POST error)
2816 1 => 'Internal Error', # Internal Error
2817 2 => 'Thermal Trip', # Thermal Trip
2818 32 => 'Configuration Error', # Configuration Error
2819 128 => 'Present', # Processor Present
2820 256 => 'Disabled', # Processor Disabled
2821 512 => 'Terminator Present', # Terminator Present
2822 1024 => 'Throttled', # Processor Throttled
2825 # Mapping between family numbers from SNMP and actual CPU family
2828 1 => 'Other', 2 => 'Unknown', 3 => '8086',
2829 4 => '80286', 5 => '386', 6 => '486',
2830 7 => '8087', 8 => '80287', 9 => '80387',
2831 10 => '80487', 11 => 'Pentium', 12 => 'Pentium Pro',
2832 13 => 'Pentium II', 14 => 'Pentium with MMX', 15 => 'Celeron',
2833 16 => 'Pentium II Xeon', 17 => 'Pentium III', 18 => 'Pentium III Xeon',
2834 19 => 'Pentium III', 20 => 'Itanium', 21 => 'Xeon',
2835 22 => 'Pentium 4', 23 => 'Xeon MP', 24 => 'Itanium 2',
2836 25 => 'K5', 26 => 'K6', 27 => 'K6-2',
2837 28 => 'K6-3', 29 => 'Athlon', 30 => 'AMD2900',
2838 31 => 'K6-2+', 32 => 'Power PC', 33 => 'Power PC 601',
2839 34 => 'Power PC 603', 35 => 'Power PC 603+', 36 => 'Power PC 604',
2840 37 => 'Power PC 620', 38 => 'Power PC x704', 39 => 'Power PC 750',
2841 48 => 'Alpha', 49 => 'Alpha 21064', 50 => 'Alpha 21066',
2842 51 => 'Alpha 21164', 52 => 'Alpha 21164PC', 53 => 'Alpha 21164a',
2843 54 => 'Alpha 21264', 55 => 'Alpha 21364', 64 => 'MIPS',
2844 65 => 'MIPS R4000', 66 => 'MIPS R4200', 67 => 'MIPS R4400',
2845 68 => 'MIPS R4600', 69 => 'MIPS R10000', 80 => 'SPARC',
2846 81 => 'SuperSPARC', 82 => 'microSPARC II', 83 => 'microSPARC IIep',
2847 84 => 'UltraSPARC', 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
2848 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi', 96 => '68040',
2849 97 => '68xxx', 98 => '68000', 99 => '68010',
2850 100 => '68020', 101 => '68030', 112 => 'Hobbit',
2851 120 => 'Crusoe TM5000', 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
2852 128 => 'Weitek', 131 => 'Athlon 64', 132 => 'Opteron',
2853 133 => 'Sempron', 134 => 'Turion 64 Mobile', 135 => 'Dual-Core Opteron',
2854 136 => 'Athlon 64 X2 DC', 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
2855 139 => '3rd gen Opteron', 144 => 'PA-RISC', 145 => 'PA-RISC 8500',
2856 146 => 'PA-RISC 8000', 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
2857 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100', 160 => 'V30',
2858 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200', 173 => 'Quad-Core Xeon 7300',
2859 174 => 'Quad-Core Xeon 7400', 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
2860 177 => 'M2', 180 => 'AS400', 182 => 'Athlon XP',
2861 183 => 'Athlon MP', 184 => 'Duron', 185 => 'Pentium M',
2862 186 => 'Celeron D', 187 => 'Pentium D', 188 => 'Pentium Extreme',
2863 189 => 'Core Solo', 190 => 'Core2', 191 => 'Core2 Duo',
2864 198 => 'Core i7', 199 => 'Dual-Core Celeron', 200 => 'IBM390',
2865 201 => 'G4', 202 => 'G5', 203 => 'ESA/390 G6',
2866 204 => 'z/Architectur', 210 => 'C7-M', 211 => 'C7-D',
2867 212 => 'C7', 213 => 'Eden', 214 => 'Multi-Core Xeon',
2868 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx', 218 => 'Dual-Core Xeon 5xxx',
2869 219 => 'Quad-Core Xeon 5xxx', 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
2870 223 => 'Multi-Core Xeon 7xxx', 250 => 'i860', 251 => 'i960',
2874 foreach my $out (@output) {
2876 $index = exists $out->{processorDeviceStatusIndex}
2877 ? $out->{processorDeviceStatusIndex} - 1
2878 : $out->{processorDeviceIndex} - 1;
2879 $status = exists $out->{processorDeviceStatusStatus}
2880 ? $snmp_status{$out->{processorDeviceStatusStatus}}
2881 : $snmp_status{$out->{processorDeviceStatus}};
2882 if (exists $out->{processorDeviceStatusReading}) {
2883 my @states = (); # contains states for the CPU
2885 # get the combined state from the StatusReading OID
2886 foreach my $mask (sort keys %cpu_reading) {
2887 if (($out->{processorDeviceStatusReading} & $mask) != 0) {
2888 push @states, $cpu_reading{$mask};
2892 # Finally, create the state string
2893 $state = join q{, }, @states;
2896 $state = $cpu_state{$out->{processorDeviceStatusState}};
2898 $man = $out->{processorDeviceManufacturerName};
2899 $family = (exists $out->{processorDeviceFamily}
2900 and exists $cpu_family{$out->{processorDeviceFamily}})
2901 ? $cpu_family{$out->{processorDeviceFamily}} : undef;
2902 $speed = $out->{processorDeviceCurrentSpeed};
2903 $brand = $out->{processorDeviceBrandName};
2906 $index = $out->{'Index'};
2907 $status = $out->{'Status'};
2908 $state = $out->{'State'};
2909 $brand = exists $out->{'Processor Brand'} ? $out->{'Processor Brand'} : undef;
2910 $family = exists $out->{'Processor Family'} ? $out->{'Processor Family'} : undef;
2911 $man = exists $out->{'Processor Manufacturer'} ? $out->{'Processor Manufacturer'} : undef;
2912 $speed = exists $out->{'Current Speed'} ? $out->{'Current Speed'} : undef;
2915 next CPU if blacklisted('cpu', $index);
2917 # Ignore unoccupied CPU slots (omreport)
2918 next CPU if (defined $out->{'Processor Manufacturer'}
2919 and $out->{'Processor Manufacturer'} eq '[Not Occupied]')
2920 or (defined $out->{'Processor Brand'} and $out->{'Processor Brand'} eq '[Not Occupied]');
2922 # Ignore unoccupied CPU slots (snmp)
2923 if ($snmp and exists $out->{processorDeviceStatusReading}
2924 and $out->{processorDeviceStatusReading} == 0) {
2930 if (defined $brand) {
2931 $brand =~ s{\s\s+}{ }gxms;
2932 $brand =~ s{\((R|tm)\)}{}gxms;
2933 $brand =~ s{\s(CPU|Processor)}{}xms;
2934 $brand =~ s{\s\@}{}xms;
2936 elsif (defined $family and defined $man and defined $speed) {
2937 $speed =~ s{\A (\d+) .*}{$1}xms;
2938 $brand = sprintf '%s %s %.2fGHz', $man, $family, $speed / 1000;
2945 if ($status ne 'Ok') {
2946 my $msg = sprintf 'Processor %d [%s] needs attention: %s',
2947 $index, $brand, $state;
2948 report('chassis', $msg, $status2nagios{$status}, $index);
2952 my $msg = sprintf 'Processor %d [%s] is %s',
2953 $index, $brand, $state;
2954 report('chassis', $msg, $E_OK, $index);
2961 #-----------------------------------------
2962 # CHASSIS: Check voltage probes
2963 #-----------------------------------------
2967 my $reading = undef;
2968 my $location = undef;
2974 '1.3.6.1.4.1.674.10892.1.600.20.1.2.1' => 'voltageProbeIndex',
2975 '1.3.6.1.4.1.674.10892.1.600.20.1.5.1' => 'voltageProbeStatus',
2976 '1.3.6.1.4.1.674.10892.1.600.20.1.6.1' => 'voltageProbeReading',
2977 '1.3.6.1.4.1.674.10892.1.600.20.1.8.1' => 'voltageProbeLocationName',
2978 '1.3.6.1.4.1.674.10892.1.600.20.1.16.1' => 'voltageProbeDiscreteReading',
2981 my $voltageProbeTable = '1.3.6.1.4.1.674.10892.1.600.20.1';
2982 my $result = $snmp_session->get_table(-baseoid => $voltageProbeTable);
2984 if (!defined $result) {
2985 printf "SNMP ERROR [voltage]: %s.\n", $snmp_session->error;
2986 $snmp_session->close;
2990 @output = @{ get_snmp_output($result, \%volt_oid) };
2993 @output = @{ run_omreport("$omopt_chassis volts") };
2996 my %volt_discrete_reading
3003 foreach my $out (@output) {
3005 $index = $out->{voltageProbeIndex} - 1;
3006 $status = $snmp_status{$out->{voltageProbeStatus}};
3007 $reading = exists $out->{voltageProbeReading}
3008 ? sprintf('%.3f V', $out->{voltageProbeReading}/1000)
3009 : $volt_discrete_reading{$out->{voltageProbeDiscreteReading}};
3010 $location = $out->{voltageProbeLocationName};
3013 $index = $out->{'Index'};
3014 $status = $out->{'Status'};
3015 $reading = $out->{'Reading'};
3016 $location = $out->{'Probe Name'};
3019 next VOLT if blacklisted('volt', $index);
3022 my $msg = sprintf 'Voltage sensor %d [%s] is %s',
3023 $index, $location, $reading;
3024 my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
3025 report('chassis', $msg, $err, $index);
3031 #-----------------------------------------
3032 # CHASSIS: Check batteries
3033 #-----------------------------------------
3034 sub check_batteries {
3037 my $reading = undef;
3038 my $location = undef;
3044 '1.3.6.1.4.1.674.10892.1.600.50.1.2.1' => 'batteryIndex',
3045 '1.3.6.1.4.1.674.10892.1.600.50.1.5.1' => 'batteryStatus',
3046 '1.3.6.1.4.1.674.10892.1.600.50.1.6.1' => 'batteryReading',
3047 '1.3.6.1.4.1.674.10892.1.600.50.1.7.1' => 'batteryLocationName',
3049 my $result = $snmp_session->get_entries(-columns => [keys %bat_oid]);
3051 # No batteries is OK
3052 return 0 if !defined $result;
3054 @output = @{ get_snmp_output($result, \%bat_oid) };
3057 @output = @{ run_omreport("$omopt_chassis batteries") };
3062 1 => 'Predictive Failure',
3064 4 => 'Presence Detected',
3068 foreach my $out (@output) {
3070 $index = $out->{batteryIndex} - 1;
3071 $status = $snmp_status{$out->{batteryStatus}};
3072 $reading = $bat_reading{$out->{batteryReading}};
3073 $location = $out->{batteryLocationName};
3076 $index = $out->{'Index'};
3077 $status = $out->{'Status'};
3078 $reading = $out->{'Reading'};
3079 $location = $out->{'Probe Name'};
3082 next BATTERY if blacklisted('bp', $index);
3085 my $msg = sprintf 'Battery probe %d [%s] is %s',
3086 $index, $location, $reading;
3087 report('chassis', $msg, $status2nagios{$status}, $index);
3093 #-----------------------------------------
3094 # CHASSIS: Check amperage probes (power monitoring)
3095 #-----------------------------------------
3096 sub check_pwrmonitoring {
3099 my $reading = undef;
3100 my $location = undef;
3101 my $max_crit = undef;
3102 my $max_warn = undef;
3109 '1.3.6.1.4.1.674.10892.1.600.30.1.2.1' => 'amperageProbeIndex',
3110 '1.3.6.1.4.1.674.10892.1.600.30.1.5.1' => 'amperageProbeStatus',
3111 '1.3.6.1.4.1.674.10892.1.600.30.1.6.1' => 'amperageProbeReading',
3112 '1.3.6.1.4.1.674.10892.1.600.30.1.7.1' => 'amperageProbeType',
3113 '1.3.6.1.4.1.674.10892.1.600.30.1.8.1' => 'amperageProbeLocationName',
3114 '1.3.6.1.4.1.674.10892.1.600.30.1.10.1' => 'amperageProbeUpperCriticalThreshold',
3115 '1.3.6.1.4.1.674.10892.1.600.30.1.11.1' => 'amperageProbeUpperNonCriticalThreshold',
3116 '1.3.6.1.4.1.674.10892.1.600.30.1.16.1' => 'amperageProbeDiscreteReading',
3118 my $result = $snmp_session->get_entries(-columns => [keys %amp_oid]);
3120 # No pwrmonitoring is OK
3121 return 0 if !defined $result;
3123 @output = @{ get_snmp_output($result, \%amp_oid) };
3126 @output = @{ run_omreport("$omopt_chassis pwrmonitoring") };
3129 my %amp_type # Amperage probe types
3131 1 => 'amperageProbeTypeIsOther', # other than following values
3132 2 => 'amperageProbeTypeIsUnknown', # unknown
3133 3 => 'amperageProbeTypeIs1Point5Volt', # 1.5 amperage probe
3134 4 => 'amperageProbeTypeIs3Point3volt', # 3.3 amperage probe
3135 5 => 'amperageProbeTypeIs5Volt', # 5 amperage probe
3136 6 => 'amperageProbeTypeIsMinus5Volt', # -5 amperage probe
3137 7 => 'amperageProbeTypeIs12Volt', # 12 amperage probe
3138 8 => 'amperageProbeTypeIsMinus12Volt', # -12 amperage probe
3139 9 => 'amperageProbeTypeIsIO', # I/O probe
3140 10 => 'amperageProbeTypeIsCore', # Core probe
3141 11 => 'amperageProbeTypeIsFLEA', # FLEA (standby) probe
3142 12 => 'amperageProbeTypeIsBattery', # Battery probe
3143 13 => 'amperageProbeTypeIsTerminator', # SCSI Termination probe
3144 14 => 'amperageProbeTypeIs2Point5Volt', # 2.5 amperage probe
3145 15 => 'amperageProbeTypeIsGTL', # GTL (ground termination logic) probe
3146 16 => 'amperageProbeTypeIsDiscrete', # amperage probe with discrete reading
3147 23 => 'amperageProbeTypeIsPowerSupplyAmps', # Power Supply probe with reading in Amps
3148 24 => 'amperageProbeTypeIsPowerSupplyWatts', # Power Supply probe with reading in Watts
3149 25 => 'amperageProbeTypeIsSystemAmps', # System probe with reading in Amps
3150 26 => 'amperageProbeTypeIsSystemWatts', # System probe with reading in Watts
3161 'amperageProbeTypeIsPowerSupplyAmps' => 'hA', # tenths of Amps
3162 'amperageProbeTypeIsSystemAmps' => 'hA', # tenths of Amps
3163 'amperageProbeTypeIsPowerSupplyWatts' => 'W', # Watts
3164 'amperageProbeTypeIsSystemWatts' => 'W', # Watts
3165 'amperageProbeTypeIsDiscrete' => q{}, # discrete reading, no unit
3169 foreach my $out (@output) {
3171 $index = $out->{amperageProbeIndex} - 1;
3172 $status = $snmp_status{$out->{amperageProbeStatus}};
3173 $reading = $amp_type{$out->{amperageProbeType}} eq 'amperageProbeTypeIsDiscrete'
3174 ? $amp_discrete{$out->{amperageProbeDiscreteReading}}
3175 : $out->{amperageProbeReading};
3176 $location = $out->{amperageProbeLocationName};
3177 $max_crit = exists $out->{amperageProbeUpperCriticalThreshold}
3178 ? $out->{amperageProbeUpperCriticalThreshold} : 0;
3179 $max_warn = exists $out->{amperageProbeUpperNonCriticalThreshold}
3180 ? $out->{amperageProbeUpperNonCriticalThreshold} : 0;
3181 $unit = exists $amp_unit{$amp_type{$out->{amperageProbeType}}}
3182 ? $amp_unit{$amp_type{$out->{amperageProbeType}}} : 'mA';
3183 if ($unit eq 'hA') {
3191 $index = $out->{'Index'};
3192 next if $index !~ m/^\d+$/x;
3193 $status = $out->{'Status'};
3194 $reading = $out->{'Reading'};
3195 $location = $out->{'Probe Name'};
3196 $max_crit = $out->{'Failure Threshold'} ne '[N/A]'
3197 ? $out->{'Failure Threshold'} : 0;
3198 $max_warn = $out->{'Warning Threshold'} ne '[N/A]'
3199 ? $out->{'Warning Threshold'} : 0;
3200 $reading =~ s{\A (\d+.*?)\s+([a-zA-Z]+) \s*\z}{$1}xms;
3202 $max_warn =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3203 $max_crit =~ s{\A (\d+.*?)\s+[a-zA-Z]+ \s*\z}{$1}xms;
3206 next AMP if blacklisted('amp', $index);
3207 next AMP if $index !~ m{\A \d+ \z}xms;
3210 my $msg = sprintf 'Amperage probe %d [%s] reads %s %s',
3211 $index, $location, $reading, $unit, $status;
3212 report('chassis', $msg, $status2nagios{$status}, $index);
3214 # Collect performance data
3215 if (defined $opt{perfdata}) {
3216 next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
3217 my $pname = lc $location;
3218 $pname =~ s{\s}{_}gxms;
3219 my $pkey = join q{_}, 'pwr_mon', $index, $pname;
3220 my $pval = join q{;}, "$reading$unit", $max_warn, $max_crit;
3221 $perfdata{$pkey} = $pval;
3225 # Collect EXTRA performance data not found at first run. This is a
3227 if (defined $opt{perfdata} && !$snmp) {
3233 foreach (keys %perfdata) {
3234 if (m/\A pwr_mon_(\d+)/xms) {
3240 foreach my $line (@{ run_command("$omreport $omopt_chassis pwrmonitoring -fmt ssv") }) {
3242 if ($line eq 'Location;Reading') {
3250 if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s ([AW]) \z/xms) {
3254 $aname =~ s{\s}{_}gxms;
3256 # don't use an existing index
3257 while (exists $used{$index}) { ++$index; }
3259 $perfdata{"pwr_mon_${index}_${aname}"} = "$aval$aunit;0;0";
3269 #-----------------------------------------
3270 # CHASSIS: Check intrusion
3271 #-----------------------------------------
3272 sub check_intrusion {
3275 my $reading = undef;
3281 '1.3.6.1.4.1.674.10892.1.300.70.1.2.1' => 'intrusionIndex',
3282 '1.3.6.1.4.1.674.10892.1.300.70.1.5.1' => 'intrusionStatus',
3283 '1.3.6.1.4.1.674.10892.1.300.70.1.6.1' => 'intrusionReading',
3285 my $result = $snmp_session->get_entries(-columns => [keys %int_oid]);
3287 # No intrusion is OK
3288 return 0 if !defined $result;
3290 @output = @{ get_snmp_output($result, \%int_oid) };
3293 @output = @{ run_omreport("$omopt_chassis intrusion") };
3298 1 => 'Not Breached', # chassis not breached and no uncleared breaches
3299 2 => 'Breached', # chassis currently breached
3300 3 => 'Breached Prior', # chassis breached prior to boot and has not been cleared
3301 4 => 'Breach Sensor Failure', # intrusion sensor has failed
3305 foreach my $out (@output) {
3307 $index = $out->{intrusionIndex} - 1;
3308 $status = $snmp_status{$out->{intrusionStatus}};
3309 $reading = $int_reading{$out->{intrusionReading}};
3312 $index = $out->{'Index'};
3313 $status = $out->{'Status'};
3314 $reading = $out->{'State'};
3317 next INTRUSION if blacklisted('intr', $index);
3320 if ($status ne 'Ok') {
3321 my $msg = sprintf 'Chassis intrusion %d detected: %s',
3323 report('chassis', $msg, $E_WARNING, $index);
3327 my $msg = sprintf 'Chassis intrusion %d detection: %s (%s)',
3328 $index, $status, $reading;
3329 report('chassis', $msg, $E_OK, $index);
3336 #-----------------------------------------
3337 # CHASSIS: Check alert log
3338 #-----------------------------------------
3339 sub check_alertlog {
3340 return if $snmp; # Not supported with SNMP
3342 my @output = @{ run_omreport("$omopt_system alertlog") };
3343 foreach my $out (@output) {
3344 ++$count{alert}{$out->{Severity}};
3347 # Create error messages and set exit value if appropriate
3349 if ($count{alert}{'Critical'} > 0) { $err = $E_CRITICAL; }
3350 elsif ($count{alert}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3352 my $msg = sprintf 'Alert log content: %d critical, %d non-critical, %d ok',
3353 $count{alert}{'Critical'}, $count{alert}{'Non-Critical'}, $count{alert}{'Ok'};
3354 report('other', $msg, $err);
3359 #-----------------------------------------
3360 # CHASSIS: Check ESM log overall health
3361 #-----------------------------------------
3362 sub check_esmlog_health {
3366 my $systemStateEventLogStatus = '1.3.6.1.4.1.674.10892.1.200.10.1.41.1';
3367 my $result = $snmp_session->get_request(-varbindlist => [$systemStateEventLogStatus]);
3368 if (!defined $result) {
3369 my $msg = sprintf 'SNMP ERROR [esmhealth]: %s',
3370 $snmp_session->error;
3371 report('other', $msg, $E_UNKNOWN);
3373 $health = $snmp_status{$result->{$systemStateEventLogStatus}};
3376 foreach (@{ run_command("$omreport $omopt_system esmlog -fmt ssv") }) {
3377 if (m/\A Health;(.+) \z/xms) {
3385 # If the overall health of the ESM log is other than "Ok", the
3386 # fill grade of the log is more than 80% and the log should be
3388 if ($health eq 'Ok') {
3389 my $msg = sprintf 'ESM log health is Ok (less than 80%% full)';
3390 report('other', $msg, $E_OK);
3392 elsif ($health eq 'Critical') {
3393 my $msg = sprintf 'ESM log is 100%% full';
3394 report('other', $msg, $status2nagios{$health});
3397 my $msg = sprintf 'ESM log is more than 80%% full';
3398 report('other', $msg, $status2nagios{$health});
3404 #-----------------------------------------
3405 # CHASSIS: Check ESM log
3406 #-----------------------------------------
3413 '1.3.6.1.4.1.674.10892.1.300.40.1.7.1' => 'eventLogSeverityStatus',
3415 my $result = $snmp_session->get_entries(-columns => [keys %esm_oid]);
3418 return if !defined $result;
3420 @output = @{ get_snmp_output($result, \%esm_oid) };
3421 foreach my $out (@output) {
3422 ++$count{esm}{$snmp_status{$out->{eventLogSeverityStatus}}};
3426 @output = @{ run_omreport("$omopt_system esmlog") };
3427 foreach my $out (@output) {
3428 ++$count{esm}{$out->{Severity}};
3432 # Create error messages and set exit value if appropriate
3434 if ($count{esm}{'Critical'} > 0) { $err = $E_CRITICAL; }
3435 elsif ($count{esm}{'Non-Critical'} > 0) { $err = $E_WARNING; }
3437 my $msg = sprintf 'ESM log content: %d critical, %d non-critical, %d ok',
3438 $count{esm}{'Critical'}, $count{esm}{'Non-Critical'}, $count{esm}{'Ok'};
3439 report('other', $msg, $err);
3445 # Handy function for checking all storage components
3448 check_controllers();
3449 check_physical_disks();
3450 check_virtual_disks();
3451 check_cache_battery();
3454 check_enclosure_fans();
3455 check_enclosure_pwr();
3456 check_enclosure_temp();
3457 check_enclosure_emms();
3463 #---------------------------------------------------------------------
3465 #---------------------------------------------------------------------
3468 # Fetch output from 'omreport chassis info', put in sysinfo hash
3470 sub get_omreport_chassis_info {
3471 if (open my $INFO, '-|', "$omreport $omopt_chassis info -fmt ssv") {
3472 my @lines = <$INFO>;
3475 next if !m/\A (Chassis\sModel|Chassis\sService\sTag|Model|Service\sTag)/xms;
3476 my ($key, $val) = split /;/xms;
3477 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3478 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3479 if ($key eq 'Chassis Model' or $key eq 'Model') {
3480 $sysinfo{model} = $val;
3482 if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
3483 $sysinfo{serial} = $val;
3491 # Fetch output from 'omreport chassis bios', put in sysinfo hash
3493 sub get_omreport_chassis_bios {
3494 if (open my $BIOS, '-|', "$omreport $omopt_chassis bios -fmt ssv") {
3495 my @lines = <$BIOS>;
3499 my ($key, $val) = split /;/xms;
3500 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3501 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3502 $sysinfo{bios} = $val if $key eq 'Version';
3503 $sysinfo{biosdate} = $val if $key eq 'Release Date';
3510 # Fetch output from 'omreport system operatingsystem', put in sysinfo hash
3512 sub get_omreport_system_operatingsystem {
3513 if (open my $VER, '-|', "$omreport $omopt_system operatingsystem -fmt ssv") {
3518 my ($key, $val) = split /;/xms;
3519 $key =~ s{\s+\z}{}xms; # remove trailing whitespace
3520 $val =~ s{\s+\z}{}xms; # remove trailing whitespace
3521 if ($key eq 'Operating System') {
3522 $sysinfo{osname} = $val;
3524 elsif ($key eq 'Operating System Version') {
3525 $sysinfo{osver} = $val;
3533 # Fetch output from 'omreport about', put in sysinfo hash
3535 sub get_omreport_about {
3536 if (open my $OM, '-|', "$omreport about -fmt ssv") {
3540 if (m/\A Version;(.+) \z/xms) {
3550 # Fetch chassis info via SNMP, put in sysinfo hash
3552 sub get_snmp_chassis_info {
3555 '1.3.6.1.4.1.674.10892.1.300.10.1.9.1' => 'chassisModelName',
3556 '1.3.6.1.4.1.674.10892.1.300.10.1.11.1' => 'chassisServiceTagName',
3559 my $chassisInformationTable = '1.3.6.1.4.1.674.10892.1.300.10.1';
3560 my $result = $snmp_session->get_table(-baseoid => $chassisInformationTable);
3562 if (defined $result) {
3563 foreach my $oid (keys %{ $result }) {
3564 if (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisModelName') {
3565 $sysinfo{model} = $result->{$oid};
3566 $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
3568 elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
3569 $sysinfo{serial} = $result->{$oid};
3574 my $msg = sprintf 'SNMP ERROR getting chassis info: %s',
3575 $snmp_session->error;
3576 report('other', $msg, $E_UNKNOWN);
3582 # Fetch BIOS info via SNMP, put in sysinfo hash
3584 sub get_snmp_chassis_bios {
3587 '1.3.6.1.4.1.674.10892.1.300.50.1.7.1.1' => 'systemBIOSReleaseDateName',
3588 '1.3.6.1.4.1.674.10892.1.300.50.1.8.1.1' => 'systemBIOSVersionName',
3591 my $systemBIOSTable = '1.3.6.1.4.1.674.10892.1.300.50.1';
3592 my $result = $snmp_session->get_table(-baseoid => $systemBIOSTable);
3594 if (defined $result) {
3595 foreach my $oid (keys %{ $result }) {
3596 if (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSReleaseDateName') {
3597 $sysinfo{biosdate} = $result->{$oid};
3598 $sysinfo{biosdate} =~ s{\A (\d{4})(\d{2})(\d{2}).*}{$2/$3/$1}xms;
3600 elsif (exists $bios_oid{$oid} and $bios_oid{$oid} eq 'systemBIOSVersionName') {
3601 $sysinfo{bios} = $result->{$oid};
3606 my $msg = sprintf 'SNMP ERROR getting BIOS info: %s',
3607 $snmp_session->error;
3608 report('other', $msg, $E_UNKNOWN);
3614 # Fetch OS info via SNMP, put in sysinfo hash
3616 sub get_snmp_system_operatingsystem {
3619 '1.3.6.1.4.1.674.10892.1.400.10.1.6.1' => 'operatingSystemOperatingSystemName',
3620 '1.3.6.1.4.1.674.10892.1.400.10.1.7.1' => 'operatingSystemOperatingSystemVersionName',
3623 my $operatingSystemTable = '1.3.6.1.4.1.674.10892.1.400.10.1';
3624 my $result = $snmp_session->get_table(-baseoid => $operatingSystemTable);
3626 if (defined $result) {
3627 foreach my $oid (keys %{ $result }) {
3628 if (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemName') {
3629 $sysinfo{osname} = ($result->{$oid});
3631 elsif (exists $os_oid{$oid} and $os_oid{$oid} eq 'operatingSystemOperatingSystemVersionName') {
3632 $sysinfo{osver} = $result->{$oid};
3637 my $msg = sprintf 'SNMP ERROR getting OS info: %s',
3638 $snmp_session->error;
3639 report('other', $msg, $E_UNKNOWN);
3645 # Fetch OMSA version via SNMP, put in sysinfo hash
3647 sub get_snmp_about {
3650 '1.3.6.1.4.1.674.10892.1.100.10.0' => 'systemManagementSoftwareGlobalVersionName',
3652 my $systemManagementSoftwareGroup = '1.3.6.1.4.1.674.10892.1.100';
3653 my $result = $snmp_session->get_table(-baseoid => $systemManagementSoftwareGroup);
3654 if (defined $result) {
3655 foreach my $oid (keys %{ $result }) {
3656 if (exists $omsa_oid{$oid} and $omsa_oid{$oid} eq 'systemManagementSoftwareGlobalVersionName') {
3657 $sysinfo{om} = ($result->{$oid});
3662 my $msg = sprintf 'SNMP ERROR getting OMSA info: %s',
3663 $snmp_session->error;
3664 report('other', $msg, $E_UNKNOWN);
3670 # Collects some information about the system
3674 # Get system model and serial number
3675 $snmp ? get_snmp_chassis_info() : get_omreport_chassis_info();
3677 # Get BIOS information. Only if needed
3678 if ( $opt{okinfo} >= 1
3680 or (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][bd]/xms) ) {
3681 $snmp ? get_snmp_chassis_bios() : get_omreport_chassis_bios();
3684 # Get OMSA information. Only if needed
3685 if ($opt{okinfo} >= 3 or $opt{debug}) {
3686 $snmp ? get_snmp_about() : get_omreport_about();
3689 # Return now if debug
3690 return if $opt{debug};
3692 # Get OS information. Only if needed
3693 if (defined $opt{postmsg} and $opt{postmsg} =~ m/[%][or]/xms) {
3694 $snmp ? get_snmp_system_operatingsystem() : get_omreport_system_operatingsystem();
3701 # Helper function for running omreport when the results are strictly
3703 sub run_omreport_info {
3704 my $command = shift;
3708 # Run omreport and fetch output
3709 my $rawtext = slurp_command("$omreport $command -fmt ssv 2>&1");
3711 # Parse output, store in array
3712 for ((split /\n/xms, $rawtext)) {
3713 if (m/\A Error/xms) {
3714 my $msg = "Problem running 'omreport $command': $_";
3715 report('other', $msg, $E_UNKNOWN);
3717 next if !m/;/xms; # ignore lines with less than two fields
3718 my @vals = split m/;/xms;
3719 $output{$vals[0]} = $vals[1];
3722 # Finally, return the collected information
3726 # Get various firmware information (BMC, RAC)
3727 sub get_firmware_info {
3728 my @snmp_output = ();
3729 my %nrpe_output = ();
3734 '1.3.6.1.4.1.674.10892.1.300.60.1.7.1' => 'firmwareType',
3735 '1.3.6.1.4.1.674.10892.1.300.60.1.8.1' => 'firmwareTypeName',
3736 '1.3.6.1.4.1.674.10892.1.300.60.1.11.1' => 'firmwareVersionName',
3739 my $firmwareTable = '1.3.6.1.4.1.674.10892.1.300.60.1';
3740 my $result = $snmp_session->get_table(-baseoid => $firmwareTable);
3742 # Some don't have this OID, this is ok
3743 if (!defined $result) {
3747 @snmp_output = @{ get_snmp_output($result, \%fw_oid) };
3750 %nrpe_output = %{ run_omreport_info("$omopt_chassis info") };
3753 my %fw_type # Firmware types
3755 1 => 'other', # other than following values
3756 2 => 'unknown', # unknown
3757 3 => 'systemBIOS', # System BIOS
3758 4 => 'embeddedSystemManagementController', # Embedded System Management Controller
3759 5 => 'powerSupplyParallelingBoard', # Power Supply Paralleling Board
3760 6 => 'systemBackPlane', # System (Primary) Backplane
3761 7 => 'powerVault2XXSKernel', # PowerVault 2XXS Kernel
3762 8 => 'powerVault2XXSApplication', # PowerVault 2XXS Application
3763 9 => 'frontPanel', # Front Panel Controller
3764 10 => 'baseboardManagementController', # Baseboard Management Controller
3765 11 => 'hotPlugPCI', # Hot Plug PCI Controller
3766 12 => 'sensorData', # Sensor Data Records
3767 13 => 'peripheralBay', # Peripheral Bay Backplane
3768 14 => 'secondaryBackPlane', # Secondary Backplane for ESM 2 systems
3769 15 => 'secondaryBackPlaneESM3And4', # Secondary Backplane for ESM 3 and 4 systems
3770 16 => 'rac', # Remote Access Controller
3771 17 => 'imc' # Integrated Management Controller
3776 foreach my $out (@snmp_output) {
3777 if ($fw_type{$out->{firmwareType}} eq 'baseboardManagementController') {
3778 $sysinfo{'bmc'} = 1;
3779 $sysinfo{'bmc_fw'} = $out->{firmwareVersionName};
3781 elsif ($fw_type{$out->{firmwareType}} =~ m{\A rac|imc \z}xms) {
3782 my $name = $out->{firmwareTypeName}; $name =~ s/\s//gxms;
3783 $sysinfo{'rac'} = 1;
3784 $sysinfo{'rac_name'} = $name;
3785 $sysinfo{'rac_fw'} = $out->{firmwareVersionName};
3790 foreach my $key (keys %nrpe_output) {
3791 next if !defined $nrpe_output{$key};
3792 if ($key eq 'BMC Version' or $key eq 'Baseboard Management Controller Version') {
3793 $sysinfo{'bmc'} = 1;
3794 $sysinfo{'bmc_fw'} = $nrpe_output{$key};
3796 elsif ($key =~ m{\A (i?DRAC)\s*(\d?)\s+Version}xms) {
3798 $sysinfo{'rac'} = 1;
3799 $sysinfo{'rac_fw'} = $nrpe_output{$key};
3800 $sysinfo{'rac_name'} = $name;
3810 #=====================================================================
3812 #=====================================================================
3814 # Here we do the actual checking of components
3815 # Check global status if applicable
3817 $globalstatus = check_global();
3820 # Do multiple selected checks
3821 if ($check{storage}) { check_storage(); }
3822 if ($check{memory}) { check_memory(); }
3823 if ($check{fans}) { check_fans(); }
3824 if ($check{power}) { check_powersupplies(); }
3825 if ($check{temp}) { check_temperatures(); }
3826 if ($check{cpu}) { check_processors(); }
3827 if ($check{voltage}) { check_volts(); }
3828 if ($check{batteries}) { check_batteries(); }
3829 if ($check{amperage}) { check_pwrmonitoring(); }
3830 if ($check{intrusion}) { check_intrusion(); }
3831 if ($check{alertlog}) { check_alertlog(); }
3832 if ($check{esmlog}) { check_esmlog(); }
3833 if ($check{esmhealth}) { check_esmlog_health(); }
3836 #---------------------------------------------------------------------
3838 #---------------------------------------------------------------------
3849 # Get system information
3852 # Get firmware info if requested via option
3853 if ($opt{okinfo} >= 1) {
3854 get_firmware_info();
3857 # Close SNMP session
3859 $snmp_session->close;
3864 print " System: $sysinfo{model}\n";
3865 print " ServiceTag: $sysinfo{serial}";
3866 print q{ } x (25 - length $sysinfo{serial}), "OMSA version: $sysinfo{om}\n";
3867 print " BIOS/date: $sysinfo{bios} $sysinfo{biosdate}";
3868 print q{ } x (25 - length "$sysinfo{bios} $sysinfo{biosdate}"), "Plugin version: $VERSION\n";
3869 if ($#report_storage >= 0) {
3870 print "-----------------------------------------------------------------------------\n";
3871 print " Storage Components \n";
3872 print "=============================================================================\n";
3873 print " STATE | ID | MESSAGE TEXT \n";
3874 print "---------+----------+--------------------------------------------------------\n";
3875 foreach (@report_storage) {
3876 my ($msg, $level, $nexus) = @{$_};
3877 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
3878 . q{ } x (8 - length $nexus) . "$nexus | $msg\n";
3879 $nagios_alert_count{$reverse_exitcode{$level}}++;
3882 if ($#report_chassis >= 0) {
3883 print "-----------------------------------------------------------------------------\n";
3884 print " Chassis Components \n";
3885 print "=============================================================================\n";
3886 print " STATE | ID | MESSAGE TEXT \n";
3887 print "---------+------+------------------------------------------------------------\n";
3888 foreach (@report_chassis) {
3889 my ($msg, $level, $nexus) = @{$_};
3890 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | "
3891 . q{ } x (4 - length $nexus) . "$nexus | $msg\n";
3892 $nagios_alert_count{$reverse_exitcode{$level}}++;
3895 if ($#report_other >= 0) {
3896 print "-----------------------------------------------------------------------------\n";
3897 print " Other messages \n";
3898 print "=============================================================================\n";
3899 print " STATE | MESSAGE TEXT \n";
3900 print "---------+-------------------------------------------------------------------\n";
3901 foreach (@report_other) {
3902 my ($msg, $level, $nexus) = @{$_};
3903 print q{ } x (8 - length $reverse_exitcode{$level}) . "$reverse_exitcode{$level} | $msg\n";
3904 $nagios_alert_count{$reverse_exitcode{$level}}++;
3909 my $c = 0; # counter to determine linebreaks
3911 # Run through each message, sorted by severity level
3913 foreach (sort {$a->[1] < $b->[1]} (@report_storage, @report_chassis, @report_other)) {
3914 my ($msg, $level, $nexus) = @{ $_ };
3915 next ALERT if $level == $E_OK;
3917 if (defined $opt{only}) {
3918 # If user wants only critical alerts
3919 next ALERT if ($opt{only} eq 'critical' and $level == $E_WARNING);
3921 # If user wants only warning alerts
3922 next ALERT if ($opt{only} eq 'warning' and $level == $E_CRITICAL);
3925 # Prefix with service tag if specified with option '-i|--info'
3927 if (defined $opt{htmlinfo}) {
3928 $msg = '[<a href="' . warranty_url($sysinfo{serial})
3929 . "\">$sysinfo{serial}</a>] " . $msg;
3932 $msg = "[$sysinfo{serial}] " . $msg;
3936 # Prefix with nagios level if specified with option '--state'
3937 $msg = $reverse_exitcode{$level} . ": $msg" if $opt{state};
3939 # Prefix with one-letter nagios level if specified with option '--short-state'
3940 $msg = (substr $reverse_exitcode{$level}, 0, 1) . ": $msg" if $opt{shortstate};
3942 ($c++ == 0) ? print $msg : print $linebreak, $msg;
3944 $nagios_alert_count{$reverse_exitcode{$level}}++;
3948 # Determine our exit code
3950 $exit_code = $E_UNKNOWN if $nagios_alert_count{'UNKNOWN'} > 0;
3951 $exit_code = $E_WARNING if $nagios_alert_count{'WARNING'} > 0;
3952 $exit_code = $E_CRITICAL if $nagios_alert_count{'CRITICAL'} > 0;
3954 # Global status via SNMP.. extra safety check
3955 if ($globalstatus != $E_OK && $exit_code == $E_OK && !defined $opt{only}) {
3956 print "OOPS! Something is wrong with this server, but I don't know what. ";
3957 print "The global system health status is $reverse_exitcode{$globalstatus}, ";
3958 print "but every component check is OK. This may be a bug in the Nagios plugin, ";
3959 print "please file a bug report.\n";
3964 if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|warning|chassis \z}xms && !$opt{debug}) {
3966 = ( 'storage' => "STORAGE OK - $count{pdisk} physical drives, $count{vdisk} logical drives",
3967 'fans' => $count{fan} == 0 && $blade ? 'OK - blade system with no fan probes' : "FANS OK - $count{fan} fan probes checked",
3968 'temp' => "TEMPERATURES OK - $count{temp} temperature probes checked",
3969 'memory' => "MEMORY OK - $count{dimm} memory modules checked",
3970 'power' => $count{power} == 0 ? 'OK - no instrumented power supplies found' : "POWER OK - $count{power} power supplies checked",
3971 'cpu' => "PROCESSORS OK - $count{cpu} processors checked",
3972 'voltage' => "VOLTAGE OK - $count{volt} voltage probes checked",
3973 'batteries' => $count{bat} == 0 ? 'OK - no batteries found' : "BATTERIES OK - $count{bat} batteries checked",
3974 'amperage' => $count{amp} == 0 ? 'OK - no power monitoring probes found' : "AMPERAGE OK - $count{amp} amperage (power monitoring) probes checked",
3975 'intrusion' => $count{intr} == 0 ? 'OK - no intrusion detection probes found' : "INTRUSION OK - $count{intr} intrusion detection probes checked",
3976 '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",
3977 'esmlog' => "OK - ESM Log content: $count{esm}{Ok} ok, $count{esm}{'Non-Critical'} warning and $count{esm}{Critical} critical",
3978 'esmhealth' => "ESM LOG OK - less than 80% used",
3981 print $okmsg{$opt{only}};
3983 elsif ($exit_code == $E_OK && !$opt{debug}) {
3984 if (defined $opt{htmlinfo}) {
3985 printf q{OK - System: '<a href="%s">%s</a>', SN: '<a href="%s">%s</a>', hardware working fine},
3986 documentation_url($sysinfo{model}), $sysinfo{model},
3987 warranty_url($sysinfo{serial}), $sysinfo{serial};
3990 printf q{OK - System: '%s', SN: '%s', hardware working fine},
3991 $sysinfo{model}, $sysinfo{serial};
3994 if ($check{storage}) {
3995 printf ', %d logical drives, %d physical drives',
3996 $count{vdisk}, $count{pdisk};
3999 print ', not checking storage';
4002 if ($opt{okinfo} >= 1) {
4004 printf q{----- BIOS='%s %s'}, $sysinfo{bios}, $sysinfo{biosdate};
4006 if ($sysinfo{rac}) {
4007 printf q{, %s='%s'}, $sysinfo{rac_name}, $sysinfo{rac_fw};
4009 if ($sysinfo{bmc}) {
4010 printf q{, BMC='%s'}, $sysinfo{bmc_fw};
4014 if ($opt{okinfo} >= 2) {
4015 if ($check{storage}) {
4016 my @storageprint = ();
4017 foreach my $id (sort keys %{ $sysinfo{controller} }) {
4018 chomp $sysinfo{controller}{$id}{driver};
4019 push @storageprint, sprintf q{----- CTRL %s (%s): FW='%s', DR='%s'},
4020 $sysinfo{controller}{$id}{id}, $sysinfo{controller}{$id}{name},
4021 $sysinfo{controller}{$id}{firmware}, $sysinfo{controller}{$id}{driver};
4023 foreach my $id (sort keys %{ $sysinfo{enclosure} }) {
4024 push @storageprint, sprintf q{----- ENCL %s (%s): FW='%s'},
4025 $sysinfo{enclosure}{$id}->{id}, $sysinfo{enclosure}{$id}->{name},
4026 $sysinfo{enclosure}{$id}->{firmware};
4030 foreach my $line (@storageprint) {
4031 print $linebreak, $line;
4036 if ($opt{okinfo} >= 3) {
4037 print "$linebreak----- OpenManage Server Administrator (OMSA) version: '$sysinfo{om}'";
4042 if ($opt{extinfo}) {
4044 if (defined $opt{htmlinfo}) {
4045 printf '------ SYSTEM: <a href="%s">%s</a>, SN: <a href="%s">%s</a>',
4046 documentation_url($sysinfo{model}), $sysinfo{model},
4047 warranty_url($sysinfo{serial}), $sysinfo{serial};
4050 printf '------ SYSTEM: %s, SN: %s',
4051 $sysinfo{model}, $sysinfo{serial};
4054 if (defined $opt{postmsg}) {
4056 if (-f $opt{postmsg}) {
4057 open my $POST, '<', $opt{postmsg}
4058 or ( print $linebreak
4059 and print "ERROR: Couldn't open post message file $opt{postmsg}: $!\n"
4060 and exit $E_UNKNOWN );
4066 $post = $opt{postmsg};
4068 if (defined $post) {
4070 $post =~ s{[%]s}{$sysinfo{serial}}gxms;
4071 $post =~ s{[%]m}{$sysinfo{model}}gxms;
4072 $post =~ s{[%]b}{$sysinfo{bios}}gxms;
4073 $post =~ s{[%]d}{$sysinfo{biosdate}}gxms;
4074 $post =~ s{[%]o}{$sysinfo{osname}}gxms;
4075 $post =~ s{[%]r}{$sysinfo{osver}}gxms;
4076 $post =~ s{[%]p}{$count{pdisk}}gxms;
4077 $post =~ s{[%]l}{$count{vdisk}}gxms;
4078 $post =~ s{[%]n}{$linebreak}gxms;
4079 $post =~ s{[%]{2}}{%}gxms;
4085 # Print performance data
4086 if (defined $opt{perfdata} && !$opt{debug} && %perfdata) {
4087 my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
4098 return ($order{(split /_/, $a, 2)[0]} cmp $order{(split /_/, $b, 2)[0]}) || $a cmp $b;
4101 print join $lb, map { "'$_'=$perfdata{$_}" } sort perfdata keys %perfdata;
4104 # Print a linebreak at the end
4105 print "\n" if !$opt{debug};
4107 # Exit with proper exit code