You are on page 1of 5

Automation of Informatica workflow Scheduling

POSTED BY RAJ GUPTA AT 11:20 AM

1 COMMENTS

This will check status of all workflows/batches scheduled or running on an Infor


matica 7.1.2 Power Mart server( Unix). And a mail will be sent to user giving st
atistics of all workflows whether the are scheduled or running. The unscheduled
workflows will be automatically Scheduled. Limitations Project should have Infor
matica7.1.2 and whoose PM server is to be in Unix.
view plainprint?
#!/bin/ksh
set -x

# This script is to found out status of all workflows whether they are
# Scheduled or running or unscheduled. If they are unscheduled they will be auto
matically scheduled
# This Script works in a step by step manner
#1. Gather data from PMSERVER
#2. Compare the collected data with master data
#3. And extracting which workflows are scheduled/unscheduled/running
# Constraints :
# 1.User must be an Superuser to run PMCMD command in UNIX

# Variables Hardcoded:- Database, user/password and user to whom mail is to be s


ent( Separate multiple user by comma)
db="ORABIETA.WORLD"
up="biread/biread"
user="koushik.sinharoy@bp.com"
#PMServer information ( serv_name:port_no -u user -p password ) User must be Adm
inistrator of the server.
#PMserver for PROD
serv="tdcbdsd1:4003 -u infa -p infa"
#PM server for TEST
#serv="brcbdsd2:4001 -u Administrator -p admin"

#Temporary Variables used


mailfile="/tmp/mailfile"
owf="/tmp/owf"
wftime="/tmp/wftime"
wfdtime1="/tmp/wfdtime1"
psch="/tmp/psch"
unsch="/tmp/unsch"
disch="/tmp/disch"
tisch="/tmp/tisch"
running="/tmp/running"
sch="/tmp/sch"
run="/tmp/run"
spoollog="/tmp/spoollog.txt"
wfr="/tmp/wfr"

wfdtime="/tmp/wfdtime"
mwf="/infa/informatica/powercenter7/mwf.txt"
fwf="/infa/informatica/powercenter7/fwf.txt"
mwft="/infa/informatica/powercenter7/mwft.txt"
nsch="/tmp/nsch"

#Getting Server details in 2 diff file.


pmcmd getserverdetails -s $serv -scheduled > $sch
pmcmd getserverdetails -s $serv -running > $run

# Selecting only workflows and schedule time


grep "Workflow: " $sch | cut -d " " -f 2 > $owf
grep "Schedule time:" $sch | cut -d " " -f 4,5,6 > $wftime
#pastes two files side by side format- wf:dd:time
paste -d " " $owf $wftime > $wfdtime1
#Removing [ and ]
sed 's/[//g' $wfdtime1 | sed 's/]//g' >$wfdtime

#selecting running wfs and removing[ and ]


grep "Workflow: " $run | cut -d " " -f 2 | sed 's/[//g' | sed 's/]//g' | sort -u
> $wfr

# Getting sysdate+1 from SQL and accepting output to a file $spoollog


sqlplus -s "$up"@"$db" <<ENDSQL
whenever sqlerror exit 99
whenever oserror exit 72
set heading off
set newpage none
set pagesize 0
set feedback off
set tab off
set trim on
spool $spoollog
SELECT TO_CHAR(SYSDATE+1,'DY Mon DD HH24:MI:SS') FROM DUAL;
spool off
exit;
ENDSQL
# Error Handling
sqlerr=$?
if [ $sqlerr -eq 99 ]
then
print "[ $0, $$, $(date "+%m/%d/%Y %H:%M:%S") ]ERROR: Connectin
g to DB Failed"
fi

if [ $sqlerr -eq 72 ]
then
print "[ $0, $$, $(date "+%m/%d/%Y %H:%M:%S") ]ERROR: Connectin
g to DB Failed"
fi

# got Sysdate + 1 in a file kt.txt


# Cutting sysdate+1 format Mon DD
mdstr=`cut -d " " -f2,3 $spoollog`

#Formatting the outputs


dash="--------------------------------------------------------------------------------------------"
# Properly Scheduled $psch
echo "
"" Workflows: PROPERLY SCHEDULED for " "$mdstr" > $psch
echo "$dash" >> $psch
# Date is not Proper $disch
echo "
"" Workflows: Scheduled but NOT ON " "$mdstr" > $disch
echo "$dash" >> $disch
# Workflows scheduled in wrong time $tisch
echo "
""Workflows: Scheduled for" "$mdstr" " but in INCORRECT TIME " > $tisch
echo "$dash" >> $tisch
# Workflows that are running $running
echo "
"" Workflows: RUNNING" > $running
echo "$dash" >> $running
# Unscheduled workflows $unsch
echo "
"" Workflows: UNSCHEDULED Which are automatically scheduled( not on work)" > $u
nsch
echo "$dash" >> $unsch

# Main portion
# The Problem of GREP searching multiple match string is solved using a blank sp
ace after variable for Eg: "$wfvar "
for wf in `cat $mwf`
do
wfvar="$wf"
schwfdtime1=`grep "$wfvar " $wfdtime`
status=$?
schwfdtime=`echo "$schwfdtime1" | sed -n '1p'`
if [ "$status" -eq 0 ] ; then
dstr=`echo "$schwfdtime" | cut -d " " -f 2,3`
tstr=`echo "$schwfdtime" | cut -d " " -f 4`
mtstr=`grep "$wfvar " $mwft | sed -n '1p' | cut -d " " -f 2`
if [ "$mtstr" == "$tstr" ] ; then
if [ "$mdstr" == "$dstr" ] ; then
echo "$dstr" "$tstr" "$wfvar" >>$psch

else echo "$dstr" "$wfvar" >>$disch


fi
elif [ "$mdstr" == "$dstr" ]
then
echo "Originaltime:" "$mtstr" "Scheduled time:" "$tstr" "
$wfvar" >>$tisch
fi
else
wfrunning=`grep "$wfvar" $wfr`
if [ $? -eq 0 ] ; then
echo "$wfvar">>$running
else
echo "$wfvar">>$unsch
# To Schedule workflows that are unscheduled...
wffolder=`grep "$wfvar " $fwf | sed -n '1p' | cut -d " "
#pmcmd scheduleworkflow -s tdcbdsd1:4003 -u infa -p infa
folder" "$wfvar"
if [ $? -ne 0 ] ; then
echo "Error during scheduling Cannot Schedule " "$wfvar"
$mdstr" >>$unsch
else echo "Workflow" "$wfvar" "for" "$mdstr" "Properly
ed"
fi
fi
fi

done

# Extra workflow scheduled Detection


echo "
" " Workflows:Not in BIE Schedule " >$nsch
echo "$dash" >>$nsch
cut -d " " -f 1 $wfdtime >$wfdtime1
cat $wfr >>$wfdtime1
sed -n '4,$p' $unsch >>$wfdtime1
for wf in `cat $wfdtime1`
do
grep "$wf" $mwf
if [ $? -eq 0 ] ; then
continue
else
echo "$wf" >>$nsch
fi
done
# Concatenating Output and sending by mail
echo "
"" SCHEDULE FOR DAY " "$mdstr" > $mailfile
echo "$dash""
" "Data Collected on" `date` >>$mailfile
cat $unsch $psch $disch $running $tisch $nsch>>$mailfile
subj=`echo "Schedule for the day" "$mdstr"`
cat $mailfile | mailx -s "$subj" "$user"

-f 1`
-f "$wf
"for" "
schedul

# End of Prog

You might also like