#!

/usr/bin/ksh ################################################################### # Author: Rajasekhar # Date: September, 2012 # Purpose: To check informatica errors automatically ################################################################## . $HOME/.profile SCRIPT_DIR=$HOME/scripts INFM_DIR=/sites/app/qatport/temp/INFM LOG_DIR=$INFM_DIR/logs TASK_ERR_LOG=$LOG_DIR/tasks_error.log TASK_ERR_LOG_UNIQ=$LOG_DIR/tasks_error_uniq.log TASK_ERR_LOG_UNIQ_PRIOR=$LOG_DIR/tasks_error_uniq_prior.log TASK_ERR_LOG_DLY=$LOG_DIR/tasks_error_dly.log CHECK_TASK_LOG=$LOG_DIR/check_infm_tasks.log CHECK_TASK_ERR=$LOG_DIR/check_infm_tasks.err EMAIL_NOTE=$LOG_DIR/error_email_message EMAIL="etlperson1@company.com etlperson2@company.com" TEAM_EMAIL="etlperson1@company.com etlpm@company.com" #PAGE="xxxxxxxxxx@abc.com" PRIOR_DATE=`date +%m%d%Y` PRIOR_TIME=`date +%H%M%S` PRIOR_DATETIME=$PRIOR_DATE-$PRIOR_TIME START_DATETIME=$PRIOR_DATETIME cat /dev/null > $TASK_ERR_LOG_UNIQ cat /dev/null > $CHECK_TASK_LOG check_infm_task() { while [ 1 -gt 0 ] do CURR_TIME=`date +%H%M%S` CURR_DATE=`date +%m%d%Y` CURR_DATETIME=`date +%m%d%Y-%H%M%S` echo "----------------------------------------------" echo "" echo "Current Time Stamp = $CURR_DATETIME" if [ $CURR_TIME -gt 050000 -a $CURR_DATE != $PRIOR_DATE ];then echo "==============================================" echo "Daily ETL Status Process Started At $CURR_DATETIME" echo "" if [ -s $TASK_ERR_LOG_UNIQ ]; then cat /dev/null > $TASK_ERR_LOG_DLY echo " ======================================================================= Folder_Name : Wkf_Name : Wklt_Name : Sess_Name : Sess_Start_Time ======================================================================= " >> $TASK_ERR_LOG_DLY cat $TASK_ERR_LOG_UNIQ |awk -F',' '{print $2","$4","$10","$16","$18}' |sort -u | awk F',' '{print $1" : "$2" : "$3" : "$4" : "$5 "\n"}' >>$TASK_ERR_LOG_DLY echo "Sent errored tasks info to ETL Team Thru Email" echo "" mailx -s "Informatica Errored Tasks From $PRIOR_DATETIME To $CURR_DATETIME" $TEAM_EMAIL < $TASK_ERR_LOG_DLY mv $TASK_ERR_LOG_UNIQ $TASK_ERR_LOG_UNIQ_PRIOR cat /dev/null > $TASK_ERR_LOG_UNIQ else mailx -s "All Informatica Tasks Were Succeessful From $PRIOR_DATETIME to $CURR_DATETIME" $TEAM_EMAIL < /dev/null

'{print $11}'` TASK_END=`echo $FILE |awk -F.sql $START_DATETIME $CURR_DATETIME >> $TASK_ERR_LOG START_DATETIME=`sqlplus -s rchepuru/start123 << EOF set heading off set feedback off select to_char(min(start_time). 'mmddyyyy-hh24miss') from infoadmin.#echo "Set Prior Date To Current Date To Stop Daily ETL Status Process" PRIOR_DATE=$CURR_DATE PRIOR_TIME=$CURR_TIME PRIOR_DATETIME=$CURR_DATETIME echo "Daily ETL Status Process Finished at $CURR_DATETIME" echo "==============================================" fi fi cat /dev/null > $TASK_ERR_LOG echo "finding errored tasks from $START_DATETIME thru $CURR_DATETIME" #FIND out errored tasks that are associated with wklt sqlplus -s rchepuru/start123 @$SCRIPT_DIR/fail_sess_wklt_involve. '{print $2}'` WORKFLOW_NAME=`echo $FILE |awk -F. '{print $16}'` SESS_START=`echo $FILE |awk -F. then #check whether the error is already recorded for FILE in `cat $TASK_ERR_LOG` do EXIST=`cat $TASK_ERR_LOG_UNIQ |grep "$FILE"` if [ -z $EXIST ]. '{print $10}'` TASK_START=`echo $FILE |awk -F. exit.then echo " Folder_Name = $FOLDER_NAME Workflow_Name = $WORKFLOW_NAME Session_Name = $SESS_NAME Session_Start_Time = $SESS_START Session_End_Time = $SESS_END .then if [ ! -z $SESS_NAME ].sql $START_DATETIME $CURR_DATETIME >> $TASK_ERR_LOG #FIND out errored tasks that are not wklt or session related sqlplus -s rchepuru/start123 @$SCRIPT_DIR/fail_tasks_other. '{print $12}'` SESS_NAME=`echo $FILE |awk -F. '{print $19}'` # Error sessions that are not associated with wklt" if [ -z $TASK_NAME ]. '{print $4}'` TASK_NAME=`echo $FILE |awk -F.rep_wflow_run@p0trpir_dblink where run_status_code = 6. '{print $18}'` SESS_END=`echo $FILE |awk -F. EOF` if [ -z $START_DATETIME ].then #echo "No tasks running at $CURR_DATETIME" #echo "Next run check for errrors from $CURR_DATETIME" START_DATETIME=$CURR_DATETIME fi COUNT=`cat $TASK_ERR_LOG |wc -l` if [ $COUNT -ne 0 ].then #check the error in previous day error file for any continuous process PRIOR_EXIST=`cat $TASK_ERR_LOG_UNIQ_PRIOR |grep "$FILE"` if [ -z $PRIOR_EXIST ].then echo $FILE >> $TASK_ERR_LOG_UNIQ FOLDER_NAME=`echo $FILE |awk -F.sql $START_DATETIME $CURR_DATETIME >> $TASK_ERR_LOG #FIND out errored tasks that are not associated with wklt sqlplus -s rchepuru/start123 @$SCRIPT_DIR/fail_sess_wklt_not_involve.

