]> git.uio.no Git - check_openmanage.git/blobdiff - check_openmanage
3.7.2
[check_openmanage.git] / check_openmanage
index 2e626dc7a325db36044b853a57b8cc75361908df..5a1e30971fb4f5d07f3eb885d503d6029b42a8c6 100755 (executable)
@@ -51,7 +51,7 @@ $SIG{__WARN__} = sub { push @perl_warnings, [@_]; };
 
 # Version and similar info
 $NAME    = 'check_openmanage';
-$VERSION = '3.7.1-beta1';
+$VERSION = '3.7.2';
 $AUTHOR  = 'Trond H. Amundsen';
 $CONTACT = 't.h.amundsen@usit.uio.no';
 
@@ -167,6 +167,7 @@ END_LICENSE
         'privkey'           => undef,    # SMNP v3
         'privprotocol'      => undef,    # SMNP v3
          'use_get_table'     => 0,        # hack for SNMPv3 on Windows with net-snmp
+        'hide_servicetag'   => 0,        # hidden servicetag
        );
 
 # Get options
@@ -210,6 +211,7 @@ GetOptions('b|blacklist=s'      => \@{ $opt{blacklist} },
           'privkey=s'          => \$opt{privkey},
           'privprotocol=s'     => \$opt{privprotocol},
            'use-get_table'      => \$opt{use_get_table},
+          'hide-servicetag'    => \$opt{hide_servicetag},
          ) or do { print $USAGE; exit $E_UNKNOWN };
 
 # If user requested help
