[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.17 and 1.18

version 1.17, 2006/10/26 00:30:23 version 1.18, 2006/12/02 02:15:17
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: check_hw_sensors,v 1.16 2006/10/25 18:36:46 andrew Exp $  # $RedRiver: check_hw_sensors,v 1.17 2006/10/25 23:30:23 andrew Exp $
 ########################################################################  ########################################################################
 # check_hw_sensors *** A nagios check for OpenBSD hw.sensors  # check_hw_sensors *** A nagios check for OpenBSD hw.sensors
 #  #
Line 52 
Line 52 
         "warning|w=s"     => \$warning,          "warning|w=s"     => \$warning,
         "critical|c=s"    => \$critical,          "critical|c=s"    => \$critical,
 );  );
   
 # set the default this way so it only happens if someone typed -f or --filename  # set the default this way so it only happens if someone typed -f or --filename
 $filename = $DEFAULT_CONFIG if (defined $filename && $filename eq '');  $filename = $DEFAULT_CONFIG if (defined $filename && $filename eq '');
   
   # Stuff is output in this file by print_sensor()
   # http://www.openbsd.org/cgi-bin/cvsweb/src/sbin/sysctl/sysctl.c
   my @Type_Map = (
           {
                   type  => 'temp',
                   regex => qr/\sdegC$/,
           },
           {
                   type  => 'fanrpm',
                   regex => qr/\sRPM$/,
           },
           {
                   type  => 'volts_dc',
                   regex => qr/\sV\sDC$/,
           },
           {
                   type  => 'amps',
                   regex => qr/\sA$/,
           },
           {
                   type  => 'watthour',
                   regex => qr/\sWh$/,
           },
           {
                   type  => 'amphour',
                   regex => qr/\sAh$/,
           },
           {
                   type  => 'indicator',
                   regex => qr/^(On|Off)$/,
           },
           {
                   type  => 'integer',
                   regex => qr/\sraw$/,
           },
           {
                   type  => 'lux',
                   regex => qr/\slx$/,
           },
           {
                   type  => 'drive',
                   regex => qr/^drive\s/,
           },
           {
                   type  => 'timedelta',
                   regex => qr/\ssecs$/,
           },
   );
   
 if ($status == 0) {  if ($status == 0) {
         print_help() ;          print_help() ;
         exit $ERRORS{'OK'};          exit $ERRORS{'OK'};
Line 100 
Line 149 
         my ($id, $output) = split /=/;          my ($id, $output) = split /=/;
         my @o = split /,\s*/, $output;          my @o = split /,\s*/, $output;
   
         my $source = $o[0];          my ($type, $source, $descr, $data, $status);
         my $descr  = $o[1];  
         my $status = $o[2] if @o == 5;  
         my $type   = $o[-2];  
         my $data   = $o[-1];  
   
           $source = $o[0];
           $descr  = $o[1];
           $type   = $o[-2] if @o >= 4;
           $data   = $o[-1];
   
           $status = $o[2] if ($type && @o == 5) || @o == 4;
   
           unless ($type) {
                   foreach my $t (@Type_Map) {
                           if ($data =~ /$t->{'regex'}/) {
                                   $type = $t->{'type'};
                                   last;
                           }
                   }
           }
   
           $type ||= 'unknown';
   
         $SENSORS{$id} = {          $SENSORS{$id} = {
                 id          => $id,                  id          => $id,
                 output      => $output,                  output      => $output,
Line 318 
Line 381 
                 } elsif ($sensor->{'type'} eq 'temp') {                  } elsif ($sensor->{'type'} eq 'temp') {
                         my ($degC, $degF) = split /\//, $sensor->{'data'};                          my ($degC, $degF) = split /\//, $sensor->{'data'};
                         $degC =~ s/[^\d\.]//g;                          $degC =~ s/[^\d\.]//g;
                           $degF ||= $degC * 9 / 5 + 32;
                         $degF =~ s/[^\d\.]//g;                          $degF =~ s/[^\d\.]//g;
                         if (                          if (
                                 defined $check->{$code . ".low"} ||                                  defined $check->{$code . ".low"} ||
Line 397 
Line 461 
                         $sensor->{'type'} eq 'drive' ||                          $sensor->{'type'} eq 'drive' ||
                         $sensor->{'type'} eq 'indicator'                          $sensor->{'type'} eq 'indicator'
                 ) {                  ) {
                           $sensor->{'type'} =~ s/^drive\s+//;
                         if (@{ $check->{$code} }) {                          if (@{ $check->{$code} }) {
                                 my $matched = 0;                                  my $matched = 0;
                                 foreach (@{ $check->{$code} }) {                                  foreach (@{ $check->{$code} }) {

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

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