Commit 1eea72c4 authored by bnachtw's avatar bnachtw
Browse files

Typo fixed

parent 17042b68
#! /bin/bash
# take $1 as username
# convert username to lowcase and upcase
luser=$(echo $1 | tr '[:upper:]' '[:lower:]');
uuser=$(echo $1 | tr '[:lower:]' '[:upper:]');
# copy / sync vital instance files
# -c checksum instead of timestamp
# -t preserve timestamp
# -u update only
rsync -ctu /$luser/config/cert* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/devconf.dat /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmkeydb* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmserv.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/tsmdbmgr.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/volhist.dat /tsmshare/DRM/$uuser/
set -x
# do DB2 analysis
su -c "cd /tsmshare/OfflineReorg/$luser && sh /tsmshare/bin/get-DB2-Analysis.sh" -l $luser
# remove old planfiles
find /tsmshare/DRM/$uuser/ -name "*" -ctime +30 -exec rm -vf {} \;
# remove old dsmffdc.log files
find /$luser/config -name "dsmffdc.log.*" -ctime +30 -exec rm -vf {} \;
# remove old errorlog files
find /$luser/sqllib/db2dump -name "[0-9]*.dump.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.stack.txt" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.trap.txt" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "TSMDB1.*.events.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "db2pd.[0-9]*.*.events.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/config -name "dsmffdc.*.log" -ctime +30 -exec rm -vf {} \;
# prune db2diaglog and remove old files
su -c "cd /$luser/sqllib/db2dump/DIAG0000 && db2diag -A" -l $luser
find /$luser/sqllib/db2dump -name "db2diag*log_*" -ctime +30 -exec rm -vf {} \;
# remove old weblog file
rm -f /tsm/dsmwebcl.log
#! /bin/bash
# take $1 as username
# convert username to lowcase and upcase
luser=$(echo $1 | tr '[:upper:]' '[:lower:]');
uuser=$(echo $1 | tr '[:lower:]' '[:upper:]');
# copy / sync vital instance files
# -c checksum instead of timestamp
# -t preserve timestamp
# -u update only
rsync -ctu /$luser/config/cert* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/devconf.dat /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmkeydb* /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/dsmserv.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/tsmdbmgr.opt /tsmshare/DRM/$uuser/
rsync -ctu /$luser/config/volhist.dat /tsmshare/DRM/$uuser/
set -x
# do DB2 analysis
su -c "cd /tsmshare/OfflineReorg/$luser && sh /tsmshare/bin/get-DB2-Analysis.sh" -l $luser
# remove old planfiles
find /tsmshare/DRM/$uuser/ -name "*" -ctime +30 -exec rm -vf {} \;
# remove old dsmffdc.log files
find /$luser/config -name "dsmffdc.log.*" -ctime +30 -exec rm -vf {} \;
# remove old errorlog files
find /$luser/sqllib/db2dump -name "[0-9]*.dump.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.stack.txt" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "[0-9]*.trap.txt" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "TSMDB1.*.events.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/sqllib/db2dump -name "db2pd.[0-9]*.*.events.bin" -ctime +30 -exec rm -vf {} \;
find /$luser/config -name "dsmffdc.*.log" -ctime +30 -exec rm -vf {} \;
# prune db2diaglog and remove old files
su -c "cd /$luser/sqllib/db2dump/DIAG0000 && db2diag -A" -l $luser
find /$luser/sqllib/db2dump -name "db2diag*log_*" -ctime +30 -exec rm -vf {} \;
# remove old weblog file
rm -f /tsm/dsmwebcl.log
#! /usr/bin/perl
##############################################################################
#
# scripted-container_move.pl
#
# script for identifying sparse containers and moving their data
#
#
# (C) 2020 GWDG Goettingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# changelog
# date version remark
# 2020-10-28 0.1 initial coding
# 2020-11-18 0.2 added stgpool to be processed as an argument
#
##############################################################################
use warnings;
use strict;
use Time::Piece;
##############################################################################
# check for necessary arguments
##############################################################################
if ( $#ARGV != 7 )
{
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 "\n\n";
exit 99;
}
##############################################################################
##############################################################################
# F I L L I N Y O U R S E T T I N G S H E R E
##############################################################################
##############################################################################
##############################################################################
# C R E D E N T I A L S
##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
##############################################################################
# R U N T I M E S E T T I N G S
##############################################################################
my $utillimit = $ARGV[2]; # ratio of utilization
my $dayslimit = $ARGV[3]; # limit of days for last write access
my $entrylimit = $ARGV[4]; # limit of entries to be moved
my $servername = $ARGV[5]; # servername
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
##############################################################################
my $date = localtime->strftime ('%F');
my $outputpath = "/TSM/log/" . $date . "-$servername-containermove.log";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set some variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmadsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
# # some lists to be processed
my @result; # return of select
my @containerlist; # list of containers eligable for MOVE
# # some loop iterators
my $thiscontainer;
my $container_name; # name of actual container
my $dataamount; # amount of data stored on actual container
my $freeamount; # amount of free space on actual container
# for logging
my $time = localtime->strftime ('%R');
my $global_freeamount; # amount of space freed by moving
# # new variables
my $command; # put system command in seperate variable for debugging
my $selectstatement; # .. same with building select statements :-)
my $rc_test; # test for return code of command
open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpath;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main routine
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$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";
@containerlist = split '\n' , `$command`;
if ( ! @containerlist )
{
printf LOGFILE "%s: nothing to do! \n", $time;
close LOGFILE;
exit 0;
}
else
{
container: foreach $thiscontainer (@containerlist)
{
printf ">>%s\n", $thiscontainer;
if ( ( $thiscontainer =~ m/^ANR/ ) or ($thiscontainer =~ m/^ANS/) )
{
printf LOGFILE "%s: nothing to do! \n", $time;
last container;
}
else
{
($container_name, undef, $freeamount, $dataamount) = split ' ', $thiscontainer;
# move data
$command = "$dsmadmc $dsmadsmargs -se=$servername \"move container $container_name STGPOOLDIRectory=$destdir\" 2>/dev/null";
printf "CMD:%s\n\n", $command;
@result = split '\n' , `$command`;
$rc_test = grep( /Return/, @result);
if ( $rc_test == 0 )
{
printf LOGFILE "%s: move data %s (saving %7.2f GB)\n", $time, $container_name, $freeamount;
}
}
}
}
close LOGFILE;
exit 0;
#! /usr/bin/perl
##############################################################################
#
# scripted-reclamation_I1.pl
#
# script for identifying sparse tapes not uses some days to move it's data
# so doing reclamation for a large environment with few tape drives
#
#
# (C) 2016, 2017 GWDG Goettingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# changelog
# date version remark
# 2016-08-04 0.9 initial coding
# 2017-12-20 0.9.1 renamed, added filling tapes not used
# 2018-07-18 0.9.2 added Apache License
#
##############################################################################
use warnings;
use strict;
use Time::Piece;
##############################################################################
##############################################################################
# F I L L I N Y O U R S E T T I N G S H E R E
##############################################################################
##############################################################################
##############################################################################
# C R E D E N T I A L S
##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
##############################################################################
# R U N T I M E S E T T I N G S
##############################################################################
my $dayslimit = $ARGV[2]; # number of days a volume wasn't use for write
my $sizelimit_GB = $ARGV[3]; # threshold amount of data to be moved [GB]
# my $sparsetaperation = $ARGV[4]; # minimum ratio of scratch tape to start reclmation
my $libman = 'lm101'; # Name of Libman as given in dsm.sys
# list of servers to be processed (names as given in "dsm.sys"):
my @serverlist = qw /tsm110 tsm113 tsm131 tsm182 tsm230 tsm231 tsm234/;
my $devc = "I1%"; # Name or pattern to look for in select
##############################################################################
# O U T P U T S E T T I N G S
##############################################################################
my $date = localtime->strftime ('%F');
my $outputpath = "/TSM/log/" . $date . "-reclamation_I1.log";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# set some variables
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmadsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
# # some lists to be processed
my @result; # return of select
my $emptydrives; # number of empty drives
my @volumelist; # list of volumes eligable for MOVE
# # some loop iterators
my $server; # actual server name
my $thisvolume;
my $volume_name; # name of actual volume
my @global_volumelist; # list of *all* reclaimable volumes to be ordered by data amount
my @sorted_global_volumelist; # list of *all* reclaimable volumes ordered by data amount
my $dataamount; # amount of data stored on actual tape
# for logging
my $time = localtime->strftime ('%R');
# # new variables
my $command; # put system command in seperate variable for debugging
my $selectstatement; # .. same with building select statements :-)
my $numproc; # number of MOVE processes to be started
my $moveproc; # number of MOVE processes already started
my $rc_test; # test for return code of command
open LOGFILE, ">>" . $outputpath or die "$0 cannot open log file: " . $outputpath;
# check for empty drives
$selectstatement="SELECT COUNT(*) FROM drives WHERE DRIVE_STATE='EMPTY'";
$command = "$dsmadmc $dsmadsmargs -se=$libman \"$selectstatement\" 2>/dev/null";
@result = split '\n' , `$command`;
$emptydrives = $result[0];
if ( ( $emptydrives =~ m/^ANR/ ) or ($emptydrives =~ m/^ANS/) )
{
printf LOGFILE "%s: error on getting number of empty drives \n", $time;
die;
}
if ($emptydrives < 2 )
{
printf LOGFILE "%s: not enough drives empty.\n", $time;
die "not enough drives empty.";
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# check if emptying tapes is needed at all
# thanks to Maurice van't Loo for this idea :-)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# t.b.d :-|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$numproc = sprintf ("%2d", ($emptydrives/2.) );
$moveproc = 0;
@global_volumelist = undef;
foreach $server (@serverlist)
{
$selectstatement = "select volume_name, (est_capacity_mb * pct_utilized * 0.00001) from volumes ".
"where (DEVCLASS_NAME like '".$devc."' and (DAYS(current_date) - DAYS(LAST_WRITE_DATE))>$dayslimit and ( (est_capacity_mb * pct_utilized * 0.00001) < $sizelimit_GB ) " .
" and status<>'EMPTY' and access<>'UNAVAILABLE')";
$command = "$dsmadmc $dsmadsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@volumelist = split '\n' , `$command`;
VOLUME: foreach $thisvolume (@volumelist)
{
if ( ( $thisvolume =~ m/^ANR/ ) or ($thisvolume =~ m/^ANS/) )
{
last VOLUME;
}
else
{
($volume_name, $dataamount) = split ' ', $thisvolume;
my $entry = sprintf "%07.2f:%6s:%s", $dataamount, $server, $volume_name;
push (@global_volumelist, $entry);
}
}
}
# order all volumes by size
if ( ! @global_volumelist )
{
printf LOGFILE "%s: nothing to do! \n", $time;
close LOGFILE;
exit 0;
}
shift @global_volumelist;
# sort all entries by data amount
my @sorted_global_volumelist = sort @global_volumelist;
ALLVOLUMES: foreach $thisvolume (@sorted_global_volumelist)
{
($dataamount, $server, $volume_name) = split ":", $thisvolume;
$command = "$dsmadmc $dsmadsmargs -se=$server \"move data $volume_name\" 2>/dev/null";
@result = split '\n' , `$command`;
$rc_test = grep( /Return/, @result);
if ( $rc_test == 0 )
{
$moveproc= $moveproc + 1;
printf LOGFILE "%s: \@ %s: move data %s (%7.2f GB)\n", $time, $server, $volume_name, $dataamount;
}
if ($moveproc >= $numproc)
{
printf LOGFILE "%s: %d of %d MOVE processes already running\n", $time, $moveproc, $numproc;
last ALLVOLUMES;
}
} # EO for (@global_volumeslist)
close LOGFILE;
exit 0;
\ No newline at end of file
#! /usr/bin/perl
##############################################################################
#
# tsm-group-nodes.pl
#
# script for group former nongroup nodes
# to collocgroupr due to their policy domain
#
#
#
# (C) 2015,2019 GWD Göttingen, Bjørn Nachtwey
# mailto:bjoern.nachtwey@gwdg.de
#
##############################################################################
#
# changelog
# date version remark
# 2015-01-16 0.8 initial coding
# 2015-04-22 0.9 fixes for mon1.tsm.gwdg.de
# 2019-07-31 1.0 switched to common style with account and password given by call
#
##############################################################################
use warnings;
use strict;
use Time::Piece;
##############################################################################
##############################################################################
# F I L L I N Y O U R S E T T I N G S H E R E
##############################################################################
##############################################################################
##############################################################################
# C R E D E N T I A L S
##############################################################################
my $admuser = $ARGV[0]; # or replace by expicit ID
my $admpwd = $ARGV[1]; # or replace by expicit PW
##############################################################################
# # some loop iterators
my $server; # actual server name
my $server_name;
my $node_name;
my $domain_name;
# # some lists to be processed
my @serverlist = qw /tsm110 tsm112 tsm130 tsm131 tsm180 tsm182 tsm230 tsm231 tsm232 tsm233 tsm234 tsm235 tsm236 tsm237 tsm285/; # list of new servers
my @domainlist; # list of domains
my @nodelist; # list of all non-collocated nodes
my $dsmadmc = "/usr/bin/dsmadmc "; # linux servers
my $dsmargs = " -tab -dataonly=yes -id=$admuser -pa=$admpwd -outfile";
my $date = localtime->strftime ('%F');
my $outputpath = "/TSM/log/";
my $outlog = $outputpath . $date . "-grouped-nodes.log";
#
# # new variables
my $command;
my $selectstatement;
open LOGFILE, ">" . $outlog or die "$0: cannot open log file: " . $outlog;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# main loop over all servers
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach $server (@serverlist)
{
$server_name = $server;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get list of domains
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
undef @domainlist;
if ( $server =~ m/-admin$/ )
{
$server_name = $server;
$server_name =~ s/-admin$//;
}
else
{
$server_name = $server;
}
printf LOGFILE "\n ==>\t SERVER: $server_name\n\n";
printf LOGFILE " ====>\t COLLOCGROUPS \n\n";
$selectstatement = "select domain_name from domains minus (select collocgroup_name from collocgroup)";
$command = "$dsmadmc $dsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@domainlist = split '\n' , `$command`;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# define collocgroup for each domain without default-group
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
foreach my $domain (@domainlist)
{
next if ( $domain eq "TPL" );
next if ( $domain =~ m/^GWDG-FS/ );
printf LOGFILE "DEF COLLOCGR $domain\n";
$command = "$dsmadmc $dsmargs -se=$server \"DEF COLLOCGR $domain\" 2>/dev/null";
`$command`;
} # EO foreach domain
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# get all non-collocated nodes
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$selectstatement = "SELECT domain_name, node_name from nodes where (collocgroup_name IS NULL)";
$command = "$dsmadmc $dsmargs -se=$server \"$selectstatement\" 2>/dev/null";
@nodelist = split '\n' , `$command`;
printf LOGFILE "\n ====>\t NODES \n\n";
foreach my $node (@nodelist)
{
if ( ( $node =~ m/^ANR/ ) or ($node =~ m/^ANS/) )
{
last
}
($domain_name, $node_name) = split '\t' , $node;
next if ( $domain_name eq "TPL" );
next if ( $domain_name =~ m/^GWDG-FS/ );
printf LOGFILE "def collocmem $domain_name $node_name\n";
$command = "$dsmadmc $dsmargs -se=$server \"def collocmem $domain_name $node_name\" 2>/dev/null";
`$command`;
}
printf LOGFILE "======================================================================\n";
}
close LOGFILE;
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