Skip to content
Snippets Groups Projects
Commit 53312893 authored by Sergey Joseph Ivanov's avatar Sergey Joseph Ivanov
Browse files

check for state, status, and action

parent 4f3a0b53
No related branches found
No related tags found
No related merge requests found
......@@ -86,12 +86,51 @@ sub handler {
my $oldhowlong = ( ( -r $statusfile ) ? `cat $statusfile` : 0 );
chomp $oldhowlong;
$oldhowlong = 0 unless $oldhowlong =~ /^[\d]+$/;
my ($when,$days,$h,$m,$s,$howlong,$togo,$repaired,$errors,$canceled)
=(0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0);
my ($when,$days,$h,$m,$s,$howlong,$togo,$repaired,$errors,$canceled,$State,$Status,$Action)
=(0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0, '', '', '');
my $STATUSCMD = "/usr/sbin/zpool status $zpool";
open (my $status, "-|", $STATUSCMD)or die "can't run $STATUSCMD: $!";
while (<$status>) {
if (/^\s*scan:\s+scrub\s+canceled\s+on\s+(.+)$/){
LINE: while (<$status>) {
=pod
state: ONLINE
=cut
if(/^\s*state:\s(\S*)\s*$/) {
$State = $1
}
=pod
status: One or more devices are faulted in response to persistent errors.
Sufficient replicas exist for the pool to continue functioning in a
degraded state.
action: Replace the faulted device, or use 'zpool clear' to mark the device
repaired.
- or -
status: One or more devices has experienced an unrecoverable error. An
attempt was made to correct the error. Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
using 'zpool clear' or replace the device with 'zpool replace'.
=cut
elsif (/^\s*status:\s+(.+)$/){
$Status = $1;
while(<$status>) {
redo LINE if (/^\s*[a-z]*:/);
chomp;
$_ =~ s/\s+/ /g;
$Status .= $_;
}
}
elsif (/^\s*action:\s+(.+)$/){
$Action = $1;
while(<$status>) {
redo LINE if (/^\s*[a-z]*:/);
chomp;
$_ =~ s/\s+/ /g;
$Action .= $_;
}
}
=pod
scan: scrub cancelled on Thu Mar 7 01:46:05 2019
=cut
elsif (/^\s*scan:\s+scrub\s+canceled\s+on\s+(.+)$/){
$when = $1;
$when = `$DATE '+%s'` - `$DATE '+%s' -d "$when"`;
$when = int(($when+30)/60);
......@@ -178,12 +217,15 @@ sub handler {
$howlong = $when + $togo
}
return {
"when" => [$when, "i"],
"howlong" => [$howlong, "i"],
"togo" => [$togo, "i"],
"repaired" => [$repaired, "i"],
"when" => [$when, "i"],
"howlong" => [$howlong, "i"],
"togo" => [$togo, "i"],
"repaired" => [$repaired,"i"],
"errors" => [$errors, "i"],
"canceled" => [$canceled, "i"],
"canceled" => [$canceled,"i"],
"state" => [$State, "s"],
"status" => [$Status, "s"],
"action" => [$Action, "s"],
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment