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

Jobs Status Report

Post by pandeesh »

Hi,

I would like to generate a report daily in such a way that, it should contain

the below details:

Job name, Current status (Aborted or finished ), Last runtime.

It should contains only the jobs which ran in yesterday.

How to generate that report?

Please let me know, if anyone already implemented this!!

Thanks
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Well... one of the standard answers you're going to get would be to download ETLStats from Kim Duke's website and tweak it to do whatever you like. I'll let you search the forum for information on that, if you like.

If that's literally all you need, seems to me you could script that using dsjob with the -jobinfo option. Use dsjob to get a list of jobs (or higher level a list of projects) and then iterate thru the list of projects / jobs and check each one by one. If it ran "yesterday" capture the status and runtime.
-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 »

Thanks! I want to go with the second way..I wish to start with my own Unix script...may I know how we can get the list of all jobs in a project In Unix level..I used to get this by select * from ds_jobs in ds administrator.
Thanks
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Everything can be accomplished using dsjob.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you enter the command dsjob with no arguments, it will display a list of available options at that level. You would discern from that, for example, that the option of a list of projects is -lprojects.

If you enter the command dsjob with a major argument, such as -run, but no other arguments, you will get a usage syntax for that option.

Over to you to conduct the research. An alternative is to read through the many pages on dsjob in the manual.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yup, in other words it supports normal 'usage' information. I purposely left any specifics out in an effort to coerce our dear Pandeesh into doing his own research, even on the '-lprojects' part. :wink:
-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 »

Thanks Craig!!

I have started working on the script:

Code: Select all


. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv 

touch status.`date +%m`.`date +%d`.txt

for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user uname -password pwd -ljobs prjname `

/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user uname -password pwd -jobinfo $job_name | grep "Job Status : RUN FAILED (3)"

if [ $? -eq 0 ]
do echo $job_name >> /home/status.`date +%m`.`date +%d`.txt
done
fi
done
The logic i have tried is :

1)Listing out all the jobs in a project using -ljobs

2)While executing -jobinfo for each job if the string "Job Status : RUN FAILED (3)",that job name should be written to the status file.

But i am facing the error on 4th line (executing -jobinfo for each job)

Still i am working on this..
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Hi,

I have little bit modified the script:

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 "Job Status      : RUN FAILED (3)"

if [ $? -eq 0 ]
then 
echo  $job_name >> /path/$sfile
fi
done
But still i am getting failed to open project -1002 error.
Can anyone help me on this?

Thanks
Last edited by pandeesh on Sun Aug 07, 2011 11:49 pm, edited 1 time in total.
pandeeswaran
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

The error failed to open project arose because of incorrect syntax in -jobinfo option:

Code: Select all

do
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname -user unam -password pwd -jobinfo PRJDEV $job_name  | grep "Job Status      : RUN FAILED (3)"
The above code eliminates that error.
Last edited by pandeesh on Sun Aug 07, 2011 11:49 pm, edited 1 time in total.
pandeeswaran
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Good... keep on going! :D
-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 am struggling to get the aborted jobs alone

For example i have a job called 'job123' which has been finished fine .

So while executing the below code:

Code: Select all

dsjob -serverservname-user uname -password pwd -jobinfo Prjname job123
it gives:

Code: Select all

Job Status      : RUN OK (1)
Job Controller  : not available
Job Start Time  : Mon Feb 21 00:04:09 2011
Job Wave Number : 1
User Status     : not available
Job Control     : 0
Interim Status  : NOT RUNNING (99)
Invocation ID   : not available
Last Run Time   : Mon Feb 21 00:04:11 2011
Job Process ID  : 0
Invocation List : job123

Status code = 0
So, while executing the below code:

Code: Select all

dsjob -server servname -user uname -password pwd -jobinfo Prjname job123
|grep "Job Status      : RUN FAILED (3)"
it should return non zero return code since it doesn't contain the search string.
so $? gives 1.

At the same time, the below code also returns 1(even though the search term is found).

Code: Select all

dsjob -server servname -user uname -password pwd -jobinfo Prjname job123
|grep "Job Status      : RUN OK (1)"
Can any one help me on this?

Thanks
pandeeswaran
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

$? just says that the previous command was executed sucessfully or not.

It will alwas give 0 for your command because the command was executed sucessfully.

Can you please let me know why you are using the if condition.
based on what you want you might have to handle it differently.
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Hi,

My requirement is :
if the output of the command ,

Code: Select all

dsjob -server servname -user uname -password pwd -jobinfo Prjname job123 
contains the string " Job Status : RUN FAILED (3)" , the jobname 'job123' should be written to a file.

Thanks
pandeeswaran
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

So you want only the job name in the file right?
samyamkrishna
Premium Member
Premium Member
Posts: 258
Joined: Tue Jul 04, 2006 10:35 pm
Location: Toronto

Post by samyamkrishna »

Hey Pandeesh,


Sorry my bad.

What you are doing in the script is correct.
What is going wrong when you run it?
Post Reply