IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41385


Ignore:
Timestamp:
Jun 25, 2020, 1:37:44 PM (6 years ago)
Author:
eugene
Message:

some updates to errors

Location:
trunk/tools/eam/rebalance
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/eam/rebalance/neb_check_reinsert.pl

    r41383 r41385  
    108108
    109109    unless (-e "$tgt_subdir/$movefile") {
    110         print "MISSING FILE: $tgt_subdir/$movefile\n";
     110        print "ERROR : MISSING FILE: $tgt_subdir/$movefile\n";
    111111        next;
    112112    }
     
    114114    # print "movefile: $movefile\n";
    115115
    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+)\..*|;
    117117    my $summary = "$tgt_subdir/$movefile";
    118118
  • trunk/tools/eam/rebalance/rebalance.mana

    r41383 r41385  
    1212$VERSION = NONE
    1313
    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
     21macro run.find.test
    1822  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)"
    2024    echo "srchost, tgthost : e.g., ipp070"
    2125    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
     
    2630  local srchost srcvol tgthost tgtvol Fraction
    2731
     32  # NOTE: tgthost and tgtvol are not actually used in this step
    2833  $srchost = $1
    2934  $srcvol = $2
     
    4348  ## partitions
    4449
    45   $result = `df -l $source | tail -n 1`
     50  $result = `df -l -m $source | tail -n 1`
    4651  if ("$result" == "")
    4752    echo "invalid source partition or partition is not local"
     
    5358
    5459  $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"
     82end
     83
     84macro 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}
    55134
    56135  if ($Nbytes < 0)
     
    135214  $target = /data/$tgthost.$tgtvol/rebalance/$srchost.$srcvol/nebulous
    136215
    137 # list subdirs -glob $source/[0-9,a-f][0-9,a-f]
    138 # for i 0 $subdirs:n
    139 
    140216  for i 0 $NSUBDIR
    141217    sprintf srcdir "%s/%02x" $source $i
     
    201277  end
    202278
    203   if ($NtotalError)
     279  if ($NtotalError > 0)
    204280    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
    205283  else
    206284    echo "SUCCESS: no insert errors detected"
     
    267345macro run.trash
    268346  if ($0 != 6)
    269     echo "USAGE: run.insert (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
     347    echo "USAGE: run.trash (srchost) (srcvol) (tgthost) (tgtvol) (VERSION)"
    270348    echo "srchost, tgthost : e.g., ipp070"
    271349    echo "srcvol, tgtvol   : e.g., 0 (for /data/ipp070.0/nebulous)"
     
    286364    break
    287365  end
    288 
    289 # list subdirs -glob $source/[0-9,a-f][0-9,a-f]
    290 # for i 0 $subdirs:n
    291366
    292367  for i 0 $NSUBDIR
     
    309384end
    310385
     386macro 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
     428end
     429
     430macro 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
     468end
     469
    311470if ($SCRIPT)
    312471  if ($argv:n < 6)
    313472    echo "USAGE: rebalance.mana (MODE) (srchost) (srcvol) (tgthost) (tgtvol) (VERSION) [options]"
    314473    echo ""
    315     echo "MODE: find, rsync, insert, check, trash"
     474    echo "MODE: find.test, find, rsync, insert, check, trash, check.trash, empty.trash"
    316475    echo ""
    317476    echo "srchost, tgthost : e.g., ipp070"
     
    320479    echo "VERSION : free-form string (e.g., YYYYMMDD)"
    321480    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
    322492  end
    323493
     
    373543  end
    374544
     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
    375565  exit 0
    376566end
Note: See TracChangeset for help on using the changeset viewer.