better output while relocating sectors
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 25 Jan 2012 17:05:33 +0000 (17:05 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 25 Jan 2012 17:05:33 +0000 (17:05 +0000)
git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@288 191e9f34-6774-4a6d-acfc-7664dacd4a2a

recepies/smart/smart-test-relocate.pl

index 0dc992a..c1acdbb 100755 (executable)
@@ -18,7 +18,9 @@ sub smart_test {
 }
 
 sub smart {
 }
 
 sub smart {
-       open(my $fh, '-|', "smartctl -l selective $drive");
+       my $cmd = "smartctl -l selective $drive";
+       warn "$cmd\n";
+       open(my $fh, '-|', $cmd);
        while(<$fh>) {
                chomp;
                print "# $_\n";
        while(<$fh>) {
                chomp;
                print "# $_\n";
@@ -31,6 +33,7 @@ sub smart {
                        smart_test $sector;
                        return 1;
                } elsif ( m/Self_test_in_progress/ ) {
                        smart_test $sector;
                        return 1;
                } elsif ( m/Self_test_in_progress/ ) {
+                       $test_started = 1;
                        return 1;
                } elsif ( m/Not_testing/ ) {
                        return 1 if $test_started;
                        return 1;
                } elsif ( m/Not_testing/ ) {
                        return 1 if $test_started;
@@ -41,6 +44,6 @@ sub smart {
 }
 
 while ( smart ) {
 }
 
 while ( smart ) {
-       warn "# sleep $delay s\n";
+       warn "sleep $delay s", ( $test_started ? " smart test running..." : "idle" ), "\n";
        sleep $delay;
 }
        sleep $delay;
 }