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

Diff for /nagios/check_bioctl/check_bioctl between version 1.11 and 1.12

version 1.11, 2009/11/23 21:45:58 version 1.12, 2009/11/23 21:52:53
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: check_bioctl,v 1.10 2009/11/12 18:54:38 andrew Exp $  # $RedRiver: check_bioctl,v 1.11 2009/11/23 21:45:58 andrew Exp $
 ########################################################################  ########################################################################
 # check_bioctl *** A nagios check for OpenBSD bioctl  # check_bioctl *** A nagios check for OpenBSD bioctl
 #  #
Line 8 
Line 8 
 use strict;  use strict;
 use warnings;  use warnings;
   
 use 5.010;  
   
 local %ENV = ();  local %ENV = ();
   
 my $NAGIOS_OUTPUT => 1;  my $NAGIOS_OUTPUT = 1;
   
 my $License = <<'EOL';  my $License = <<'EOL';
 Copyright (c) 2009 Andrew Fresh <andrew@afresh1.com>  Copyright (c) 2009 Andrew Fresh <andrew@afresh1.com>
Line 44 
Line 42 
 use utils qw($TIMEOUT %ERRORS &support);  use utils qw($TIMEOUT %ERRORS &support);
   
 $SIG{'ALRM'} = sub {  $SIG{'ALRM'} = sub {
     say "ERROR: $PROGNAME timeout";      print "ERROR: $PROGNAME timeout\n";
     exit $ERRORS{'UNKNOWN'};      exit $ERRORS{'UNKNOWN'};
 };  };
 alarm($TIMEOUT);  alarm($TIMEOUT);
Line 130 
Line 128 
             or die "Couldn't open bioctl: $!\n";              or die "Couldn't open bioctl: $!\n";
         while ( my $line = <$bioctl> ) {          while ( my $line = <$bioctl> ) {
             my ( $i, $item ) = parse_bioctl_line($line);              my ( $i, $item ) = parse_bioctl_line($line);
               next unless defined $i;
             $volumes{$d}{$i} = $item;              $volumes{$d}{$i} = $item;
         }          }
         ## no critic 'die'          ## no critic 'die'
Line 143 
Line 142 
         foreach my $i ( keys %{ $volumes{$d} } ) {          foreach my $i ( keys %{ $volumes{$d} } ) {
             my $item = $volumes{$d}{$i};              my $item = $volumes{$d}{$i};
             if ( $item->{device} =~ /^\d+:\d+/xms ) {              if ( $item->{device} =~ /^\d+:\d+/xms ) {
                 $item->{'volume'} = $volumes{$d}{ $i->{volume_id} };                  $item->{'volume'} = $volumes{$d}{ $item->{volume_id} };
             }              }
         }          }
     }      }
Line 151 
Line 150 
     return %volumes;      return %volumes;
 }  }
   
   {
       my $vid;
 sub parse_bioctl_line {  sub parse_bioctl_line {
     my ($line) = @_;      my ($line) = @_;
     state $vid;  
     chomp $line;      chomp $line;
   
     # Do these by columns cuZ that is the easiest for now      # Do these by columns cuZ that is the easiest for now
     my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line );      my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line );
     next if $o[0] eq 'Volume';      return if $o[0] eq 'Volume';
   
     foreach (@o) {      foreach (@o) {
         s/^\s+//xms;          s/^\s+//xms;
Line 188 
Line 188 
   
     return $index, \%item;      return $index, \%item;
 }  }
   }
   
 sub check_status {  sub check_status {
     my ($volumes) = @_;      my ($volumes) = @_;
Line 245 
Line 246 
     my ( $prog, $rev ) = @_;      my ( $prog, $rev ) = @_;
     $rev =~ s/^\D+([\d\.]+)\D+$/v$1/xms;      $rev =~ s/^\D+([\d\.]+)\D+$/v$1/xms;
   
     say "$prog $rev";      print "$prog $rev\n";
   
     return 1;      return 1;
 }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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