Errored at $SESS_END" > $EMAIL_NOTE mailx -s "$SESS_NAME errored at $SESS_END" $EMAIL < $EMAIL_NOTE mailx -s "$SESS_NAME errored at $SESS_END" $PAGE < $EMAIL_NOTE fi fi # Error session that is associated with wklt" if [ ! -z $TASK_NAME ].then echo " Folder_Name = $FOLDER_NAME Workflow_Name = $WORKFLOW_NAME Worklet_Name = $TASK_NAME Session_Name = $SESS_NAME Session_Start_Time = $SESS_START Session_End_Time = $SESS_END Errored at $SESS_END" > $EMAIL_NOTE mailx -s "$SESS_NAME errored at $SESS_END" $EMAIL < $EMAIL_NOTE mailx -s "$SESS_NAME errored at $SESS_END" $PAGE < $EMAIL_NOTE else # Error tasks with cmd. . eventwait etc" echo " Folder_Name = $FOLDER_NAME Workflow_Name = $WORKFLOW_NAME Task_Name = $TASK_NAME Task_Start_Time = $TASK_START Task_End_Time = $TASK_END Errored at $TASK_END" > $EMAIL_NOTE mailx -s "$TASK_NAME errored at $TASK_END" $EMAIL < $EMAIL_NOTE mailx -s "$TASK_NAME errored at $TASK_END" $PAGE < $EMAIL_NOTE fi fi else echo "No new errored tasks From $START_DATETIME thru $CURR_DATETIME" echo "" fi else echo "No new errored tasks From $START_DATETIME thru $CURR_DATETIME" echo "" fi echo "" done else echo "No errored tasks From $START_DATETIME thru $CURR_DATETIME" echo "" fi echo "Check for error tasks again after 30 mins" echo "" sleep 1800 done } check_infm_task 1>>$CHECK_TASK_LOG 2>>$CHECK_TASK_ERR exit.then if [ ! -z $SESS_NAME ].

