Page 2 of 3
Posted: Mon Aug 08, 2011 1:13 am
by pandeesh
The problem is with the search string (since the search string contains spaces).
But with a single search string in grep (like "OK" or "FAILED" ) it's working fine.
So i have decided to go with search string as "FAILED".
So i have modified the code as:
Code: Select all
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%m.%d.%H.%M.txt")
touch $sfile
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user unam -password pwd -ljobs PRJDEV`
do
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname-user unam -password pwd -jobinfo $job_name PRJDEV | grep FAILED>/dev/null
if [ $? -eq 0 ]
then
echo $job_name >> /path/$sfile
fi
done
But while running the script, it shows Status code=0 for each execution of the job in screen .But i want to suppress it.Any idea about this?
Thanks
Posted: Mon Aug 08, 2011 1:27 am
by samyamkrishna
I am running the same code on my system.
its working fine here.
Posted: Mon Aug 08, 2011 1:40 am
by pandeesh
While running the script, for each execution of -jobinfo for each job, i am getting status code in the screen.Any idea to suppress it?
Code: Select all
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = -1004
Thanks
Posted: Mon Aug 08, 2011 1:55 am
by samyamkrishna
you can suppress it
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname-user unam -password pwd -jobinfo $job_name PRJDEV | grep FAILED>/dev/null | grep -v "Status code = "
Posted: Mon Aug 08, 2011 2:01 am
by pandeesh
samyamkrishna wrote:you can suppress it
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname-user unam -password pwd -jobinfo $job_name PRJDEV | grep FAILED>/dev/null | grep -v "Status code = "
No! That's not working. Still i am getting the status codes in the screen.
There might be some other way!!
Posted: Mon Aug 08, 2011 4:57 am
by ray.wurlod
Hint: Investigate a bit more what information goes to stdout (file unit #1) and what information goes to stderr (file unit #2) from the dsjob command.
Posted: Mon Aug 08, 2011 6:56 am
by pandeesh
Thanks Ray!
The below modified code suppressed that:
Code: Select all
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname -user uname -password pwd -jobinfo PRJDEV $job_name 2>&1 | grep FAILED >/dev/null 2>&1
Now the real issue is finding whether the last run time falls on yesterday.
For example, if the first three parts of date function in unix is :
Mon Aug 08 , we need to check the Last Run time contains the string Sun Aug 07.
Any idea about this?
Thanks
Posted: Mon Aug 08, 2011 9:12 am
by fmou
Start from this:
Code: Select all
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%m.%d.%H.%M.txt")
touch $sfile
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user unam -password pwd -ljobs PRJDEV`
do
if `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname-user unam -password pwd -jobinfo $job_name PRJDEV | grep "Job Status *: RUN FAILED" `; then
echo $job_name >> /path/$sfile
fi
done
HTH
Posted: Mon Aug 08, 2011 9:29 am
by fmou
Now the real issue is finding whether the last run time falls on yesterday.
For example, if the first three parts of date function in unix is :
Mon Aug 08 , we need to check the Last Run time contains the string Sun Aug 07.
If you don't have gnu date, search for a tool named mktime.
If you have gnu date, that's easy.
Code: Select all
$ date
Mon Aug 8 11:26:41 EDT 2011
$ date --date="-1 day" | cut -c1-11
Sun Aug 7
HTH
Posted: Mon Aug 08, 2011 9:37 am
by pandeesh
We don't have gnu date.so, i need to go with my own script.
Posted: Tue Aug 09, 2011 4:07 am
by pandeesh
is there any way to find the job_name in the output of -ljobs is a job sequence or normal job?
In general -ljobs list out both sequences and jobs.
How we can identify those?
Thanks
Posted: Tue Aug 09, 2011 8:19 am
by pandeesh
Hi All,
I have changed the requirement little bit.
Previously i have developed the script only for specific project.
Now i have decided to extend it to server level.
i have decided to drop the option of searching last run time for yesterday.
The modified script is:
Code: Select all
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%h.%d.%Y.%H.%M")
touch $sfile
to_list="abc@xyz.com"
for prj_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname -user unam -password pwd -lprojects`
do
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname -user unam -password pwd -ljobs $prj_name`
do
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname -user unam -password pwd -jobinfo $prj_name $job_name 2>&1 | grep FAILED >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo $job_name -- $prj_name>> /path/$sfile
fi
done
done
if [ -s $sfile ]
then
count=`cat $sfile|wc -l|sed -e 's/^[ \t]*//'`
echo "There are $count abends in DEV.Please take care " > body.txt
sed 's/$'"/`echo \\\r`/" $sfile > $sfile.txt
(cat body.txt;uuencode $sfile.txt $sfile.txt) | mailx -s "Alert" $to_list
rm $sfile
fi
Still i am getting the below messages while running the job:
Code: Select all
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Can any one help me in this?
thanks
Posted: Tue Aug 09, 2011 9:29 am
by chulett
Seems like you need to sprinkle more 2>&1s in there.
Posted: Wed Aug 10, 2011 4:03 am
by pandeesh
I have modified the script as generic forserver level.
I have named the script as
who_got_failedv1.0.ksh and posting here.
Let me know your comments and feedbacks:
Code: Select all
#who_got_failedv1.0.ksh
#-------------------------------------------------------------------------------------------------
#Useful to find out the jobs in aborted state in a particular project
#If we fail to address any of the job failure, then this script will alert us with the job name
#This is much useful in the environment in which more abends are occuring everyday
#Version 1.0:
#-----------------------------------------------------------------------------------------------------
#this version is extended to server level rather than project level.
# This script will looks for all the projects available in a server and finds out the aborted one.
#------------------------------------------------------------------------------------------------
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%h.%d.%Y.%H.%M")
touch $sfile
to_list="abc@xyz.com"
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects >> prj
for prj_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects`
do
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -ljobs $prj_name`
do
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -jobinfo $prj_name $job_name 2>&1 | grep FAILED >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo $prj_name - $job_name >> /path/$sfile
fi
done
done
if [ -s $sfile ]
then
j=`cat prj|wc -l|sed -e 's/^[ \t]*//'`
i=1
while [ $i -le $j ]
do
i=`expr $i + 1`
pr=`sed -n "${i}p" prj|sed -e 's/^[ \t]*//'`
k=`cat $sfile| grep $pr |wc -l|sed -e 's/^[ \t]*//'`
echo "there are $k abends in $pr" >> body.txt
done
sed 's/$'"/`echo \\\r`/" $sfile > $sfile.txt
(cat body.txt;uuencode $sfile.txt $sfile.txt) | mailx -s "Alert:there are some Abends" $to_list
rm $sfile
rm prj
rm body.txt
fi
Posted: Wed Aug 10, 2011 9:34 am
by fmou
Thanks for sharing.
> /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects >> prj
Maybe just '>' instead of '>>'?
> for prj_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects`
Maybe just a `cat prj` to speed up a bit?