=================================================================== RCS file: /cvs/nagios/check_bioctl/check_bioctl,v retrieving revision 1.15 retrieving revision 1.18 diff -u -r1.15 -r1.18 --- nagios/check_bioctl/check_bioctl 2009/11/23 22:24:45 1.15 +++ nagios/check_bioctl/check_bioctl 2011/12/27 02:12:38 1.18 @@ -1,5 +1,5 @@ #!/usr/bin/perl -T -# $RedRiver: check_bioctl,v 1.14 2009/11/23 21:58:04 andrew Exp $ +# $RedRiver: check_bioctl,v 1.15 2009/11/23 22:24:45 andrew Exp $ ######################################################################## # check_bioctl *** A nagios check for OpenBSD bioctl # @@ -10,7 +10,7 @@ local %ENV = (); -my $NAGIOS_OUTPUT = 0; +my $NAGIOS_OUTPUT = 1; my $License = <<'EOL'; Copyright (c) 2009 Andrew Fresh @@ -81,7 +81,7 @@ } if ($opt_V) { - print_revision( $PROGNAME, '$Revision: 1.15 $ ' ); + print_revision( $PROGNAME, '$Revision: 1.18 $ ' ); exit $ERRORS{'OK'}; } @@ -154,38 +154,32 @@ my $controller; sub parse_bioctl_line { - my ($line) = @_; - chomp $line; + ($_) = @_; + chomp; - # Do these by columns cuZ that is the easiest for now - my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line ); + my @o = map { s/^\s+|\s+$//g; $_ } split; return if $o[0] eq 'Volume'; - foreach (@o) { - s/^\s+//xms; - s/\s+$//xms; - } + $vid ||= ''; - my ( $c, $id, $status, $size, $dev, $details, $name ) = @o; - my $index = $id; - if ($c) { - $vid = $id; - $controller = $c; + my $index = "$vid.$o[0]"; + if ( $o[0] !~ /^\d+$/ ) { + $controller = shift @o; + $vid = $o[0]; + $index = $vid; } - else { - $index = "$vid.$id"; - } return $index, { - controller => $controller, - id => $id, - status => $status, - size => $size, - device => $dev, - details => $details, - name => $name, - volume_id => $vid, + controller => $controller, + volume_id => $vid, + id => shift @o, + status => shift @o, + size => shift @o, + device => shift @o, + name => shift @o, + description => join ' ', + @o, }; } } @@ -223,7 +217,7 @@ EOL - print_revision( $PROGNAME, '$Revision: 1.15 $' ); + print_revision( $PROGNAME, '$Revision: 1.18 $' ); print $License;