/[sysadmin-cookbook]/recepies/smart/smart-test-relocate.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /recepies/smart/smart-test-relocate.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 287 by dpavlin, Wed Jan 25 16:53:11 2012 UTC revision 288 by dpavlin, Wed Jan 25 17:05:33 2012 UTC
# Line 18  sub smart_test { Line 18  sub smart_test {
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";
# Line 31  sub smart { Line 33  sub smart {
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;
# Line 41  sub smart { Line 44  sub smart {
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  }  }

Legend:
Removed from v.287  
changed lines
  Added in v.288

  ViewVC Help
Powered by ViewVC 1.1.26