DBIx-JCL
view release on metacpan or search on metacpan
lib/DBIx/JCL.pm view on Meta::CPAN
my ($message, $severity) = @_;
return 0 unless $mail_pagerto;
return 0 if $mail_pagerto =~ /NONE/i;
my ($subject, $job);
if ( $severity eq 'MESSAGE' ) {
$subject = 'Message from ' . uc $dataenvr;
} else {
my $subject = uc($dataenvr). ' Batch Notice';
$message = time2str("%Y/%m/%d %H:%M:%S : ", time) . uc($severity) . " : $script_file : $message";
}
MIME::Lite->send('smtp', $mail_server, Timeout => 60);
my $msg = MIME::Lite->new(
From => $mail_from,
To => $mail_pagerto,
Subject => $subject,
Data => $message
);
$msg->send;
return 0;
}
sub _log_rotate {
=begin wiki
!3 _log_rotate
Parameters: ( p1, p2, p3 )
Please write this documentation.
Returns:
=cut
my ($prev,$next,$i,$j);
my $curr = $log_filefull;
my $currn = $curr;
for ($i = $log_gdg; $i > 1; $i--) {
$j = $i - 1;
my $nextgen = sprintf("%0${log_radix}d", $i);
my $prevgen = sprintf("%0${log_radix}d", $j);
$next = "${currn}." . $nextgen; ##. $ext;
$prev = "${currn}." . $prevgen; ##. $ext;
if ( -r $prev && -f $prev ) {
move($prev,$next) or sys_die( "Log move failed: ($prev,$next)" );
}
}
## copy current to next incremental
my $nextgen = sprintf("%0${log_radix}d", 1);
$next = "${currn}." . $nextgen;
copy($curr, $next);
## preserve permissions and status
my @stat = stat $curr;
chmod( $stat[2], $next ) or sys_warn( "log chmod failed: ($next)" );
utime( $stat[8], $stat[9], $next ) or sys_warn( "log utime failed: ($next)" );
chown( $stat[4], $stat[5], $next ) or sys_warn( "log chown failed: ($next)" );
## now truncate the file
truncate $curr, 0 or sys_die( "Could not truncate $curr" );
return 0;
}
sub _db_connect_check_dependent {
=begin wiki
!3 _db_connect_check_dependent
Parameters: ( p1, p2, p3 )
Please write this documentation.
Returns:
=cut
my ($dependent_jobname,$wait_duration,$wait_max_secs,$wait_action) = @_;
my $starttime = time;
while ( 1 ) {
if ( _sys_job_dependent($dependent_jobname) ) {
sleep $wait_duration;
my $curtime = time;
if ( $curtime - $starttime > $wait_max_secs ) {
if ( $wait_action =~ m/^run$/ix ) {
log_info( "Maximum dependent job wait time exceeded, starting" );
last;
} else {
sys_die( "Maximum dependent job wait time exceeded, aborting" );
return 1; ## reachable if $sys_test_harness
}
}
} else {
last;
}
}
return 0;
}
sub _db_connect_retry {
=begin wiki
!3 _db_connect_retry
Parameters: ( p1, p2, p3 )
Please write this documentation.
Returns:
=cut
my ($db,$un,$pw,$retry_duration,$retry_max_secs) = @_;
my $dbh = 0;
my $starttime = time;
while ( 1 ) {
$dbh = DBI->connect( $db, $un, $pw, { RaiseError => 0, AutoCommit => 0 } );
lib/DBIx/JCL.pm view on Meta::CPAN
each.
* %$path_bin_dir # path to bin directory%
* %$path_lib_dir # path to lib directory%
* %$path_log_dir # path to log directory%
* %$path_load_dir # path to load directory%
* %$path_extr_dir # path to extract directo%ry
* %$path_prev_dir # path to store previous vrsion files%
* %$path_scripts_dir # path to scripts directory%
* %$mail_server # mail server address%
* %$mail_from # from email address%
* %$mail_emailto # email to address list%
* %$mail_pagerto # pager to address list%
* %$mail_email_levels # log levels which initiate email notifications%
* %$mail_pager_levels # log levels which initiate pager notifications%
* %$log_file # log file filename%
* %$log_filefull # full path to log filename%
* %$log_logging_levels # log levels which initiate log mesages%
* %$log_console_levels # log levels which initiate console messages%
* %$log_gdg # number of log archive files to maintain%
Default values for all of these are defined in system conf files. The value \
of many of these can be set at runtime using command line options.
A special global variable defines the current database environment. This is \
the $dataenvr variable.
----
!1 Source Code Validation
In order to help maintain consistency across an entire library of job \
scripts. Several aspects of script files are check for compliance before \
the job will be executed. The following rules are checked before a job \
will be run by DBIx-JCL
/Header Checks/
There must be valid %##@@% and %##$$% statements. These statements can be \
used to help manage script libraries. The %##$$% statement is also used by \
the display jobs option to provide a brief description of each job.
/Documentation Checks/
There needs to be valid Pod containing at least a DESCRIPTION section, a \
RECOVERY NOTES section, and a DEPENDENCIES section in each job script.
----
!1 File And Directory Permissions
This information is here to document one approach to file and directory \
permissions. You should not adopt these for your use without careful \
consideration and testing.
All files owned by the account which processes batch jobs should be set to \
permission level 750, which will give owner rwx, group r-x, and all others no \
access.
% language=Ini_Files
% >chmod 750 filename
%
% 7 - owner permissions (rwx) i.e., read & write & execute
% 5 - group permissions (r-x) i.e., read & execute
% 0 - world permissions (---) i.e., none
%%
All directories owned by the account which processes batch jobs should \
normally be set to permission level 750.
Permission reference table:
|0 |--- |no access|
|1 |--x |execute|
|2 |-w- |write|
|3 |-wx |write and execute|
|4 |r-- |read|
|5 |r-x |read and execute|
|6 |rw- |read and write|
|7 |rwx |read write execute (full access)|
----
!1 Plugins
DBIx-JCL supports plugin modules using a simple plugin architecture. This \
will allow you to write your own modules and have them loaded at runtime to \
provide additional functionality for your job scripts. For example, you might \
want to write a module that uses http to turn off your web site before some \
processing in your batch job occurs.
Plugin modules are simple Perl modules with no exported functions or \
variables. Here is a trivial example of a plugin module:
% language=Perl
% package TestPlugin1;
%
% use strict;
% use warnings;
%
% my $tp_num = 0;
%
% sub start {
% my ($path_conf_dir, $path_plugin_dir, $dataenvr) = @_;
% $tp_num = 100;
% print "TestPlugin1 start function\n";
% }
%
% sub plugin_main {
% my $n = shift;
% $tp_num += $n;
% return $tp_num;
% }
%
% sub tp_add {
% my $n = shift;
% $tp_num += $n;
% return $tp_num;
% }
%
% sub end {
( run in 0.829 second using v1.01-cache-2.11-cpan-5a3173703d6 )