version 1.15, 2009/11/23 22:24:45 |
version 1.18, 2011/12/27 02:12:38 |
|
|
#!/usr/bin/perl -T |
#!/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 |
# check_bioctl *** A nagios check for OpenBSD bioctl |
# |
# |
|
|
|
|
local %ENV = (); |
local %ENV = (); |
|
|
my $NAGIOS_OUTPUT = 0; |
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> |
|
|
my $controller; |
my $controller; |
|
|
sub parse_bioctl_line { |
sub parse_bioctl_line { |
my ($line) = @_; |
($_) = @_; |
chomp $line; |
chomp; |
|
|
# Do these by columns cuZ that is the easiest for now |
my @o = map { s/^\s+|\s+$//g; $_ } split; |
my @o = unpack( "A6 A1 A11 A15 A7 A9 A*", $line ); |
|
return if $o[0] eq 'Volume'; |
return if $o[0] eq 'Volume'; |
|
|
foreach (@o) { |
$vid ||= ''; |
s/^\s+//xms; |
|
s/\s+$//xms; |
|
} |
|
|
|
my ( $c, $id, $status, $size, $dev, $details, $name ) = @o; |
my $index = "$vid.$o[0]"; |
my $index = $id; |
if ( $o[0] !~ /^\d+$/ ) { |
if ($c) { |
$controller = shift @o; |
$vid = $id; |
$vid = $o[0]; |
$controller = $c; |
$index = $vid; |
} |
} |
else { |
|
$index = "$vid.$id"; |
|
} |
|
|
|
return $index, |
return $index, |
{ |
{ |
controller => $controller, |
controller => $controller, |
id => $id, |
volume_id => $vid, |
status => $status, |
id => shift @o, |
size => $size, |
status => shift @o, |
device => $dev, |
size => shift @o, |
details => $details, |
device => shift @o, |
name => $name, |
name => shift @o, |
volume_id => $vid, |
description => join ' ', |
|
@o, |
}; |
}; |
} |
} |
} |
} |