Jobs Status Report

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

I am running the same code on my system.
its working fine here.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post 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 = "
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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!!
pandeeswaran
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post 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
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post 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
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

We don't have gnu date.so, i need to go with my own script.
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Seems like you need to sprinkle more 2>&1s in there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post 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
Last edited by pandeesh on Wed Aug 10, 2011 11:34 am, edited 2 times in total.
pandeeswaran
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Post 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?
Post Reply