Commented out some print statments to reduce verbosity

This commit is contained in:
bluesaxman 2019-07-01 11:19:23 -06:00
parent aa3686c0d9
commit 135d5f015b

29
wipe.pl
View File

@ -53,7 +53,7 @@ sub getdisks {
foreach(split("\n",$devices)) {
my $devicepath = $_;
my $serial = `udevadm info --query=all --name=$_ | grep SERIAL_SHORT | sed -e 's/^.*=//'`;
my $model = `udevadm info --query=all --name=$_ | grep "ID_MODEL=" | sed -e 's/^.*=//'`;
my $model = `udevadm info --query=all --name=$_ | grep "ID_MODEL=" | sed -e 's/^.*=//'`;
chomp( $serial );
chomp( $model );
if ( $serial && $model ) {
@ -76,22 +76,22 @@ sub wipethemdrives {
print $diskw $clobber;
close($diskw);
system("sync");
print "Wipe attempt complete, checking...\n";
print "Wipe attempt complete, checking...";
# Read
open(my $diskr, "<", $disks->{$diskid}{"path"}) or return warning("could not open ".$disks->{$diskid}{"path"});
my $diskdata;
read($diskr, $diskdata, 10240000);
my $disksum = md5_base64($diskdata);
close($diskr);
print "Disk Checksum: ".$disksum."\n";
# print "Disk Checksum: ".$disksum."\n";
if ($disksum eq $clobsum) {
print "Checksum ".$color{"green"}."PASSED!!!".$color{"reset"}."\n";
print $disks->{$diskid}{"path"}." is clean.\n";
printf("%-37.37s %9.9s", "Checksum ",$color{"green"}."PASSED!!!".$color{"reset"});
# print $disks->{$diskid}{"path"}." is clean.\n";
return 1;
} else {
print "Wipe Checksum: ".$clobsum."\n";
print "Checksum ".$color{"red"}."FAILED!!!".$color{"reset"}."\n";
print $disks->{$diskid}{"path"}." did not take, it could be bad.\n";
# print "Wipe Checksum: ".$clobsum."\n";
printf("%-37.37s %9.9s", "Checksum ",$color{"red"}."FAILED!!!".$color{"reset"});
# print $disks->{$diskid}{"path"}." did not take, it could be bad.\n";
return 0;
}
}
@ -120,9 +120,9 @@ sub smartcheck {
close( $smartcommand );
for my $smartentry (sort {$a cmp $b} keys %{$disks->{$diskid}{"smart"}}) {
if ($disks->{$diskid}{"smart"}{$smartentry}{"id"} =~ /0x05|0x07|0xc4|0xc5|0xc6|0xc7/) {
printf("%-6.6s %-20.20s\t%-10.10s\t", $disks->{$diskid}{"smart"}{$smartentry}{"id"}, $disks->{$diskid}{"smart"}{$smartentry}{"name"}, $disks->{$diskid}{"smart"}{$smartentry}{"raw_value"});
printf("%-6.6s %-26.26s\t%-26.26s\t", $disks->{$diskid}{"smart"}{$smartentry}{"id"}, $disks->{$diskid}{"smart"}{$smartentry}{"name"}, $disks->{$diskid}{"smart"}{$smartentry}{"raw_value"});
if ($disks->{$diskid}{"smart"}{$smartentry}{"raw_value"} =~ /0|0\/0/) {
print $color{"green"}."Passed".$color{"reset"}."\n";
print $color{"green"}."Passed".$color{"reset"}."\n";
} else { print $color{"red"}."Failed".$color{"reset"}."\n"; return 0}
}
@ -150,17 +150,16 @@ while () {
if ($disks{$diskid}{"wipe"} == 1) {
$disks{$diskid}{"smartpass"} = smartcheck($diskid,\%disks);
if ($disks{$diskid}{"smartpass"} == 1) {
print "Smart looks good.\n";
push(@good, sprintf("%-20.20s\t%-40.40s",$disks{$diskid}{"serial"},$disks{$diskid}{"model"}));
# print "Smart looks good.\n";
push(@good, sprintf("%-26.26s\t%46.46s",$disks{$diskid}{"serial"},$disks{$diskid}{"model"}));
} else { push(@failed, $disks{$diskid}{"serial"}); }
} else { push(@failed, $disks{$diskid}{"serial"}); }
print "="x80;
print "\n"x5;
}
print "These drives were successfully wiped and passed SMART, they may be put back into production:\n";
print "These drives were successfully wiped and passed SMART, they may be put back into\nproduction:\n";
print $color{"green"}.join("\n",sort {$a cmp $b} uniq(@good)).$color{"reset"};
printf "
anykey("\nHit any key to see the list of failed drives. Please also note any drives that do not appear\non ether list. Those should be tried again (if they do not show up after three times assume falure).");
anykey("\nHit any key to see the list of failed drives. Please also note any drives that\ndo not appear on ether list. Those should be tried again (if they do not show\nup after three times assume falure).");
print "The folowing drives are bad, RMA or shred:\n";
print join("\n",sort {$a cmp $b} uniq(@failed));
@failed = ();