@@ -488,6 +490,7 @@ sub parse_configfile {
          'state'           => 'output_servicestate',
          'shortstate'      => 'output_servicestate_abbr',
          'show_blacklist'  => 'output_blacklist',
+          'hide_servicetag' => 'output_hide_servicetag',
          'htmlinfo'        => 'output_html',
          'okinfo'          => 'output_ok_verbosity',
          'protocol'        => 'snmp_version',
@@ -776,6 +779,7 @@ sub parse_configfile {
        configfile_set_boolean($sect, 'ipv6');
        configfile_set_boolean($sect, 'tcp');
        configfile_set_boolean($sect, 'legacy_perfdata');
+       configfile_set_boolean($sect, 'hide_servicetag');
        configfile_set_snmp_version($sect);
        configfile_set_snmp_community($sect);
        configfile_set_snmp_port($sect);
@@ -1969,6 +1973,13 @@ sub check_physical_disks {
                report('storage', $msg, $E_WARNING, $nexus);
            }
        }
+       # Special case: Foreign disk
+       elsif ($status eq 'Non-Critical' and $state eq 'Foreign'
+             and blacklisted('pdisk_foreign', $nexus)) {
+           my $msg = sprintf '%s [%s %s, %s] on ctrl %d is %s',
+             $name, $vendor, $product, $capacity, $ctrl, $state;
+           report('storage', $msg, $E_OK, $nexus);
+       }
        # Default
        elsif ($status ne 'Ok') {
            my $msg =  sprintf '%s [%s %s, %s] on ctrl %d needs attention: %s',
@@ -2229,7 +2240,7 @@ sub check_cache_battery {
            $state  = get_hashval($out->{batteryState}, \%bat_state) || 'Unknown state';
            $learn  = get_hashval($out->{batteryLearnState}, \%bat_learn_state) || 'Unknown learn state';
            $pred   = get_hashval($out->{batteryPredictedCapacity}, \%bat_pred_cap) || 'Unknown predicted capacity status';
-           $ctrl   = get_hashval($out->{batteryConnectionControllerNumber}, \%snmp_controller) || 9999;
+           $ctrl   = $snmp_controller{$out->{batteryConnectionControllerNumber}};
            $nexus  = convert_nexus(($out->{batteryNexusID} || 9999));
            $id     = $nexus;
            $id     =~ s{\A \d+:(\d+) \z}{$1}xms;
@@ -4207,6 +4218,12 @@ sub check_pwrmonitoring {
                $max_warn /= 10;
                $unit      = 'A';
            }
+           if ($unit eq 'mA' and $type ne 'amperageProbeTypeIsDiscrete') {
+               $reading  /= 1000;
+               $max_crit /= 1000;
+               $max_warn /= 1000;
+               $unit      = 'A';
+           }
        }
        else {
            $index    = get_nonempty_string('Index', $out, 9999);
@@ -4668,7 +4685,7 @@ sub get_omreport_chassis_info {
                $sysinfo{model}  = $val;
            }
            if ($key eq 'Chassis Service Tag' or $key eq 'Service Tag') {
-               $sysinfo{serial} = $val;
+               $sysinfo{serial} = $opt{hide_servicetag} ? 'XXXXXXX' : $val;
            }
            if ($key eq 'System Revision') {
                $sysinfo{rev} = q{ } . $val;
@@ -4758,7 +4775,7 @@ sub get_snmp_chassis_info {
                $sysinfo{model} =~ s{\s+\z}{}xms; # remove trailing whitespace
            }
            elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisServiceTagName') {
-               $sysinfo{serial} = $result->{$oid};
+               $sysinfo{serial} = $opt{hide_servicetag} ? 'XXXXXXX' : $result->{$oid};
            }
            elsif (exists $chassis_oid{$oid} and $chassis_oid{$oid} eq 'chassisSystemRevisionName') {
                $sysinfo{rev} = q{ } . $result->{$oid};
@@ -5126,7 +5143,7 @@ else {
 
        # Prefix with service tag if specified with option '-i|--info'
        if ($opt{info}) {
-           if (defined $opt{htmlinfo}) {
+           if (defined $opt{htmlinfo} and !$opt{hide_servicetag}) {
                $msg = '[<a target="_blank" href="' . warranty_url($sysinfo{serial})
                  . "\">$sysinfo{serial}</a>] " . $msg;
            }
@@ -5194,11 +5211,16 @@ if ($exit_code == $E_OK && defined $opt{only} && $opt{only} !~ m{\A critical|war
     }
 }
 elsif ($exit_code == $E_OK && !$opt{debug}) {
-    if (defined $opt{htmlinfo}) {
+    if (defined $opt{htmlinfo} and !$opt{hide_servicetag}) {
        printf q{OK - System: '<a target="_blank" href="%s">%s%s</a>', SN: '<a target="_blank" href="%s">%s</a>'},
          documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
            warranty_url($sysinfo{serial}), $sysinfo{serial};
     }
+    if (defined $opt{htmlinfo} and $opt{hide_servicetag}) {
+       printf q{OK - System: '<a target="_blank" href="%s">%s%s</a>', SN: '%s'},
+         documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
+           $sysinfo{serial};
+    }
     else {
        printf q{OK - System: '%s%s', SN: '%s'},
          $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};
@@ -5280,11 +5302,16 @@ elsif ($exit_code == $E_OK && !$opt{debug}) {
 else {
     if ($opt{extinfo}) {
        print $linebreak;
-       if (defined $opt{htmlinfo}) {
+       if (defined $opt{htmlinfo} && !$opt{hide_servicetag}) {
            printf '------ SYSTEM: <a target="_blank" href="%s">%s%s</a>, SN: <a target="_blank" href="%s">%s</a>',
              documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
                warranty_url($sysinfo{serial}), $sysinfo{serial};
        }
+       elsif (defined $opt{htmlinfo} && $opt{hide_servicetag}) {
+           printf '------ SYSTEM: <a target="_blank" href="%s">%s%s</a>, SN: %s',
+             documentation_url($sysinfo{model}), $sysinfo{model}, $sysinfo{rev},
+               $sysinfo{serial};
+       }
        else {
            printf '------ SYSTEM: %s%s, SN: %s',
              $sysinfo{model}, $sysinfo{rev}, $sysinfo{serial};