Gitlab Community Edition Instance

Commit b6449c45 authored by bnachtw's avatar bnachtw
Browse files

6.6.{7,8} add switch / option to disable check for pid file / encapsulate...

6.6.{7,8} add switch / option to disable check for pid file / encapsulate escaping of special characters for non-windows systems
parent c9f9ec70
......@@ -59,6 +59,10 @@
# 2019-12-10 0.6.6.1 add the number of threads to top of ".all.log" file
# 2019-12-10 0.6.6.2 add missing recording of severe errors to logfile -- patch by Salvatore
# 2020-02-04 0.6.7 switch path of pid-file from frist startpath to path of dsmci run
# 2020-02-04 0.6.7.1 add switch / option to disable check for pid file (so called sched mode, where the scheduler itself prevents multiple runs)
# 2020-02-04 0.6.7.2 typos removed
# 2020-02-05 0.6.7.3 starting to implement debug mode switch, giving some extra output on run
# 2020-02-06 0.6.8 encapsulate escaping of special characters for non-windows systems
#
# important notes
#
......@@ -66,6 +70,7 @@
#
##############################################################################
my $debugmode = 0; # 1 equals TRUE, enabels some printf debugging and prevents removing logfiles
##############################################################################
##############################################################################
# global settings / global variables
......@@ -93,7 +98,7 @@ elsif (( $osname eq 'MSWin32' ) or ( $osname eq 'msys' ) )
$optfile = 'C:\Program Files\Tivoli\TSM\baclient\dsm.opt';# default path to optfile
}
else
{ die " Operation System \"$osname\" is not supportet :-(" }
{ die " Operation System \"$osname\" is not supported :-(" }
use constant FALSE => 0;
use constant TRUE => 1;
......@@ -168,6 +173,9 @@ my $maxthreads = 4; # max number of threads running parallel
my $threads; # number of threads running
my $threadfail = 0; # counter of threads unable to be started
my $pidmode = undef; # reading the pid check from config file
my $pidcheck = TRUE; # setting the mode for checking for a pid file, default is check;
my $os; # switch for "Linux" vs "MSWin"
my $command; # for system calls
my $childreturnvalue; # return value from child process
......@@ -259,6 +267,13 @@ if ( defined $CFGFILE )
$maxdepth =~ s/^\s+|\s+$//g;
$depth = ($maxdepth - 1);
}
elsif ( $line2 =~ /^MODE/ )
{
(undef, $pidmode) = split '=', $line2;
$pidmode =~ s/^\s+|\s+$//g;
if ( $pidmode =~ /SCHED/ or $pidmode =~ /sched/)
{ $pidcheck = FALSE; }
}
elsif ( $line2 =~ /^STARTPATH/ )
{
(undef, $startpath) = split '=', $line2;
......@@ -302,18 +317,21 @@ $log_filename = $$ . "log";
$err_filename = $$ . "err";
$globallog_filename = $$ . ".all.log";
## check for running processes like this
if ( -e $pidfile )
{
warn "Found PID file ($pidfile) ! script stopped!";
exit RETURNPIDFOUND;
}
else
if ( $pidcheck == TRUE )
{
open $PPIDFILE , '>' , $pidfile
or die "cannot open PIDFILE ". $pidfile;
printf $PPIDFILE "%d", $ppid;
close $PPIDFILE;
## check for running processes like this
if ( -e $pidfile )
{
warn "Found PID file ($pidfile) ! script stopped!";
exit RETURNPIDFOUND;
}
else
{
open $PPIDFILE , '>' , $pidfile
or die "cannot open PIDFILE ". $pidfile;
printf $PPIDFILE "%d", $ppid;
close $PPIDFILE;
}
}
# get from localtime()
......@@ -573,7 +591,7 @@ if ( $datatransfertime < 0.1 or $proctime < 0.1 )
{ $dttratio = 0.0; }
else
{
$dttratio = $datatransfertime / $proctime * 100.;
$dttratio = $datatransfertime / $proctime * 100.;
}
$proctime = convert_time($proctime);
$statfilename = File::Spec->canonpath($date."-stats.txt");
......@@ -614,9 +632,15 @@ close $STATFILE;
# clean up and exit
#
unlink $pidfile; # remove PID file
unlink $globallog_filename;
remove_log_files();
if ( $pidcheck == TRUE )
{
unlink $pidfile; # remove PID file
}
if ( $debugmode != TRUE )
{
unlink $globallog_filename;
remove_log_files();
}
if ( $sevecount gt 1 or $errorcount gt 1 )
{ exit RETURNERROR; }
......@@ -770,14 +794,19 @@ sub fork_backup_threads
$dir = File::Spec->canonpath("$actpath/#");
# cut off trailing "#", needed to preserver trailing "/" :-|
$dir =~ s{\#$}{};
# escape "$" if part of the name
$dir =~ s{\$}{\\\$}g;
# escape special [ and ] in paths
$dir =~ s{([\[\]])}{\\$1}g;
# escape special characters if not running on windows
if (! ( $osname eq 'MSWin32' ) or ( $osname eq 'msys' ) )
{
# escape "$" if part of the name
$dir =~ s{\$}{\\\$}g;
# escape special [ and ] in paths
$dir =~ s{([\[\]])}{\\$1}g;
}
# backup commandline
$command = "\"$dsmcbin\" i \"$dir\" -optfile=\"$optfile\" -su=$switcher >> $log_filename 2>&1";
#printf "%s\n", $command;
if ( $debugmode == TRUE )
{ printf "%s\n", $command; }
# record commandline in childlogfile
open $CHILDLOGFILE, ">", $log_filename;
printf $CHILDLOGFILE "CMD: >>%s<<\n\n", $command;
......
......@@ -8,6 +8,7 @@
# OPTIONFILE=<Path and Name> # .. of dsm.opt file (or however it is called)
DEPTH = 1
MAXTHREADS = 2 * in this example just 3 threads
MODE = SCHED
OPTFILE = linux-dsm.opt
STARTPATH = /space/test
......@@ -59,6 +59,10 @@
# 2019-12-10 0.6.6.1 add the number of threads to top of ".all.log" file
# 2019-12-10 0.6.6.2 add missing recording of severe errors to logfile -- patch by Salvatore
# 2020-02-04 0.6.7 switch path of pid-file from frist startpath to path of dsmci run
# 2020-02-04 0.6.7.1 add switch / option to disable check for pid file (so called sched mode, where the scheduler itself prevents multiple runs)
# 2020-02-04 0.6.7.2 typos removed
# 2020-02-05 0.6.7.3 starting to implement debug mode switch, giving some extra output on run
# 2020-02-06 0.6.8 encapsulate escaping of special characters for non-windows systems
#
# important notes
#
......@@ -66,6 +70,7 @@
#
##############################################################################
my $debugmode = 0; # 1 equals TRUE, enabels some printf debugging and prevents removing logfiles
##############################################################################
##############################################################################
# global settings / global variables
......@@ -93,7 +98,7 @@ elsif (( $osname eq 'MSWin32' ) or ( $osname eq 'msys' ) )
$optfile = 'C:\Program Files\Tivoli\TSM\baclient\dsm.opt';# default path to optfile
}
else
{ die " Operation System \"$osname\" is not supportet :-(" }
{ die " Operation System \"$osname\" is not supported :-(" }
use constant FALSE => 0;
use constant TRUE => 1;
......@@ -168,6 +173,9 @@ my $maxthreads = 4; # max number of threads running parallel
my $threads; # number of threads running
my $threadfail = 0; # counter of threads unable to be started
my $pidmode = undef; # reading the pid check from config file
my $pidcheck = TRUE; # setting the mode for checking for a pid file, default is check;
my $os; # switch for "Linux" vs "MSWin"
my $command; # for system calls
my $childreturnvalue; # return value from child process
......@@ -259,6 +267,13 @@ if ( defined $CFGFILE )
$maxdepth =~ s/^\s+|\s+$//g;
$depth = ($maxdepth - 1);
}
elsif ( $line2 =~ /^MODE/ )
{
(undef, $pidmode) = split '=', $line2;
$pidmode =~ s/^\s+|\s+$//g;
if ( $pidmode =~ /SCHED/ or $pidmode =~ /sched/)
{ $pidcheck = FALSE; }
}
elsif ( $line2 =~ /^STARTPATH/ )
{
(undef, $startpath) = split '=', $line2;
......@@ -302,18 +317,21 @@ $log_filename = $$ . "log";
$err_filename = $$ . "err";
$globallog_filename = $$ . ".all.log";
## check for running processes like this
if ( -e $pidfile )
{
warn "Found PID file ($pidfile) ! script stopped!";
exit RETURNPIDFOUND;
}
else
if ( $pidcheck == TRUE )
{
open $PPIDFILE , '>' , $pidfile
or die "cannot open PIDFILE ". $pidfile;
printf $PPIDFILE "%d", $ppid;
close $PPIDFILE;
## check for running processes like this
if ( -e $pidfile )
{
warn "Found PID file ($pidfile) ! script stopped!";
exit RETURNPIDFOUND;
}
else
{
open $PPIDFILE , '>' , $pidfile
or die "cannot open PIDFILE ". $pidfile;
printf $PPIDFILE "%d", $ppid;
close $PPIDFILE;
}
}
# get from localtime()
......@@ -573,7 +591,7 @@ if ( $datatransfertime < 0.1 or $proctime < 0.1 )
{ $dttratio = 0.0; }
else
{
$dttratio = $datatransfertime / $proctime * 100.;
$dttratio = $datatransfertime / $proctime * 100.;
}
$proctime = convert_time($proctime);
$statfilename = File::Spec->canonpath($date."-stats.txt");
......@@ -614,9 +632,15 @@ close $STATFILE;
# clean up and exit
#
unlink $pidfile; # remove PID file
unlink $globallog_filename;
remove_log_files();
if ( $pidcheck == TRUE )
{
unlink $pidfile; # remove PID file
}
if ( $debugmode != TRUE )
{
unlink $globallog_filename;
remove_log_files();
}
if ( $sevecount gt 1 or $errorcount gt 1 )
{ exit RETURNERROR; }
......@@ -770,14 +794,19 @@ sub fork_backup_threads
$dir = File::Spec->canonpath("$actpath/#");
# cut off trailing "#", needed to preserver trailing "/" :-|
$dir =~ s{\#$}{};
# escape "$" if part of the name
$dir =~ s{\$}{\\\$}g;
# escape special [ and ] in paths
$dir =~ s{([\[\]])}{\\$1}g;
# escape special characters if not running on windows
if (! ( $osname eq 'MSWin32' ) or ( $osname eq 'msys' ) )
{
# escape "$" if part of the name
$dir =~ s{\$}{\\\$}g;
# escape special [ and ] in paths
$dir =~ s{([\[\]])}{\\$1}g;
}
# backup commandline
$command = "\"$dsmcbin\" i \"$dir\" -optfile=\"$optfile\" -su=$switcher >> $log_filename 2>&1";
#printf "%s\n", $command;
if ( $debugmode == TRUE )
{ printf "%s\n", $command; }
# record commandline in childlogfile
open $CHILDLOGFILE, ">", $log_filename;
printf $CHILDLOGFILE "CMD: >>%s<<\n\n", $command;
......
......@@ -8,6 +8,7 @@
# OPTIONFILE=<Path and Name> # .. of dsm.opt file (or however it is called)
MAXTHREADS = 2 * in this example just 3 threads
STARTPATH = /home/
MODE = SCHED
OPTFILE = /opt/tivoli/tsm/client/ba/bin/test.opt
STARTPATH = /mnt/shares/
STARTPATH = /mnt/exports/
......
......@@ -7,6 +7,7 @@
# MAXTHREADS=<Number> # maximum number of parallel threads to be used
# OPTIONFILE=<Path and Name> # .. of dsm.opt file (or however it is called)
MAXTHREADS = 1 * in this example just 3 threads
MODE = SCHED
OPTFILE = "C:\Program Files\Tivoli\TSM\baclient\test.opt"
STARTPATH = D:\
STARTPATH = "C:\users\Test user"
......
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