18 |
} |
} |
19 |
|
|
20 |
sub smart { |
sub smart { |
21 |
open(my $fh, '-|', "smartctl -l selective $drive"); |
my $cmd = "smartctl -l selective $drive"; |
22 |
|
warn "$cmd\n"; |
23 |
|
open(my $fh, '-|', $cmd); |
24 |
while(<$fh>) { |
while(<$fh>) { |
25 |
chomp; |
chomp; |
26 |
print "# $_\n"; |
print "# $_\n"; |
33 |
smart_test $sector; |
smart_test $sector; |
34 |
return 1; |
return 1; |
35 |
} elsif ( m/Self_test_in_progress/ ) { |
} elsif ( m/Self_test_in_progress/ ) { |
36 |
|
$test_started = 1; |
37 |
return 1; |
return 1; |
38 |
} elsif ( m/Not_testing/ ) { |
} elsif ( m/Not_testing/ ) { |
39 |
return 1 if $test_started; |
return 1 if $test_started; |
44 |
} |
} |
45 |
|
|
46 |
while ( smart ) { |
while ( smart ) { |
47 |
warn "# sleep $delay s\n"; |
warn "sleep $delay s", ( $test_started ? " smart test running..." : "idle" ), "\n"; |
48 |
sleep $delay; |
sleep $delay; |
49 |
} |
} |