$E_UNKNOWN $FW_LOCK $USAGE $HELP $LICENSE
$snmp_session $snmp_error $omreport $globalstatus $global
$linebreak $omopt_chassis $omopt_system $blade
- $exit_code $snmp $original_sigwarn
- %check %opt %perfdata %reverse_exitcode %status2nagios
+ $exit_code $snmp
+ %check %opt %reverse_exitcode %status2nagios
%snmp_status %snmp_probestatus %probestatus2nagios %sysinfo
%blacklist %nagios_alert_count %count
- @perl_warnings @controllers @enclosures
+ @perl_warnings @controllers @enclosures @perfdata
@report_storage @report_chassis @report_other
);
# Initialization and global variables
#---------------------------------------------------------------------
-# Small subroutine to collect any perl warnings during execution
-sub collect_perl_warning {
- push @perl_warnings, [@_];
-}
-
-# Set the WARN signal to use our collect subroutine above
-$original_sigwarn = $SIG{__WARN__};
-$SIG{__WARN__} = \&collect_perl_warning;
+# Collect perl warnings in an array
+$SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
# Version and similar info
$NAME = 'check_openmanage';
-$VERSION = '3.5.7-beta13';
+$VERSION = '3.5.8-beta2';
$AUTHOR = 'Trond H. Amundsen';
$CONTACT = 't.h.amundsen@usit.uio.no';
SNMP OPTIONS:
- -H, --hostname Hostname or IP of the server (needed for SNMP)
+ -H, --hostname Hostname or IP (required for SNMP)
-C, --community SNMP community string
-P, --protocol SNMP protocol version
--port SNMP port number
# Setting timeout
$SIG{ALRM} = sub {
- print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds";
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#plugin-timeout-check-openmanage-timed-out-after-30-seconds
- print ' [<a href="http://bit.ly/bPOygB">more info</a>]';
- }
- print "\n";
+ print "PLUGIN TIMEOUT: $NAME timed out after $opt{timeout} seconds\n";
exit $E_UNKNOWN;
};
alarm $opt{timeout};
);
# Performance data
-%perfdata = ();
+@perfdata = ();
# Global health status
$global = 1; # default is to check global status
}
}
else {
- print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode";
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#error-you-need-perl-module-net-snmp-to-run-check-openmanage-in-snmp-mode
- print ' [<a href="http://bit.ly/b4F0q1">more info</a>]';
- }
- print "\n";
+ print "ERROR: You need perl module Net::SNMP to run $NAME in SNMP mode\n";
exit $E_UNKNOWN;
}
return;
# Typically if remote host isn't responding
if (!defined $result) {
- printf "SNMP CRITICAL: %s", $snmp_session->error;
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#snmp-critical-no-response-from-remote-host-10-1-2-3
- print ' [<a href="http://bit.ly/bRyk4B">more info</a>]';
- }
- print "\n";
+ printf "SNMP CRITICAL: %s\n", $snmp_session->error;
exit $E_CRITICAL;
}
# If OpenManage isn't installed or is not working
if ($result->{$chassisModelName} =~ m{\A noSuch (Instance|Object) \z}xms) {
- print "ERROR: (SNMP) OpenManage is not installed or is not working correctly";
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#error-snmp-openmanage-is-not-installed-or-is-not-working-correctly
- print ' [<a href="http://bit.ly/c7oKcK">more info</a>]';
- }
- print "\n";
+ print "ERROR: (SNMP) OpenManage is not installed or is not working correctly\n";
exit $E_UNKNOWN;
}
return;
# Exit with status=UNKNOWN if OM is not installed, or we don't
# have permission to execute the binary
if (!defined $omreport) {
- print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed";
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#error-dell-openmanage-server-administrator-omsa-is-not-installed
- print ' [<a href="http://bit.ly/a4M8Z6">more info</a>]';
- }
- print "\n";
+ print "ERROR: Dell OpenManage Server Administrator (OMSA) is not installed\n";
exit $E_UNKNOWN;
}
return;
# Collect performance data
if (defined $opt{perfdata}) {
$name =~ s{\A Temperature\sProbe\s(\d+) \z}{temp_$1}gxms;
- my $pkey = "enclosure_${encl_id}_${name}";
- my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
- $perfdata{$pkey} = $pval;
+ my $label = "enclosure_${encl_id}_${name}";
+ my $mini = $label;
+ $mini =~ s{enclosure_(.+?)_temp_(.+?)}{e$1t$2}xms;
+ push @perfdata, {
+ label => $label,
+ mini => $mini,
+ value => $reading,
+ warn => $max_warn,
+ crit => $max_crit,
+ };
}
}
return;
my $pname = lc $location;
$pname =~ s{\s}{_}gxms;
$pname =~ s{proc_}{cpu#}xms;
- my $pkey = join q{_}, 'fan', $index, $pname;
- my $pval = join q{;}, "${reading}RPM", $max_warn, $max_crit;
- $perfdata{$pkey} = $pval;
+ push @perfdata, {
+ label => "fan_${index}_${pname}",
+ mini => "f$index",
+ value => $reading,
+ warn => $max_warn,
+ crit => $max_crit,
+ };
}
}
return;
if ($snmp) {
$index = $out->{temperatureProbeIndex} - 1;
$status = $snmp_probestatus{$out->{temperatureProbeStatus}};
- $reading = $out->{temperatureProbeReading} / 10;
$location = $out->{temperatureProbeLocationName};
- $max_crit = $out->{temperatureProbeUpperCriticalThreshold} / 10;
- $max_warn = $out->{temperatureProbeUpperNonCriticalThreshold} / 10;
+ $reading = exists $out->{temperatureProbeReading}
+ ? $out->{temperatureProbeReading} / 10 : '[N/A]';
+ $max_crit = exists $out->{temperatureProbeUpperCriticalThreshold}
+ ? $out->{temperatureProbeUpperCriticalThreshold} / 10 : '[N/A]';
+ $max_warn = exists $out->{temperatureProbeUpperNonCriticalThreshold}
+ ? $out->{temperatureProbeUpperNonCriticalThreshold} / 10 : '[N/A]';
$min_crit = exists $out->{temperatureProbeLowerCriticalThreshold}
? $out->{temperatureProbeLowerCriticalThreshold} / 10 : '[N/A]';
$min_warn = exists $out->{temperatureProbeLowerNonCriticalThreshold}
? $out->{temperatureProbeLowerNonCriticalThreshold} / 10 : '[N/A]';
$type = get_hashval($out->{temperatureProbeType}, \%probe_type);
$discrete = exists $out->{temperatureProbeDiscreteReading}
- ? $out->{temperatureProbeDiscreteReading} : undef;
+ ? $out->{temperatureProbeDiscreteReading} : '[N/A]';
+ # workaround for bad temp probes
+ if ($type eq 'AmbientESM' and $reading !~ m{\A \d+(\.\d+)? \z}xms) {
+ $type = 'Discrete';
+ }
}
else {
$index = $out->{'Index'};
$count{temp}++;
if ($type eq 'Discrete') {
- my $msg = sprintf 'Temperature probe %d (%s): is %s',
+ my $msg = sprintf 'Temperature probe %d [%s] is %s',
$index, $location, $discrete;
my $err = $snmp ? $probestatus2nagios{$status} : $status2nagios{$status};
report('chassis', $msg, $err, $index);
$pname =~ s{\s}{_}gxms;
$pname =~ s{_temp\z}{}xms;
$pname =~ s{proc_}{cpu#}xms;
- my $pkey = join q{_}, 'temp', $index, $pname;
- my $pval = join q{;}, "${reading}C", $max_warn, $max_crit;
- $perfdata{$pkey} = $pval;
+ push @perfdata, {
+ label => "temp_${index}_${pname}",
+ mini => "t$index",
+ value => $reading,
+ warn => $max_warn,
+ crit => $max_crit,
+ };
}
}
}
# Mapping between family numbers from SNMP and actual CPU family
my %cpu_family
= (
- 1 => 'Other', 2 => 'Unknown', 3 => '8086',
- 4 => '80286', 5 => '386', 6 => '486',
- 7 => '8087', 8 => '80287', 9 => '80387',
- 10 => '80487', 11 => 'Pentium', 12 => 'Pentium Pro',
- 13 => 'Pentium II', 14 => 'Pentium with MMX', 15 => 'Celeron',
- 16 => 'Pentium II Xeon', 17 => 'Pentium III', 18 => 'Pentium III Xeon',
- 19 => 'Pentium III', 20 => 'Itanium', 21 => 'Xeon',
- 22 => 'Pentium 4', 23 => 'Xeon MP', 24 => 'Itanium 2',
- 25 => 'K5', 26 => 'K6', 27 => 'K6-2',
- 28 => 'K6-3', 29 => 'Athlon', 30 => 'AMD2900',
- 31 => 'K6-2+', 32 => 'Power PC', 33 => 'Power PC 601',
- 34 => 'Power PC 603', 35 => 'Power PC 603+', 36 => 'Power PC 604',
- 37 => 'Power PC 620', 38 => 'Power PC x704', 39 => 'Power PC 750',
- 48 => 'Alpha', 49 => 'Alpha 21064', 50 => 'Alpha 21066',
- 51 => 'Alpha 21164', 52 => 'Alpha 21164PC', 53 => 'Alpha 21164a',
- 54 => 'Alpha 21264', 55 => 'Alpha 21364', 64 => 'MIPS',
- 65 => 'MIPS R4000', 66 => 'MIPS R4200', 67 => 'MIPS R4400',
- 68 => 'MIPS R4600', 69 => 'MIPS R10000', 80 => 'SPARC',
- 81 => 'SuperSPARC', 82 => 'microSPARC II', 83 => 'microSPARC IIep',
- 84 => 'UltraSPARC', 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
- 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi', 96 => '68040',
- 97 => '68xxx', 98 => '68000', 99 => '68010',
- 100 => '68020', 101 => '68030', 112 => 'Hobbit',
- 120 => 'Crusoe TM5000', 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
- 128 => 'Weitek', 131 => 'Athlon 64', 132 => 'Opteron',
- 133 => 'Sempron', 134 => 'Turion 64 Mobile', 135 => 'Dual-Core Opteron',
- 136 => 'Athlon 64 X2 DC', 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
- 139 => '3rd gen Opteron', 144 => 'PA-RISC', 145 => 'PA-RISC 8500',
- 146 => 'PA-RISC 8000', 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
- 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100', 160 => 'V30',
- 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200', 173 => 'Quad-Core Xeon 7300',
- 174 => 'Quad-Core Xeon 7400', 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
- 177 => 'M2', 180 => 'AS400', 182 => 'Athlon XP',
- 183 => 'Athlon MP', 184 => 'Duron', 185 => 'Pentium M',
- 186 => 'Celeron D', 187 => 'Pentium D', 188 => 'Pentium Extreme',
- 189 => 'Core Solo', 190 => 'Core2', 191 => 'Core2 Duo',
- 198 => 'Core i7', 199 => 'Dual-Core Celeron', 200 => 'IBM390',
- 201 => 'G4', 202 => 'G5', 203 => 'ESA/390 G6',
- 204 => 'z/Architectur', 210 => 'C7-M', 211 => 'C7-D',
- 212 => 'C7', 213 => 'Eden', 214 => 'Multi-Core Xeon',
- 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx', 218 => 'Dual-Core Xeon 5xxx',
- 219 => 'Quad-Core Xeon 5xxx', 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
- 223 => 'Multi-Core Xeon 7xxx', 250 => 'i860', 251 => 'i960',
+ 1 => 'Other', 2 => 'Unknown',
+ 3 => '8086', 4 => '80286',
+ 5 => '386', 6 => '486',
+ 7 => '8087', 8 => '80287',
+ 9 => '80387', 10 => '80487',
+ 11 => 'Pentium', 12 => 'Pentium Pro',
+ 13 => 'Pentium II', 14 => 'Pentium with MMX',
+ 15 => 'Celeron', 16 => 'Pentium II Xeon',
+ 17 => 'Pentium III', 18 => 'Pentium III Xeon',
+ 19 => 'Pentium III', 20 => 'Itanium',
+ 21 => 'Xeon', 22 => 'Pentium 4',
+ 23 => 'Xeon MP', 24 => 'Itanium 2',
+ 25 => 'K5', 26 => 'K6',
+ 27 => 'K6-2', 28 => 'K6-3',
+ 29 => 'Athlon', 30 => 'AMD2900',
+ 31 => 'K6-2+', 32 => 'Power PC',
+ 33 => 'Power PC 601', 34 => 'Power PC 603',
+ 35 => 'Power PC 603+', 36 => 'Power PC 604',
+ 37 => 'Power PC 620', 38 => 'Power PC x704',
+ 39 => 'Power PC 750', 40 => 'Core Duo',
+ 41 => 'Core Duo mobile', 42 => 'Core Solo mobile',
+ 43 => 'Intel Atom', 44 => undef,
+ 45 => undef, 46 => undef,
+ 47 => undef, 48 => 'Alpha',
+ 49 => 'Alpha 21064', 50 => 'Alpha 21066',
+ 51 => 'Alpha 21164', 52 => 'Alpha 21164PC',
+ 53 => 'Alpha 21164a', 54 => 'Alpha 21264',
+ 55 => 'Alpha 21364', 56 => 'Turion II Ultra Dual-Core Mobile M',
+ 57 => 'Turion II Dual-Core Mobile M', 58 => 'Athlon II Dual-Core Mobile M ',
+ 59 => 'Opteron 6100', 60 => undef,
+ 61 => undef, 62 => undef,
+ 63 => undef, 64 => 'MIPS',
+ 65 => 'MIPS R4000', 66 => 'MIPS R4200',
+ 67 => 'MIPS R4400', 68 => 'MIPS R4600',
+ 69 => 'MIPS R10000', 70 => undef,
+ 71 => undef, 72 => undef,
+ 73 => undef, 74 => undef,
+ 75 => undef, 76 => undef,
+ 77 => undef, 78 => undef,
+ 79 => undef, 80 => 'SPARC',
+ 81 => 'SuperSPARC', 82 => 'microSPARC II',
+ 83 => 'microSPARC IIep', 84 => 'UltraSPARC',
+ 85 => 'UltraSPARC II', 86 => 'UltraSPARC IIi',
+ 87 => 'UltraSPARC III', 88 => 'UltraSPARC IIIi',
+ 89 => undef, 90 => undef,
+ 91 => undef, 92 => undef,
+ 93 => undef, 94 => undef,
+ 95 => undef, 96 => '68040',
+ 97 => '68xxx', 98 => '68000',
+ 99 => '68010', 100 => '68020',
+ 101 => '68030', 102 => undef,
+ 103 => undef, 104 => undef,
+ 105 => undef, 106 => undef,
+ 107 => undef, 108 => undef,
+ 109 => undef, 110 => undef,
+ 111 => undef, 112 => 'Hobbit',
+ 113 => undef, 114 => undef,
+ 115 => undef, 116 => undef,
+ 117 => undef, 118 => undef,
+ 119 => undef, 120 => 'Crusoe TM5000',
+ 121 => 'Crusoe TM3000', 122 => 'Efficeon TM8000',
+ 123 => undef, 124 => undef,
+ 125 => undef, 126 => undef,
+ 127 => undef, 128 => 'Weitek',
+ 129 => undef, 130 => 'Celeron M',
+ 131 => 'Athlon 64', 132 => 'Opteron',
+ 133 => 'Sempron', 134 => 'Turion 64 Mobile',
+ 135 => 'Dual-Core Opteron', 136 => 'Athlon 64 X2 DC',
+ 137 => 'Turion 64 X2 M', 138 => 'Quad-Core Opteron',
+ 139 => '3rd gen Opteron', 140 => 'AMD Phenom FX Quad-Core',
+ 141 => 'AMD Phenom X4 Quad-Core', 142 => 'AMD Phenom X2 Dual-Core',
+ 143 => 'AMD Athlon X2 Dual-Core', 144 => 'PA-RISC',
+ 145 => 'PA-RISC 8500', 146 => 'PA-RISC 8000',
+ 147 => 'PA-RISC 7300LC', 148 => 'PA-RISC 7200',
+ 149 => 'PA-RISC 7100LC', 150 => 'PA-RISC 7100',
+ 151 => undef, 152 => undef,
+ 153 => undef, 154 => undef,
+ 155 => undef, 156 => undef,
+ 157 => undef, 158 => undef,
+ 159 => undef, 160 => 'V30',
+ 161 => 'Quad-Core Xeon 3200', 162 => 'Dual-Core Xeon 3000',
+ 163 => 'Quad-Core Xeon 5300', 164 => 'Dual-Core Xeon 5100',
+ 165 => 'Dual-Core Xeon 5000', 166 => 'Dual-Core Xeon LV',
+ 167 => 'Dual-Core Xeon ULV', 168 => 'Dual-Core Xeon 7100',
+ 169 => 'Quad-Core Xeon 5400', 170 => 'Quad-Core Xeon',
+ 171 => 'Dual-Core Xeon 5200', 172 => 'Dual-Core Xeon 7200',
+ 173 => 'Quad-Core Xeon 7300', 174 => 'Quad-Core Xeon 7400',
+ 175 => 'Multi-Core Xeon 7400', 176 => 'M1',
+ 177 => 'M2', 178 => undef,
+ 179 => 'Pentium 4 HT', 180 => 'AS400',
+ 181 => undef, 182 => 'Athlon XP',
+ 183 => 'Athlon MP', 184 => 'Duron',
+ 185 => 'Pentium M', 186 => 'Celeron D',
+ 187 => 'Pentium D', 188 => 'Pentium Extreme',
+ 189 => 'Core Solo', 190 => 'Core2',
+ 191 => 'Core2 Duo', 192 => 'Core2 Solo',
+ 193 => 'Core2 Extreme', 194 => 'Core2 Quad',
+ 195 => 'Core2 Extreme mobile', 196 => 'Core2 Duo mobile',
+ 197 => 'Core2 Solo mobile', 198 => 'Core i7',
+ 199 => 'Dual-Core Celeron', 200 => 'IBM390',
+ 201 => 'G4', 202 => 'G5',
+ 203 => 'ESA/390 G6', 204 => 'z/Architectur',
+ 205 => 'Core i5', 206 => undef,
+ 207 => undef, 208 => undef,
+ 209 => undef, 210 => 'C7-M',
+ 211 => 'C7-D', 212 => 'C7',
+ 213 => 'Eden', 214 => 'Multi-Core Xeon',
+ 215 => 'Dual-Core Xeon 3xxx', 216 => 'Quad-Core Xeon 3xxx',
+ 217 => undef, 218 => 'Dual-Core Xeon 5xxx',
+ 219 => 'Quad-Core Xeon 5xxx', 220 => undef,
+ 221 => 'Dual-Core Xeon 7xxx', 222 => 'Quad-Core Xeon 7xxx',
+ 223 => 'Multi-Core Xeon 7xxx', 224 => undef,
+ 225 => undef, 226 => undef,
+ 227 => undef, 228 => undef,
+ 229 => undef, 230 => 'Embedded AMD Opteron Quad-Core',
+ 231 => 'AMD Phenom Triple-Core', 232 => 'AMD Turion Ultra Dual-Core Mobile',
+ 233 => 'AMD Turion Dual-Core Mobile', 234 => 'AMD Athlon Dual-Core',
+ 235 => 'AMD Sempron SI', 236 => 'AMD Phenom II',
+ 237 => 'AMD Athlon II', 238 => 'Six-Core AMD Opteron',
+ 239 => 'AMD Sempron M', 240 => undef,
+ 241 => undef, 242 => undef,
+ 243 => undef, 244 => undef,
+ 245 => undef, 246 => undef,
+ 247 => undef, 248 => undef,
+ 249 => undef, 250 => 'i860',
+ 251 => 'i960',
);
CPU:
# Collect performance data
if (defined $opt{perfdata}) {
next AMP if $reading !~ m{\A \d+(\.\d+)? \z}xms; # discrete reading (not number)
- my $pname = lc $location;
- $pname =~ s{\s}{_}gxms;
- my $pkey = join q{_}, 'pwr_mon', $index, $pname;
- my $pval = join q{;}, "$reading$unit", $max_warn, $max_crit;
- $perfdata{$pkey} = $pval;
+ my $label = join q{_}, 'pwr_mon', $index, lc $location;
+ $label =~ s{\s}{_}gxms;
+ push @perfdata, {
+ label => $label,
+ mini => "p${index}" . lc $unit,
+ value => $reading,
+ warn => $max_warn,
+ crit => $max_crit,
+ };
}
}
my %used = ();
# find used indexes
- foreach (keys %perfdata) {
- if (m/\A pwr_mon_(\d+)/xms) {
+ foreach (@perfdata) {
+ if ($_->{label} =~ m/\A pwr_mon_(\d+)/xms) {
$used{$1} = 1;
}
}
$found = 0;
next AMP2;
}
- if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s ([AW]) \z/xms) {
+ if ($found and $line =~ m/\A ([^;]+?) ; (\d*\.\d+) \s [AW] \z/xms) {
my $aname = lc $1;
my $aval = $2;
- my $aunit = $3;
$aname =~ s{\s}{_}gxms;
# don't use an existing index
while (exists $used{$index}) { ++$index; }
- $perfdata{"pwr_mon_${index}_${aname}"} = "$aval$aunit;0;0";
+ push @perfdata, {
+ label => "pwr_mon_${index}_${aname}",
+ mini => "p${index}a",
+ value => $aval,
+ warn => 0,
+ crit => 0,
+ };
++$index;
}
}
# Fetch OMSA version via SNMP, put in sysinfo hash
#
sub get_snmp_about {
- my %omsa_oid
- = (
- '1.3.6.1.4.1.674.10892.1.100.10.0' => 'systemManagementSoftwareGlobalVersionName',
- );
- my $systemManagementSoftwareGroup = '1.3.6.1.4.1.674.10892.1.100';
- my $result = $snmp_session->get_table(-baseoid => $systemManagementSoftwareGroup);
+ # systemManagementSoftwareGlobalVersionName
+ my $oid = '1.3.6.1.4.1.674.10892.1.100.10.0';
+ my $result = $snmp_session->get_request(-varbindlist => [$oid]);
+
if (defined $result) {
- foreach my $oid (keys %{ $result }) {
- if (exists $omsa_oid{$oid} and $omsa_oid{$oid} eq 'systemManagementSoftwareGlobalVersionName') {
- $sysinfo{om} = ($result->{$oid});
- }
- }
+ $sysinfo{om} = exists $result->{$oid} && $result->{$oid} ne q{}
+ ? $result->{$oid} : 'unknown';
}
else {
- my $msg = sprintf 'SNMP ERROR getting OMSA info: %s',
- $snmp_session->error;
+ my $msg = sprintf 'SNMP ERROR: Getting OMSA version failed: %s', $snmp_session->error;
report('other', $msg, $E_UNKNOWN);
}
return;
}
}
+# Reset the WARN signal
+$SIG{__WARN__} = 'DEFAULT';
+
# Print any perl warnings that have occured
if (@perl_warnings) {
foreach (@perl_warnings) {
chop @$_;
print "${linebreak}INTERNAL ERROR: @$_";
- if (defined $opt{htmlinfo}) {
- # check_openmanage.html#internal-error-blah-blah
- print ' [<a href="http://bit.ly/aMDzE1">more info</a>]';
- }
}
$exit_code = $E_UNKNOWN;
}
-# Reset the WARN signal
-$SIG{__WARN__} = $original_sigwarn;
-
# Print performance data
-if (defined $opt{perfdata} && !$opt{debug} && %perfdata) {
+if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
my $lb = $opt{perfdata} eq 'multiline' ? "\n" : q{ }; # line break for perfdata
print q{|};
- sub perfdata {
- my %order
- = (
- fan => 0,
- pwr => 1,
- temp => 2,
- enclosure => 3,
- );
- return ($order{(split /_/, $a, 2)[0]} cmp $order{(split /_/, $b, 2)[0]}) || $a cmp $b;
+ # Sort routine for performance data
+ sub perfsort {
+ my %order = ( fan => 0, pwr => 1, tem => 2, enc => 3, );
+ return ($order{(substr $a->{label}, 0, 3)} cmp $order{(substr $b->{label}, 0, 3)}) ||
+ $a->{label} cmp $b->{label};
}
- print join $lb, map { "'$_'=$perfdata{$_}" } sort perfdata keys %perfdata;
+ # Print performance data sorted
+ my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
+ print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
}
# Print a linebreak at the end