- Timestamp:
- Aug 25, 2020, 10:15:47 AM (6 years ago)
- Location:
- trunk/tools/eam/rebalance
- Files:
-
- 2 added
- 2 edited
-
duplicates.sh (added)
-
neb_check_trash.pl (modified) (4 diffs)
-
neb_link_repair.pl (added)
-
rebalance.mana (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rebalance/neb_check_trash.pl
r41384 r41406 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 13 13 14 my ($srchost,$trashdir );14 my ($srchost,$trashdir,$savedir); 15 15 16 16 GetOptions( 17 'srchost=s' => \$srchost, 18 'trashdir=s' => \$trashdir) || pod2usage(2); 17 'srchost=s' => \$srchost, 18 'trashdir=s' => \$trashdir, 19 'savedir=s' => \$savedir) || pod2usage(2); 19 20 20 21 my ( $dbname, $dbhost, $dbport, $dbpass, $dbuser ); … … 39 40 defined $dbname && defined $dbhost && defined $dbport && defined $dbuser && defined $dbpass; 40 41 41 pod2usage( -msg => "Cannot determine trash directory", -exitval => 2) unless defined $trashdir && defined $srchost;42 pod2usage( -msg => "Cannot determine srchost, trashdir, or savedir", -exitval => 2) unless defined $trashdir && defined $savedir && defined $srchost; 42 43 43 44 my $host_check = `hostname`; chomp($host_check); … … 52 53 53 54 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n"; 55 56 unless (mkdir $savedir) { die "failed to make savedir\n"; } 54 57 55 58 my @files = <${trashdir}/*>; … … 96 99 97 100 if ($Nrows == 0) { # We should find this instance 98 print "ERROR : NO DB ENTRY: $summary\n"; 101 print "ERROR : NO DB ENTRY: (saving) $summary\n"; 102 system ("mv $filename $savedir/"); 99 103 next; 100 104 } -
trunk/tools/eam/rebalance/rebalance.mana
r41385 r41406 158 158 sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION 159 159 sprintf movelog %s/rebalance/movefiles.%s.log $srcdir $VERSION 160 sprintf subdirset "%s/ 0?" $srcdir160 sprintf subdirset "%s/??" $srcdir 161 161 exec find $subdirset -size +$BIGSIZE > $filelist 162 162 list files -x "/bin/ls -l `cat $filelist` | sort -k 5nr" … … 228 228 end 229 229 230 macro run.rsync.check 231 if ($0 != 7) 232 echo "USAGE: run.rsync.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (OUTVER)" 233 echo "srchost, tgthost : e.g., ipp070" 234 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" 235 break 236 end 237 238 local srchost srcvol tgthost tgtvol 239 240 $srchost = $1 241 $srcvol = $2 242 $tgthost = $3 243 $tgtvol = $4 244 $VERSION = $5 245 $OUTVER = $6 246 247 # generate the full paths: 248 $source = /data/$srchost.$srcvol/nebulous 249 $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous 250 251 for i 0 $NSUBDIR 252 sprintf srcdir "%s/%02x" $source $i 253 sprintf tgtdir "%s/%02x" $target $i 254 # echo $srcdir 255 256 # generate initial file list (all big files) 257 sprintf movelist %s/rebalance/movefiles.%s.txt $srcdir $VERSION 258 sprintf movelog %s/rebalance/movefiles.%s.log $srcdir $OUTVER 259 260 echo "rsyncing $srcdir/ to $tgtdir/ : $movelog" 261 exec rsync -auv --files-from=$movelist $srcdir/ $tgtdir/ >& $movelog 262 end 263 end 264 230 265 # names are defined for a single src & tgt pair 231 266 macro run.insert … … 287 322 288 323 # names are defined for a single src & tgt pair 289 macro run. check324 macro run.insert.check 290 325 if ($0 != 6) 291 echo "USAGE: run. check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"326 echo "USAGE: run.insert.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 292 327 echo "srchost, tgthost : e.g., ipp070" 293 328 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" … … 384 419 end 385 420 386 macro run. check.trash421 macro run.trash.check 387 422 if ($0 != 6) 388 echo "USAGE: run. check.trash(srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"423 echo "USAGE: run.trash.check (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 389 424 echo "srchost, tgthost : e.g., ipp070" 390 425 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" … … 407 442 for i 0 $NSUBDIR 408 443 sprintf trashdir "/data/%s.%s/nebulous/%02x/trash" $srchost $srcvol $i 444 sprintf savedir "/data/%s.%s/nebulous/%02x/save" $srchost $srcvol $i 409 445 sprintf trashlog "/data/%s.%s/nebulous/%02x/rebalance/check.trash.%s.log" $srchost $srcvol $i $VERSION 410 446 411 echo ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir > $trashlog412 $EXEC ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir > $trashlog447 echo ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir --savedir $savedir > $trashlog 448 $EXEC ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir --savedir $savedir > $trashlog 413 449 end 414 450 … … 455 491 456 492 # list of files which have been moved & checked 457 sprintf movelist /data/%s.%s/nebulous/%02x/rebalance/movefiles.%s.txt $srchost $srcvol $i $VERSION458 459 list files - x "cat $movelist"493 # sprintf movelist /data/%s.%s/nebulous/%02x/rebalance/movefiles.%s.txt $srchost $srcvol $i $VERSION 494 495 list files -glob $trashdir/* 460 496 for j 0 $files:n 461 basename $files:$j -var myfile 462 497 file $files:$j -can-write canWrite 498 if (not($canWrite)) 499 echo "SKIP write-protected file : $files:$j" 500 next 501 end 463 502 # remove the file from the trash directory 464 echo rm $ trashdir/$myfile465 exec rm $ trashdir/$myfile503 echo rm $files:$j 504 exec rm $files:$j 466 505 end 467 506 end … … 469 508 470 509 if ($SCRIPT) 471 if ($argv:n < 6)510 if ($argv:n < 1) 472 511 echo "USAGE: rebalance.mana (MODE) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) [options]" 473 512 echo "" 474 echo "MODE: find.test, find, rsync, insert, check, trash, check.trash, empty.trash"513 echo "MODE: find.test, find, rsync, rsync.check, insert, insert.check, trash, trash.check, empty.trash" 475 514 echo "" 476 515 echo "srchost, tgthost : e.g., ipp070" … … 513 552 end 514 553 554 #### rsync.check #### 555 if ("$argv:0" == "rsync.check") 556 if ($argv:n != 7) 557 echo "USAGE: rebalance.mana (rsync.check) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (OUTVER)" 558 break 559 end 560 run.rsync.check $argv:1 $argv:2 $argv:3 $argv:4 $argv:5 $argv:6 561 exit 0 562 end 563 515 564 #### insert #### 516 565 if ("$argv:0" == "insert") … … 523 572 end 524 573 525 #### check ####526 if ("$argv:0" == " check")574 #### insert.check #### 575 if ("$argv:0" == "insert.check") 527 576 if ($argv:n != 6) 528 echo "USAGE: rebalance.mana ( check) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"529 break 530 end 531 run. check $argv:1 $argv:2 $argv:3 $argv:4 $argv:5577 echo "USAGE: rebalance.mana (insert.check) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 578 break 579 end 580 run.insert.check $argv:1 $argv:2 $argv:3 $argv:4 $argv:5 532 581 exit 0 533 582 end … … 543 592 end 544 593 545 #### check.trash####546 if ("$argv:0" == " check.trash")594 #### trash.check #### 595 if ("$argv:0" == "trash.check") 547 596 if ($argv:n != 6) 548 echo "USAGE: rebalance.mana ( check.trash) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"549 break 550 end 551 run. check.trash$argv:1 $argv:2 $argv:3 $argv:4 $argv:5597 echo "USAGE: rebalance.mana (trash.check) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 598 break 599 end 600 run.trash.check $argv:1 $argv:2 $argv:3 $argv:4 $argv:5 552 601 exit 0 553 602 end … … 556 605 if ("$argv:0" == "empty.trash") 557 606 if ($argv:n != 6) 558 echo "USAGE: rebalance.mana ( check.trash) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"607 echo "USAGE: rebalance.mana (empty.trash) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 559 608 break 560 609 end … … 563 612 end 564 613 565 exit 0 566 end 614 echo "ERROR: unknown mode $argv:0" 615 exit 1 616 end
Note:
See TracChangeset
for help on using the changeset viewer.