'|| c. 2007 --Purpose: To find out error sessions that are associated with wklt /************************************************************/ set verify off define START_DATETIME=$1 define CURR_DATETIME=$2 set pagesize 0 set echo off set heading off set feedback off set linesize 500 select a. 'Unknown') ||'. 'Succeed'.task_id ||'.worklet_run_id and c. 1.child_run_id <> 0 and b. 2.2) ||'.subject_id ||'.b.'|| to_char(a.workflow_id and a.'|| c. 'Disabled'.start_time >= to_date('&1'.'Aborted'.end_time. 'Succeed'.'|| c.end_time .workflow_id = b.run_status_code.'|| decode(a. 'Stopped'. 'mmddyyyy-hh24:mi:ss') ||'.3. 1. 'mmddyyyy-hh24:mi:ss') ||'.5.task_type_name = 'Worklet' and b.session_timestamp.workflow_name ||'.workflow_id ||'.'|| to_char(b. 4.'Unknown') from rep_wflow_run a.actual_start.5.workflow_run_id and a.session_id ||'.'|| a. 'Disabled'.workflow_id and a.end_time .actual_start) *24*60. 'mmddyyyy-hh24:mi:ss') ||'.'|| decode(c. 'Failed'.'|| to_char(c.start_time. 4. .3. 'mmddyyyy-hh24:mi:ss') ||'.workflow_id = c.'|| round((a.workflow_run_id and a.child_run_id = c.'Aborted'.start_time < to_date('&2'.'Aborted'. rep_sess_log c where a.workflow_run_id = c.task_name ||'.start_time) *24*60.session_name ||'. 'Stopped'.3.'|| c.Sql script details: fail_sess_wklt_involve. 4.'|| to_char(a.run_status_code <> 1 and c.run_status_code.'|| a.5.'mmddyyyy-hh24miss') and a. 'Stopped'. 2.2) ||'. 2. rep_task_inst_run b.end_time. 'mmddyyyy-hh24:mi:ss') ||'.a. 'Failed'.'|| b.'|| b.sql : /************************************************************/ --Author: Ramadevi. 'Disabled'.'|| a.subject_area ||'. 'mmddyyyy-hh24:mi:ss') ||'.workflow_run_id = b.'mmddyyyy-hh24miss') and b.successful_source_rows ||'.'|| decode(b.session_timestamp . 'Failed'.worklet_run_id = 0 and b.run_status_code <> 6.2) ||'.start_time.Chepuru --Date: Aug .'|| round((c.start_time) *24*60.'|| to_char(c. 'Unknown') ||'.c.run_status_code.'|| to_char(b.mapping_name ||'.'|| round((b. exit.

.'|| to_char(a.mapping_name ||'.subject_id ||'.'|| round((c.session_name ||'. 2007 --Purpose: To find our error taks other than sessions /************************************************************/ set verify off define START_DATETIME = $1 define CURR_DATETIME = $2 set pagesize 0 set echo off set heading off set feedback off set linesize 500 select a.start_time >= to_date('&1'.'|| c.start_time < to_date('&2'.2) ||'. 4.'|| to_char(c.session_timestamp.'mmddyyyy-hh24miss') and a.end_time .3.start_time) *24*60.end_time. exit. 'Disabled'.c.run_status_code <>6.a.'|| round((a.5.session_id ||'. 'Succeed'. 'Unknown') from rep_wflow_run a.'|| decode(c.workflow_id and a.session_timestamp .Chepuru --Date: Aug .Chepuru --Date: Aug .'|| ..start_time.5.'|| a.'mmddyyyy-hh24miss') and c.subject_area ||'. 'mmddyyyy-hh24:mi:ss') ||'..run_status_code.'|| c.'|| a.run_status_code.run_status_code <> 1 and c. 'Failed'. 2.'|| c.'Aborted'. 'Failed'.'|| a. 'mmddyyyy-hh24:mi:ss') ||'.workflow_id = c.workflow_id ||'.workflow_run_id and a.worklet_run_id = 0 and c.actual_start. 'Stopped'.'|| to_char(a.'|| to_char(c. 4.'|| c. 'mmddyyyy-hh24:mi:ss') ||'.workflow_name ||'. 'Unknown') ||'.2) ||'.'|| decode(a.successful_source_rows ||'.fail_sess_wklt_not_involve.'Aborted'.. 'Disabled'. 2007 --Purpose: To find out error sessions that are not associated with wklt /************************************************************/ SET VERIFY OFF define START_DATETIME=$1 define CURR_DATETIME=$2 set pagesize 0 set echo off set heading off set feedback off set linesize 500 select a.subject_id ||'..3.subject_area ||'.actual_start) *24*60.sql /************************************************************/ --Author: Ramadevi. rep_sess_log c where a. 'Stopped'.sql /************************************************************/ --Author: Ramadevi. fail_tasks_other. 'mmddyyyy-hh24:mi:ss') ||'.workflow_run_id = c.. 1.'|| a. 2.

. 2.'Aborted'.'|| round((a.'mmddyyyy-hh24miss') and b.workflow_id ||'.start_time) *24*60.workflow_run_id and a.' from rep_wflow_run a.'|| to_char(a.start_time < to_date('&2'. 'Failed'. 'Unknown') ||'. 4.workflow_id = b.run_status_code <> 6.'|| to_char(b.2) ||'.start_time >= to_date('&1'.start_time.'|| to_char(a.'|| decode(a.workflow_run_id = b.'|| decode(b.. 'Stopped'.workflow_name ||'.end_time.5. 'Disabled'.'mmddyyyy-hh24miss') and a. 'Failed'. 'Start') and b. .workflow_id and a.run_status_code <> 1 and b.task_id ||'.a.'Aborted'. 'Succeed'. 'mmddyyyy-hh24:mi:ss') ||'... 'mmddyyyy-hh24:mi:ss') ||'.start_time) *24*60. 'Stopped'.b.run_status_code.a.3.end_time .start_time.'|| round((b.2) ||'. 'Unknown') ||'. 2.'|| b.'|| to_char(b.5. 1.end_time .. 'Session'..end_time..3. 'mmddyyyy-hh24:mi:ss') ||'.task_name ||'..'|| a.task_type_name not in ('Worklet'. rep_task_inst_run b where a. 'Disabled'. exit. 'mmddyyyy-hh24:mi:ss') ||'.'|| b. 4.run_status_code.