#!/bin/ksh
###################################################################################
#
#
# Script Name: Get_DS_Job_Log.sh
#
# Process Name : Get Datastage Job Log
#
#
# Description : To get datastge log for a failed process
#
#
# Parameters :
# 1. Project
# 2. Job Name
# 3. Work Dir
#
# Change Log
######################################################################################
#exit 0
#set -x
#Host Server specifications
# Check input parameters
if [ $# -ne 3 ]
then
echo "Usage : $0 <WORK.DIR> <JOB.NAME> <PROJ.NAME>"
exit 1
fi
WorkDir=${1}
PROJ=${3}
JOBNAME=${2}
. $WorkDir/Cntrl_Files/common_parms.prm
. $WorkDir/Cntrl_Files/COMM_SendMail_List_Ref.dat
RunTS=`date +%Y%m%d%H%M%S`
JobOldLog=$WorkDir/Logs/${JOBNAME}_OldLog
JobNewLog=$WorkDir/Logs/${JOBNAME}_NewLog
JobReport=$WorkDir/Logs/${JOBNAME}_Rpt_${RunTS}.log
JobReportFile=${JOBNAME}_Rpt_${RunTS}.log
ServerName=$(uname -a|awk 'NR==1 {print $2}')
echo "Server Name:$ServerName Project Name:$PROJ Job Name:$JOBNAME" >> $JobReport
${DSPath}/dsjob -report $PROJ $JOBNAME DETAIL >> $JobReport
printf " \n****************************************************\n " >> $JobReport
printf " *** LOG DETAILS ***\n " >> $JobReport
${DSPath}/dsjob -lognewest $PROJ $JOBNAME STARTED > ${JobNewLog}
newid=$(awk '{print $4}' ${JobNewLog})
${DSPath}/dsjob -logsum -type STARTED -max 2 $PROJ $JOBNAME > ${JobOldLog}
oldid=$(awk 'NR==1 {print $1}' ${JobOldLog})
while [[ $oldid -le $newid ]];
do
${DSPath}/dsjob -logdetail $PROJ $JOBNAME $oldid >> $JobReport
printf " -----------------------------------------------------------------------\n " >> $JobReport
oldid=`expr $oldid + 1`;
done
cd $WorkDir/Logs
dos2unix $JobReportFile
#Commented out the Email Functionality
cat $JobReport|mailx -r ${DI_FROM_MAIL} -s "${ServerName}:${PROJ} DS Log for Job- $JOBNAME " ${DI_Tech_List}
exit 0
No comments:
Post a Comment