- Timestamp:
- Jun 25, 2020, 1:37:44 PM (6 years ago)
- Location:
- trunk/tools/eam/rebalance
- Files:
-
- 2 edited
-
neb_check_reinsert.pl (modified) (2 diffs)
-
rebalance.mana (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rebalance/neb_check_reinsert.pl
r41383 r41385 108 108 109 109 unless (-e "$tgt_subdir/$movefile") { 110 print " MISSING FILE: $tgt_subdir/$movefile\n";110 print "ERROR : MISSING FILE: $tgt_subdir/$movefile\n"; 111 111 next; 112 112 } … … 114 114 # print "movefile: $movefile\n"; 115 115 116 my ($ins_id) = $movefile =~ m| [0-9a-fA-F][0-9a-fA-F]/(\d+)\..*|;116 my ($ins_id) = $movefile =~ m|^[0-9a-fA-F][0-9a-fA-F]/(\d+)\..*|; 117 117 my $summary = "$tgt_subdir/$movefile"; 118 118 -
trunk/tools/eam/rebalance/rebalance.mana
r41383 r41385 12 12 $VERSION = NONE 13 13 14 $NSUBDIR = 1 15 # $NSUBDIR = 0x100 16 17 macro run.find 14 # $NSUBDIR = 1 15 $NSUBDIR = 0x100 16 17 # alternatve code for subdirs: 18 # list subdirs -glob $source/[0-9,a-f][0-9,a-f] 19 # for i 0 $subdirs:n 20 21 macro run.find.test 18 22 if ($0 != 7) 19 echo "USAGE: run.find (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)Fraction)"23 echo "USAGE: run.find.test (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (Fraction)" 20 24 echo "srchost, tgthost : e.g., ipp070" 21 25 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" … … 26 30 local srchost srcvol tgthost tgtvol Fraction 27 31 32 # NOTE: tgthost and tgtvol are not actually used in this step 28 33 $srchost = $1 29 34 $srcvol = $2 … … 43 48 ## partitions 44 49 45 $result = `df -l $source | tail -n 1`50 $result = `df -l -m $source | tail -n 1` 46 51 if ("$result" == "") 47 52 echo "invalid source partition or partition is not local" … … 53 58 54 59 $Nbytes = 1024*1024*((1 - $Fraction)*$word:1 - $word:3) 60 61 echo "MB total : $word:1"; # e.g. 100M 62 echo "MB used : $word:2"; # e.g. 95M 63 echo "MB avail : $word:3"; # e.g. 5M 64 65 echo goal used : {$Fraction*$word:1}; # e.g., 10M 66 echo to remove : {$word:2 - $Fraction*$word:1}; # e.g., 95M - 90M = 5M 67 echo alt calc : {(1 - $Fraction)*$word:1 - $word:3}; # e.g., 10M - 5M = 5M 68 69 echo Nbytes to remove: $Nbytes 70 echo NGB to remove : {$Nbytes/1024^3} 71 72 if ($Nbytes < 0) 73 echo "source partition is already below goal fraction" 74 echo "Nbytes to remove : $Nbytes" 75 break 76 end 77 78 # calculate the number of bytes to remove per subdir 79 $NremoveSub = $Nbytes / 256 80 81 echo "** removing {$NremoveSub/$TB_BYTE} TB per nebulous subdir for total of {$Nbytes/$TB_BYTE} TB" 82 end 83 84 macro run.find 85 if ($0 != 7) 86 echo "USAGE: run.find (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (Fraction)" 87 echo "srchost, tgthost : e.g., ipp070" 88 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" 89 echo "Fraction : disk fraction target" 90 break 91 end 92 93 local srchost srcvol tgthost tgtvol Fraction 94 95 # NOTE: tgthost and tgtvol are not actually used in this step 96 $srchost = $1 97 $srcvol = $2 98 $tgthost = $3 99 $tgtvol = $4 100 $VERSION = $5 101 $Fraction = $6 102 103 # generate the full paths: 104 $source = /data/$srchost.$srcvol/nebulous 105 $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous 106 107 ## make sure target exists 108 mkdir $target 109 110 ## this script must be run on the same machine as the source 111 ## partitions 112 113 $result = `df -l -m $source | tail -n 1` 114 if ("$result" == "") 115 echo "invalid source partition or partition is not local" 116 echo "source: $source" 117 break 118 end 119 120 list word -split $result 121 122 $Nbytes = 1024*1024*((1 - $Fraction)*$word:1 - $word:3) 123 124 echo "MB total : $word:1"; # e.g. 100M 125 echo "MB used : $word:2"; # e.g. 95M 126 echo "MB avail : $word:3"; # e.g. 5M 127 128 echo goal used : {$Fraction*$word:1}; # e.g., 10M 129 echo to remove : {$word:2 - $Fraction*$word:1}; # e.g., 95M - 90M = 5M 130 echo alt calc : {(1 - $Fraction)*$word:1 - $word:3}; # e.g., 10M - 5M = 5M 131 132 echo Nbytes to remove: $Nbytes 133 echo NGB to remove : {$Nbytes/1024^3} 55 134 56 135 if ($Nbytes < 0) … … 135 214 $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous 136 215 137 # list subdirs -glob $source/[0-9,a-f][0-9,a-f]138 # for i 0 $subdirs:n139 140 216 for i 0 $NSUBDIR 141 217 sprintf srcdir "%s/%02x" $source $i … … 201 277 end 202 278 203 if ($NtotalError )279 if ($NtotalError > 0) 204 280 echo "ERROR: $NtotalError errors with insert" 281 echo "use this command to see the errors:" 282 fprint "grep ERROR %s/??/rebalance/insert.%s.log" $source $VERSION 205 283 else 206 284 echo "SUCCESS: no insert errors detected" … … 267 345 macro run.trash 268 346 if ($0 != 6) 269 echo "USAGE: run. insert(srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"347 echo "USAGE: run.trash (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 270 348 echo "srchost, tgthost : e.g., ipp070" 271 349 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" … … 286 364 break 287 365 end 288 289 # list subdirs -glob $source/[0-9,a-f][0-9,a-f]290 # for i 0 $subdirs:n291 366 292 367 for i 0 $NSUBDIR … … 309 384 end 310 385 386 macro run.check.trash 387 if ($0 != 6) 388 echo "USAGE: run.check.trash (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 389 echo "srchost, tgthost : e.g., ipp070" 390 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" 391 break 392 end 393 394 local srchost tgthost srcvol tgtvol 395 396 $srchost = $1 397 $srcvol = $2 398 399 $VERSION = $5 400 401 $myhost = `hostname` 402 if ("$myhost" != "$srchost") 403 echo "please run on $srchost" 404 break 405 end 406 407 for i 0 $NSUBDIR 408 sprintf trashdir "/data/%s.%s/nebulous/%02x/trash" $srchost $srcvol $i 409 sprintf trashlog "/data/%s.%s/nebulous/%02x/rebalance/check.trash.%s.log" $srchost $srcvol $i $VERSION 410 411 echo ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir > $trashlog 412 $EXEC ./neb_check_trash.pl --srchost $srchost --trashdir $trashdir > $trashlog 413 end 414 415 $NtotalError = 0 416 for i 0 $NSUBDIR 417 sprintf trashlog "/data/%s.%s/nebulous/%02x/rebalance/check.trash.%s.log" $srchost $srcvol $i $VERSION 418 # count total number of errors 419 $NgroupError = `grep ERROR $trashlog | wc -l` 420 $NtotalError += $NgroupError 421 end 422 423 if ($NtotalError > 0) 424 echo "ERROR: $NtotalError errors with check.trash" 425 else 426 echo "SUCCESS: no check errors detected" 427 end 428 end 429 430 macro run.empty.trash 431 if ($0 != 6) 432 echo "USAGE: run.empty.trash (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 433 echo "srchost, tgthost : e.g., ipp070" 434 echo "srcvol, tgtvol : e.g., 0 (for /data/ipp070.0/nebulous)" 435 break 436 end 437 438 local srchost tgthost srcvol tgtvol 439 440 $srchost = $1 441 $srcvol = $2 442 443 $VERSION = $5 444 445 $myhost = `hostname` 446 if ("$myhost" != "$srchost") 447 echo "please run on $srchost" 448 break 449 end 450 451 ### *** I need a test to confirm I have run check.trash *** #### 452 453 for i 0 $NSUBDIR 454 sprintf trashdir "/data/%s.%s/nebulous/%02x/trash" $srchost $srcvol $i 455 456 # list of files which have been moved & checked 457 sprintf movelist /data/%s.%s/nebulous/%02x/rebalance/movefiles.%s.txt $srchost $srcvol $i $VERSION 458 459 list files -x "cat $movelist" 460 for j 0 $files:n 461 basename $files:$j -var myfile 462 463 # remove the file from the trash directory 464 echo rm $trashdir/$myfile 465 exec rm $trashdir/$myfile 466 end 467 end 468 end 469 311 470 if ($SCRIPT) 312 471 if ($argv:n < 6) 313 472 echo "USAGE: rebalance.mana (MODE) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) [options]" 314 473 echo "" 315 echo "MODE: find , rsync, insert, check,trash"474 echo "MODE: find.test, find, rsync, insert, check, trash, check.trash, empty.trash" 316 475 echo "" 317 476 echo "srchost, tgthost : e.g., ipp070" … … 320 479 echo "VERSION : free-form string (e.g., YYYYMMDD)" 321 480 exit 2 481 end 482 483 #### find.test #### 484 if ("$argv:0" == "find.test") 485 if ($argv:n != 7) 486 echo "USAGE: rebalance.mana (find.test) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) (Fraction)" 487 echo "Fraction : disk fraction target" 488 break 489 end 490 run.find.test $argv:1 $argv:2 $argv:3 $argv:4 $argv:5 $argv:6 491 exit 0 322 492 end 323 493 … … 373 543 end 374 544 545 #### check.trash #### 546 if ("$argv:0" == "check.trash") 547 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:5 552 exit 0 553 end 554 555 #### empty.trash #### 556 if ("$argv:0" == "empty.trash") 557 if ($argv:n != 6) 558 echo "USAGE: rebalance.mana (check.trash) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)" 559 break 560 end 561 run.empty.trash $argv:1 $argv:2 $argv:3 $argv:4 $argv:5 562 exit 0 563 end 564 375 565 exit 0 376 566 end
Note:
See TracChangeset
for help on using the changeset viewer.
