|
|
@ -40,15 +40,14 @@ sub gluster($){ |
|
|
|
my $code = 256; |
|
|
|
my $code = 256; |
|
|
|
my @result = (); |
|
|
|
my @result = (); |
|
|
|
# Loop to run gluster cmd as it can fail if two run at the same time |
|
|
|
# Loop to run gluster cmd as it can fail if two run at the same time |
|
|
|
for (my $i = 0; ($code != 0 && $i < 10); $i++){ |
|
|
|
for (my $i = 0; ($code != 0 && $i < 3); $i++){ |
|
|
|
open (RES, "$cmd |") |
|
|
|
open (RES, "$cmd 2>/dev/null |") |
|
|
|
|| die "error: Could not execute $cmd"; |
|
|
|
|| die "error: Could not execute $cmd"; |
|
|
|
@result = <RES>; |
|
|
|
@result = <RES>; |
|
|
|
close RES; |
|
|
|
close RES; |
|
|
|
$code = $?; |
|
|
|
$code = $?; |
|
|
|
sleep(1) unless ($code == 0); |
|
|
|
sleep(1) unless ($code == 0); |
|
|
|
} |
|
|
|
} |
|
|
|
die "error: Could not execute $cmd" unless ($code == 0); |
|
|
|
|
|
|
|
return @result; |
|
|
|
return @result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -59,9 +58,12 @@ if (($what eq 'volume' && !$volume) || |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($what eq 'volume'){ |
|
|
|
if ($what eq 'volume'){ |
|
|
|
my @volinfo = gluster("$gluster vol status $volume"); |
|
|
|
|
|
|
|
my $bricksfound = 0; |
|
|
|
my $bricksfound = 0; |
|
|
|
my $status = 'OK'; |
|
|
|
my $status = 'OK'; |
|
|
|
|
|
|
|
my @volinfo = gluster("$gluster vol status $volume"); |
|
|
|
|
|
|
|
unless (scalar @volinfo){ |
|
|
|
|
|
|
|
die "Error occurred while trying to get volume status for $volume"; |
|
|
|
|
|
|
|
} |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
# Check that all bricks are online |
|
|
|
# Check that all bricks are online |
|
|
|
if ($line =~ m/^Brick\ ([\w\.]+:\/[\w\.\/]+)\s+\d+\s+([A-Z])/){ |
|
|
|
if ($line =~ m/^Brick\ ([\w\.]+:\/[\w\.\/]+)\s+\d+\s+([A-Z])/){ |
|
|
@ -78,13 +80,19 @@ if ($what eq 'volume'){ |
|
|
|
$status = "CRITICAL: bricks count mismatch (found $bricksfound while expecting $bricks)"; |
|
|
|
$status = "CRITICAL: bricks count mismatch (found $bricksfound while expecting $bricks)"; |
|
|
|
} |
|
|
|
} |
|
|
|
@volinfo = gluster("$gluster vol heal $volume info heal-failed"); |
|
|
|
@volinfo = gluster("$gluster vol heal $volume info heal-failed"); |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
# the heal-failed command isn't supported on all version of GlusterFS |
|
|
|
# Now, check we don't have any file which the Self-Heal daemon couldn't sync |
|
|
|
if (scalar @volinfo){ |
|
|
|
if ($line =~ m/^Number\ of\ entries:\s+(\d+)$/){ |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
$status = "CRITICAL: self-heal error ($1)" if ($1 gt 0); |
|
|
|
# Now, check we don't have any file which the Self-Heal daemon couldn't sync |
|
|
|
|
|
|
|
if ($line =~ m/^Number\ of\ entries:\s+(\d+)$/){ |
|
|
|
|
|
|
|
$status = "CRITICAL: self-heal error ($1)" if ($1 gt 0); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@volinfo = gluster("$gluster vol heal $volume info split-brain"); |
|
|
|
@volinfo = gluster("$gluster vol heal $volume info split-brain"); |
|
|
|
|
|
|
|
unless (scalar @volinfo){ |
|
|
|
|
|
|
|
die "Error occurred while trying to get split-brain info for $volume"; |
|
|
|
|
|
|
|
} |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
# Now, check we don't have any file in a split-brain situation |
|
|
|
# Now, check we don't have any file in a split-brain situation |
|
|
|
if ($line =~ m/^Number\ of\ entries:\s+(\d+)$/){ |
|
|
|
if ($line =~ m/^Number\ of\ entries:\s+(\d+)$/){ |
|
|
@ -92,6 +100,9 @@ if ($what eq 'volume'){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@volinfo = gluster("$gluster vol info $volume"); |
|
|
|
@volinfo = gluster("$gluster vol info $volume"); |
|
|
|
|
|
|
|
unless (scalar @volinfo){ |
|
|
|
|
|
|
|
die "Error occurred while trying to get volume info for $volume"; |
|
|
|
|
|
|
|
} |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
foreach my $line (@volinfo){ |
|
|
|
# Check the volume is started |
|
|
|
# Check the volume is started |
|
|
|
if ($line =~ m/^Status:\s+(\w+)$/){ |
|
|
|
if ($line =~ m/^Status:\s+(\w+)$/){ |
|
|
|