0% found this document useful (0 votes)
152 views4 pages

Get Over Running DataStage Job Details

This script monitors DataStage jobs that have been running longer than their last runtime. It retrieves job details, calculates elapsed time, and compares it to a reference time. If a job's elapsed time exceeds the reference by more than 30 seconds, a report is generated and emailed to the mailing list. Temporary files created during the process are cleaned up at the end.

Uploaded by

DataStage4You
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views4 pages

Get Over Running DataStage Job Details

This script monitors DataStage jobs that have been running longer than their last runtime. It retrieves job details, calculates elapsed time, and compares it to a reference time. If a job's elapsed time exceeds the reference by more than 30 seconds, a report is generated and emailed to the mailing list. Temporary files created during the process are cleaned up at the end.

Uploaded by

DataStage4You
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

## Get Over Running DataStage Job Details

################################################################################
#####################
#
#
# Program Name : OverRunningJobs.sh
#
# Author : Atul Singh
#
# Purpose : This script will monitor the Jobs that are running for a time
duration that is #
# more than the last run time.
#
# Version : 1.0
#
# Date : 30th Nov 2015
# Blog : www.datagenx.net
#
#
#
#
#
################################################################################
#####################

. /etl/apps/DS/InformationServer/Server/DSEngine/dsenv
#### DO ARCHIVE ####
do_archive()
{
foldername="Archive"
if [ -e $foldername ] && [ -d $foldername ]
then
c=`find ./Attention -name "Attention_*"|wc -l`
let count=c
echo $count
if [ $count -gt 0 ]
then
`mv Attention/Attention_* Archive`
else
## No files to archive
fi
else
`mkdir Archive`
`mv Attention/Attention_* Archive`
fi
echo "\n** Previous Log Files have been sent to Archive **\n"
}

######### MAIN ############


echo "\n\n"
do_archive
filename="Projectinfo.txt"
if [ -e $filename ]
then
project=`cat Projectinfo.txt`
else
echo "**** Server Information file doesnot exist *****\n\n "
exit 1 ##exit shell script
fi

filemail="Mail_List.txt"
if [ -f $filemail ]
then
strmail=`cat Mail_List.txt|tr '\n' ' '`
else
echo "**** Mail_List file doesnot exist *****\n\n "
exit 1 ##exit shell script
fi

dsjob -ljobs $project>Joblist.txt


echo "\n\n No of jobs found :`cat Joblist.txt|wc -l` "
x=0
run[0]=" "
counter=0
while read myline
do
cat /dev/null>Jobinfo.txt
dsjob -jobinfo $project $myline>Jobinfo.txt
x=`cat Jobinfo.txt|head -1|cut -d " " -f3`
echo Status : $x
if [ $x = "RUNNING" ]
then
## GET THE START TIME OF THE JOB ##
st_time=`cat Jobinfo.txt|head -3|tail -1|tr -s " "|cut -d " " -f7`
echo $myline started at $st_time
let h1=`echo $st_time|cut -d ":" -f1`
let m1=`echo $st_time|cut -d ":" -f2`
let s1=`echo $st_time|cut -c 7,8`
hh=`expr $h1 \* 3600`
mm=`expr $m1 \* 60`
st_time_sec=`expr $hh + $mm`
st_time_sec=`expr $st_time_sec + $s1`
echo st_time_sec :$st_time_sec
## GET THE CURRENT SYSTIME ##
pr_time=`date|tr -s " "|cut -f4 -d " "`
echo "\n\nPresent time : $pr_time"
let h2=`echo $pr_time|cut -d ":" -f1`
let m2=`echo $pr_time|cut -d ":" -f2`
let s2=`echo $pr_time|cut -d ":" -f3`
hh=`expr $h2 \* 3600`
mm=`expr $m2 \* 60`
pr_time_sec=`expr $hh + $mm`
pr_time_sec=`expr $pr_time_sec + $s2`
echo pr_time_sec :$pr_time_sec
## CALCULATE THE CURRENT ELAPSED TIME ##
if [ $pr_time_sec>$st_time_sec ]
then
elapse_time_sec=`expr $pr_time_sec - $st_time_sec`
echo "\n\nelapse_time_sec : $elapse_time_sec"
fi
## Refer to the JobTimeRef*** File ##
filename="JobTimeRef.txt"
if [ -e $filename ]
then
ref_time_sec=`cat JobTimeRef.txt|grep $myline|cut -d "|" -f2`
echo "\n\nReference Time Is :$ref_time_sec"
echo ref_time_sec :$ref_time_sec
else
echo "\n\n $filename doesnot exist.Cannot proceed further.\n\n"
exit 1
fi
### BUFFER TIME ASSUMED TO BE 30 SECONDS ###
buffer_time_sec=`expr $elapse_time_sec + 30`
echo buffer_time_sec :$buffer_time_sec
if [ $buffer_time_sec -ge $ref_time_sec ]
then
echo "\n\n**Job $myline needs attention**\n\n"
## Chk the existence of the folder "Attention" ##
foldername="Attention"
if [ -e $foldername ] && [ -d $foldername ]
then
pwd=`pwd`
report_txt="Job $myline needs attention.Elapsed time(sec): $elap
se_time_sec has crossed the Reference Time(sec): $ref_time_sec."
echo $report_txt>$pwd/Attention/Attention_`date +%m_%d_%y_%H-%M-%S
`.txt
else
`mkdir Attention;mkdir Mail`
pwd=`pwd`
report_txt="Job $myline needs attention.Elapsed time(sec): $elap
se_time_sec has crossed the Reference Time(sec): $ref_time_sec."
echo $report_txt>$pwd/Attention/Attention_`date +%m_%d_%y_%H-%M-%S
`.txt
fi
else
echo "\n\n**Job $myline is ok**\n\n"
fi
fi ##RUNNING
done<Joblist.txt

### CONCATENATE ALL THE ATTENTION FILES TO A SINGLE MAIL FILE ###

c=`find ./Attention -name "Attention_*"|wc -l`


let count=c
echo $count
if [ $count -gt 0 ]
then
cat Attention/Attention_*>Sendmail.txt
if [ -e Mail ] && [ -d Mail ]
then
cat Sendmail.txt>Mail/Sendmail_`date +%m_%d_%y_%H-%M-%S`.txt
else
`mkdir Mail`
cat Sendmail.txt>Mail/Sendmail_`date +%m_%d_%y_%H-%M-%S`.txt
fi

###### MAILING #######


##mailx cat Sendmail.txt $strmail
else
### DNT SEND MAIL
fi

### REMOVING JOB INFO AND SENDMAIL FILE ###


find . -name "Jobinfo.txt"|xargs rm
find . -name "Sendmail.txt"|xargs rm
## REMOVING THE TEMPORARY ZERO BYTE FILES
find . -type f -size 0|xargs rm

You might also like