=================================================================== RCS file: /cvs/nagios/check_bioctl/check_bioctl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- nagios/check_bioctl/check_bioctl 2009/11/23 21:52:53 1.12 +++ nagios/check_bioctl/check_bioctl 2009/11/23 21:57:31 1.13 @@ -1,5 +1,5 @@ #!/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 # @@ -82,7 +82,7 @@ } if ($opt_V) { - print_revision( $PROGNAME, '$Revision: 1.12 $ ' ); + print_revision( $PROGNAME, '$Revision: 1.13 $ ' ); exit $ERRORS{'OK'}; } @@ -126,9 +126,9 @@ foreach my $d ( @{$devices} ) { open my $bioctl, q{-|}, $BIOCTL, $d or die "Couldn't open bioctl: $!\n"; - while ( my $line = <$bioctl> ) { + LINE: while ( my $line = <$bioctl> ) { my ( $i, $item ) = parse_bioctl_line($line); - next unless defined $i; + next LINE if !defined $i; $volumes{$d}{$i} = $item; } ## no critic 'die' @@ -152,41 +152,43 @@ { my $vid; -sub parse_bioctl_line { - my ($line) = @_; - chomp $line; - # Do these by columns cuZ that is the easiest for now - my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line ); - return if $o[0] eq 'Volume'; + sub parse_bioctl_line { + my ($line) = @_; + chomp $line; - foreach (@o) { - s/^\s+//xms; - s/\s+$//xms; - } + # Do these by columns cuZ that is the easiest for now + my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line ); + return if $o[0] eq 'Volume'; - my ( $controller, $id, $status, $size, $dev, $details, $name ) = @o; - my $index = $id; - if ($controller) { - $vid = $id; - } - else { - $index = "$vid.$id"; - } + foreach (@o) { + s/^\s+//xms; + s/\s+$//xms; + } - my %item = ( - type => 'volume', - controller => $controller, - id => $id, - status => $status, - size => $size, - device => $dev, - details => $details, - name => $name, - volume_id => $vid, - ); + my ( $controller, $id, $status, $size, $dev, $details, $name ) = @o; + my $index = $id; + if ($controller) { + $vid = $id; + } + else { + $index = "$vid.$id"; + } - 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; + } } } @@ -235,7 +237,7 @@ EOL - print_revision( $PROGNAME, '$Revision: 1.12 $' ); + print_revision( $PROGNAME, '$Revision: 1.13 $' ); print $License;