[BACK]Return to check_hw_sensors CVS log [TXT][DIR] Up to [local] / nagios / check_hw_sensors

Diff for /nagios/check_hw_sensors/check_hw_sensors between version 1.4 and 1.9

version 1.4, 2006/05/02 16:54:42 version 1.9, 2006/05/03 03:26:47
Line 1 
Line 1 
 #!/usr/bin/perl  #!/usr/bin/perl
 # $RedRiver: check_hw_sensors,v 1.3 2006/05/02 01:39:23 andrew Exp $  # $RedRiver: check_hw_sensors,v 1.8 2006/05/02 21:23:29 andrew Exp $
 ########################################################################  ########################################################################
 # check_hw_sensors *** A nagios check for OpenBSD hw.sensors  # check_hw_sensors *** A nagios check for OpenBSD hw.sensors
 #  #
Line 148 
Line 148 
 #print Dumper \%states;  #print Dumper \%states;
   
 $state = 'OK';  $state = 'OK';
 if (NAGIOS_OUTPUT) {  my $have_results = 0;
         print '<ul>';  foreach my $error (sort { $ERRORS{$a} <=> $ERRORS{$b} } keys %ERRORS) {
           if (exists $states{$error}) {
                   $have_results++;
                   $state = $error;
           }
 }  }
 foreach my $error (sort { $ERRORS{$b} <=> $ERRORS{$a} } keys %ERRORS) {  foreach my $error (sort { $ERRORS{$b} <=> $ERRORS{$a} } keys %ERRORS) {
         if (exists $states{$error}) {          if (exists $states{$error}) {
                 if (NAGIOS_OUTPUT) {                  if (NAGIOS_OUTPUT) {
                         print "<li>$error (" . scalar(@{ $states{ $error } }) . "):<ul>";                          print "$error (" . scalar(@{ $states{ $error } }) . ")";
                         foreach (@{ $states{ $error } }) {                          unless ($error eq 'OK') {
                                 print "<li>$_</li>";                                  print '<br>';
                                   print map { " - $_<br>" } @{ $states{ $error } };
                         }                          }
                         print "</ul></li>"  
                 } else {                  } else {
                         print "$error (" . scalar(@{ $states{ $error } }) . "):\n";                          print "$error (" . scalar(@{ $states{ $error } }) . "):\n";
                         foreach (@{ $states{ $error } }) {                          foreach (@{ $states{ $error } }) {
Line 167 
Line 171 
                 }                  }
         }          }
 }  }
 if (NAGIOS_OUTPUT) {  if ($have_results == 0) {
         print '</ul>' . "\n";          print "No results found\n";
 }  }
 foreach my $error (sort { $ERRORS{$a} <=> $ERRORS{$b} } keys %ERRORS) {  
         if (exists $states{$error}) {  
                 $state = $error;  
         }  
 }  
 exit $ERRORS{$state};  exit $ERRORS{$state};
   
   
Line 294 
Line 293 
                                         $result = $errors{$code}                                          $result = $errors{$code}
                                                 if ($c <= $data);                                                  if ($c <= $data);
                                 }                                  }
                         } elsif (defined $check->{$code}) {                          } elsif (@{ $check->{$code} }) {
                                 my $matched = 0;                                  my $matched = 0;
                                 foreach my $c (@{ $check->{$code} }) {                                  foreach my $c (@{ $check->{$code} }) {
                                         $c =~ s/[^\d\.]//g;                                          $c =~ s/[^\d\.]//g;
                                         unless (length $c) {                                          unless (length $c) {
                                                 warn "INVALID CHECK (" . $check->{$code} .                                                  warn "INVALID CHECK (" . $c .
                                                       ") for '$sensor->{'id'}:$code'";                                                        ") for '$sensor->{'id'}:$code'";
                                                 next;                                                  next;
                                         }                                          }
Line 362 
Line 361 
                                         $result = $errors{$code}                                          $result = $errors{$code}
                                                 if ($c <= $data);                                                  if ($c <= $data);
                                 }                                  }
                         } elsif (defined $check->{$code}) {                          } elsif (@{ $check->{$code} }) {
   
                                 my $matched = 0;                                  my $matched = 0;
                                 foreach my $c (@{ $check->{$code} }) {                                  foreach my $c (@{ $check->{$code} }) {
Line 377 
Line 376 
   
                                         $c =~ s/[^\d\.]//g;                                          $c =~ s/[^\d\.]//g;
                                         unless (length $c) {                                          unless (length $c) {
                                                 warn "INVALID CHECK (" . $check->{$code} .                                                  warn "INVALID CHECK (" . $c .
                                                          ") for '$sensor->{'id'}':$code";                                                           ") for '$sensor->{'id'}':$code";
                                                 next;                                                  next;
                                         }                                          }
Line 394 
Line 393 
                         $sensor->{'type'} eq 'drive' ||                          $sensor->{'type'} eq 'drive' ||
                         $sensor->{'type'} eq 'indicator'                          $sensor->{'type'} eq 'indicator'
                 ) {                  ) {
                         if (defined $check->{$code}) {                          if (@{ $check->{$code} }) {
                                 my $matched = 0;                                  my $matched = 0;
                                 foreach (@{ $check->{$code} }) {                                  foreach (@{ $check->{$code} }) {
                                         if ($_ eq $sensor->{'data'}) {                                          if ($_ eq $sensor->{'data'}) {

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.9

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>