]> git.uio.no Git - check_openmanage.git/blobdiff - check_openmanage
* version 3.5.8-beta2
[check_openmanage.git] / check_openmanage
index 88b06890f56a99ddd23f5029d3f4b250c516da26..1edeea754d75add5eb94ffb992934bb72d327e61 100755 (executable)
@@ -51,7 +51,7 @@ $SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
 
 # Version and similar info
 $NAME    = 'check_openmanage';
-$VERSION = '3.5.7-beta19';
+$VERSION = '3.5.8-beta2';
 $AUTHOR  = 'Trond H. Amundsen';
 $CONTACT = 't.h.amundsen@usit.uio.no';
 
@@ -2332,7 +2332,6 @@ sub check_enclosure_temp {
                             label => $label,
                             mini  => $mini,
                             value => $reading,
-                            unit  => '',
                             warn  => $max_warn,
                             crit  => $max_crit,
                            };
@@ -2666,12 +2665,10 @@ sub check_fans {
            my $pname = lc $location;
            $pname =~ s{\s}{_}gxms;
            $pname =~ s{proc_}{cpu#}xms;
-           my $pkey = join q{_}, 'fan', $index, $pname;
            push @perfdata, {
-                            label => $pkey,
+                            label => "fan_${index}_${pname}",
                             mini  => "f$index",
                             value => $reading,
-                            unit  => '',
                             warn  => $max_warn,
                             crit  => $max_crit,
                            };
@@ -2874,17 +2871,24 @@ sub check_temperatures {
        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'};
@@ -2903,7 +2907,7 @@ sub check_temperatures {
        $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);
@@ -2979,12 +2983,10 @@ sub check_temperatures {
                $pname =~ s{\s}{_}gxms;
                $pname =~ s{_temp\z}{}xms;
                $pname =~ s{proc_}{cpu#}xms;
-               my $pkey = join q{_}, 'temp', $index, $pname;
                push @perfdata, {
-                                label => $pkey,
+                                label => "temp_${index}_${pname}",
                                 mini  => "t$index",
                                 value => $reading,
-                                unit  => '',
                                 warn  => $max_warn,
                                 crit  => $max_crit,
                                };
@@ -3577,7 +3579,6 @@ sub check_pwrmonitoring {
                             label => $label,
                             mini  => "p${index}" . lc $unit,
                             value => $reading,
-                            unit  => '',
                             warn  => $max_warn,
                             crit  => $max_crit,
                            };
@@ -3621,7 +3622,6 @@ sub check_pwrmonitoring {
                                 label => "pwr_mon_${index}_${aname}",
                                 mini  => "p${index}a",
                                 value => $aval,
-                                unit  => '',
                                 warn  => 0,
                                 crit  => 0,
                                };
@@ -4022,22 +4022,16 @@ sub get_snmp_system_operatingsystem {
 # 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;
@@ -4489,7 +4483,7 @@ if (defined $opt{perfdata} && !$opt{debug} && @perfdata) {
 
     # Print performance data sorted
     my $type = $opt{perfdata} eq 'minimal' ? 'mini' : 'label';
-    print join $lb, map { "$_->{$type}=$_->{value}$_->{unit};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
+    print join $lb, map { "$_->{$type}=$_->{value};$_->{warn};$_->{crit}" } sort perfsort @perfdata;
 }
 
 # Print a linebreak at the end