[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.12 and 1.13

version 1.12, 2009/11/23 21:52:53 version 1.13, 2009/11/23 21:57:31
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: check_bioctl,v 1.11 2009/11/23 21:45:58 andrew Exp $  # $RedRiver: check_bioctl,v 1.12 2009/11/23 21:52:53 andrew Exp $
 ########################################################################  ########################################################################
 # check_bioctl *** A nagios check for OpenBSD bioctl  # check_bioctl *** A nagios check for OpenBSD bioctl
 #  #
Line 126 
Line 126 
     foreach my $d ( @{$devices} ) {      foreach my $d ( @{$devices} ) {
         open my $bioctl, q{-|}, $BIOCTL, $d          open my $bioctl, q{-|}, $BIOCTL, $d
             or die "Couldn't open bioctl: $!\n";              or die "Couldn't open bioctl: $!\n";
         while ( my $line = <$bioctl> ) {      LINE: while ( my $line = <$bioctl> ) {
             my ( $i, $item ) = parse_bioctl_line($line);              my ( $i, $item ) = parse_bioctl_line($line);
             next unless defined $i;              next LINE if !defined $i;
             $volumes{$d}{$i} = $item;              $volumes{$d}{$i} = $item;
         }          }
         ## no critic 'die'          ## no critic 'die'
Line 152 
Line 152 
   
 {  {
     my $vid;      my $vid;
 sub parse_bioctl_line {  
     my ($line) = @_;  
     chomp $line;  
   
     # Do these by columns cuZ that is the easiest for now      sub parse_bioctl_line {
     my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line );          my ($line) = @_;
     return if $o[0] eq 'Volume';          chomp $line;
   
     foreach (@o) {          # Do these by columns cuZ that is the easiest for now
         s/^\s+//xms;          my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line );
         s/\s+$//xms;          return if $o[0] eq 'Volume';
     }  
   
     my ( $controller, $id, $status, $size, $dev, $details, $name ) = @o;          foreach (@o) {
     my $index = $id;              s/^\s+//xms;
     if ($controller) {              s/\s+$//xms;
         $vid = $id;          }
     }  
     else {  
         $index = "$vid.$id";  
     }  
   
     my %item = (          my ( $controller, $id, $status, $size, $dev, $details, $name ) = @o;
         type       => 'volume',          my $index = $id;
         controller => $controller,          if ($controller) {
         id         => $id,              $vid = $id;
         status     => $status,          }
         size       => $size,          else {
         device     => $dev,              $index = "$vid.$id";
         details    => $details,          }
         name       => $name,  
         volume_id  => $vid,  
     );  
   
     return $index, \%item;          my %item = (
               type       => 'volume',
               controller => $controller,
               id         => $id,
               status     => $status,
               size       => $size,
               device     => $dev,
               details    => $details,
               name       => $name,
               volume_id  => $vid,
           );
   
           return $index, \%item;
       }
 }  }
 }  }
   

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

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