Gitlab Community Edition Instance

Commit 7c1b3776 authored by Bjoern Nachtwey's avatar Bjoern Nachtwey
Browse files

added dirID parameter to control which stgpooldirs are emptied

parent 799cb6b5
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# 2020-10-28 0.1 initial coding # 2020-10-28 0.1 initial coding
# 2020-11-18 0.2 added stgpool to be processed as an argument # 2020-11-18 0.2 added stgpool to be processed as an argument
# 2021-12-21 0.2.1 added some more informative error messages # 2021-12-21 0.2.1 added some more informative error messages
# 2021-12-21 0.2.2 added "dirID" parameter to control which stgpooldirs are emptied
# #
############################################################################## ##############################################################################
...@@ -40,10 +41,10 @@ use Time::Piece; ...@@ -40,10 +41,10 @@ use Time::Piece;
# check for necessary arguments # check for necessary arguments
############################################################################## ##############################################################################
if ( $#ARGV != 7 ) if ( $#ARGV < 7 or $#ARGV > 8)
{ {
printf "\n\tusage: \n\n\t"; printf "\n\tusage: \n\n\t";
printf "perl -f scripted-container_move.pl <Admin-UID> <Admin-PW> <Ratio of Free data> <Days since last write> <servername as in dsm.sys> <storagepool to process> <directory to move to>"; printf "perl -f scripted-container_move.pl <Admin-UID> <Admin-PW> <Ratio of Free data> <Days since last write> <servername as in dsm.sys> <storagepool to process> <directory to move to> [dirID]";
printf "\n\n"; printf "\n\n";
exit 99; exit 99;
} }
...@@ -57,18 +58,19 @@ if ( $#ARGV != 7 ) ...@@ -57,18 +58,19 @@ if ( $#ARGV != 7 )
############################################################################## ##############################################################################
# C R E D E N T I A L S # C R E D E N T I A L S
############################################################################## ##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW my $admpwd = $ARGV[1]; # or replace by expicit PW
############################################################################## ##############################################################################
# R U N T I M E S E T T I N G S # R U N T I M E S E T T I N G S
############################################################################## ##############################################################################
my $utillimit = $ARGV[2]; # ratio of utilization my $utillimit = $ARGV[2]; # ratio of utilization
my $dayslimit = $ARGV[3]; # limit of days for last write access my $dayslimit = $ARGV[3]; # limit of days for last write access
my $entrylimit = $ARGV[4]; # limit of entries to be moved my $entrylimit = $ARGV[4]; # limit of entries to be moved
my $servername = $ARGV[5]; # servername my $servername = $ARGV[5]; # servername
my $stgpool = $ARGV[6]; # container pool to be processed my $stgpool = $ARGV[6]; # container pool to be processed
my $destdir = $ARGV[7]; # destination stgpooldir my $destdir = $ARGV[7]; # destination stgpooldir
my $dirid = $ARGV[8]; # dirID of stpooldir to move from (optional)
############################################################################## ##############################################################################
# O U T P U T S E T T I N G S # O U T P U T S E T T I N G S
...@@ -80,7 +82,6 @@ my $outputpath = "/TSM/log/" . $date . "-$servername-containermove.log"; ...@@ -80,7 +82,6 @@ my $outputpath = "/TSM/log/" . $date . "-$servername-containermove.log";
# set some variables # set some variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmadsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile"; my $dsmadsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
...@@ -105,17 +106,25 @@ my $rc_test; # test for return code of command ...@@ -105,17 +106,25 @@ my $rc_test; # test for return code of command
open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpath; open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpath;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main routine # main routine
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if (defined($dirid))
$selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ". {
"from containers where ". $selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ".
"( STGPOOL_NAME='$stgpool' and ". "from containers where ".
"state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ". "( STGPOOL_NAME='$stgpool' and DIRID='$dirid' and ".
"order by pct desc limit $entrylimit"; "state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ".
"order by pct desc limit $entrylimit";
}
else
{
$selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ".
"from containers where ".
"( STGPOOL_NAME='$stgpool' and ".
"state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ".
"order by pct desc limit $entrylimit";
}
$command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null"; $command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null";
@containerlist = split '\n' , `$command`; @containerlist = split '\n' , `$command`;
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# 2020-10-28 0.1 initial coding # 2020-10-28 0.1 initial coding
# 2020-11-18 0.2 added stgpool to be processed as an argument # 2020-11-18 0.2 added stgpool to be processed as an argument
# 2021-12-21 0.2.1 added some more informative error messages, special version for SP7-Servers without "limit" # 2021-12-21 0.2.1 added some more informative error messages, special version for SP7-Servers without "limit"
# 2021-12-21 0.2.2 added "dirID" parameter to control which stgpooldirs are emptied
# #
############################################################################## ##############################################################################
...@@ -43,7 +44,7 @@ use Time::Piece; ...@@ -43,7 +44,7 @@ use Time::Piece;
if ( $#ARGV < 7 or $#ARGV > 8) if ( $#ARGV < 7 or $#ARGV > 8)
{ {
printf "\n\tusage: \n\n\t"; printf "\n\tusage: \n\n\t";
printf "perl -f scripted-container_move.pl <Admin-UID> <Admin-PW> <Ratio of Free data> <Days since last write> <servername as in dsm.sys> <storagepool to process> <directory to move to>"; printf "perl -f scripted-container_move.pl <Admin-UID> <Admin-PW> <Ratio of Free data> <Days since last write> <servername as in dsm.sys> <storagepool to process> <directory to move to> [dirID]";
printf "\n\n"; printf "\n\n";
exit 99; exit 99;
} }
...@@ -113,18 +114,18 @@ open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpa ...@@ -113,18 +114,18 @@ open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpa
if (defined($dirid)) if (defined($dirid))
{ {
$selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ". $selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ".
"from containers where ". "from containers where ".
"( STGPOOL_NAME='$stgpool' and DIRID='$dirid' and ". "( STGPOOL_NAME='$stgpool' and DIRID='$dirid' and ".
"state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ". "state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ".
"order by pct desc"; "order by pct desc";
} }
else else
{ {
$selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ". $selectstatement = "select CONTAINER_NAME, CAST(FLOAT(FREE_SPACE_MB / TOTAL_SPACE_MB ) AS DEC (5,4)) AS PCT, FREE_SPACE_MB, TOTAL_SPACE_MB ".
"from containers where ". "from containers where ".
"( STGPOOL_NAME='$stgpool' and ". "( STGPOOL_NAME='$stgpool' and ".
"state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ". "state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ".
"order by pct desc"; "order by pct desc";
} }
$command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null"; $command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment