Commit 17042b68 authored by bnachtw's avatar bnachtw
Browse files

added stgpool to be processed as an argument

parent 88e21533
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# changelog # changelog
# date version remark # date version remark
# 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
# #
############################################################################## ##############################################################################
...@@ -38,10 +39,10 @@ use Time::Piece; ...@@ -38,10 +39,10 @@ use Time::Piece;
# check for necessary arguments # check for necessary arguments
############################################################################## ##############################################################################
if ( $#ARGV != 6 ) if ( $#ARGV != 7 )
{ {
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> <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>";
printf "\n\n"; printf "\n\n";
exit 99; exit 99;
} }
...@@ -65,7 +66,8 @@ my $utillimit = $ARGV[2]; # ratio of utilization ...@@ -65,7 +66,8 @@ 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 $destdir = $ARGV[6]; # destination stgpooldir my $stgpool = $ARGV[6]; # container pool to be processed
my $destdir = $ARGV[7]; # destination stgpooldir
############################################################################## ##############################################################################
# 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
...@@ -109,7 +111,8 @@ open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpa ...@@ -109,7 +111,8 @@ open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpa
$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 ".
"( state='AVAILABLE' and (FREE_SPACE_MB / TOTAL_SPACE_MB)>$utillimit and (DAYS(current_date) - DAYS(LASTWR_DATE))>$dayslimit) ". "( 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"; "order by pct desc limit $entrylimit";
$command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null"; $command = "$dsmadmc $dsmadsmargs -se=$servername \"$selectstatement\" 2>/dev/null";
...@@ -130,6 +133,7 @@ container: foreach $thiscontainer (@containerlist) ...@@ -130,6 +133,7 @@ container: foreach $thiscontainer (@containerlist)
printf ">>%s\n", $thiscontainer; printf ">>%s\n", $thiscontainer;
if ( ( $thiscontainer =~ m/^ANR/ ) or ($thiscontainer =~ m/^ANS/) ) if ( ( $thiscontainer =~ m/^ANR/ ) or ($thiscontainer =~ m/^ANS/) )
{ {
printf LOGFILE "%s: nothing to do! \n", $time;
last container; last container;
} }
else else
...@@ -139,6 +143,7 @@ container: foreach $thiscontainer (@containerlist) ...@@ -139,6 +143,7 @@ container: foreach $thiscontainer (@containerlist)
# move data # move data
$command = "$dsmadmc $dsmadsmargs -se=$servername \"move container $container_name STGPOOLDIRectory=$destdir\" 2>/dev/null"; $command = "$dsmadmc $dsmadsmargs -se=$servername \"move container $container_name STGPOOLDIRectory=$destdir\" 2>/dev/null";
printf "CMD:%s\n\n", $command;
@result = split '\n' , `$command`; @result = split '\n' , `$command`;
$rc_test = grep( /Return/, @result); $rc_test = grep( /Return/, @result);
...@@ -151,4 +156,4 @@ container: foreach $thiscontainer (@containerlist) ...@@ -151,4 +156,4 @@ container: foreach $thiscontainer (@containerlist)
} }
close LOGFILE; close LOGFILE;
exit 0; exit 0;
\ No newline at end of file
Markdown is supported
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