Capturing the director log metadata

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Druid_Elf
Participant
Posts: 32
Joined: Thu Aug 28, 2008 5:53 am

Capturing the director log metadata

Post by Druid_Elf »

Hi,
I am trying to write a job, which dumps some information of the director to a file on unix when the job has aborted due to a fatal error.
I've been looking with the search function and found some solutions using dsjob.
Now I have the following statement
dsjob -logsum -type FATAL -max 3 INTFUAT refresh_ODS_MV

(INTFUAT is the projectname, refresh_ODS_MV is the jobname)

Is it possible with the above, not to limit the output to the last 3 entries, but to limit the output for the final run ?

Thanks for any help :)
miwinter
Participant
Posts: 396
Joined: Thu Jun 22, 2006 7:00 am
Location: England, UK

Post by miwinter »

Purely playing from memory here, but I think dsjob has an option somewhere of -lognewest that would restrict to output from most recent run. Best bet, as ever, first and always, would be to refer to the product documentation :)
Mark Winter
<i>Nothing appeases a troubled mind more than <b>good</b> music</i>
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right, you would need to use a combination of -lognewest and -logdetail to get what you want.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Druid_Elf
Participant
Posts: 32
Joined: Thu Aug 28, 2008 5:53 am

Post by Druid_Elf »

Hi,
thanks from the feedback but I've taken a bit of a different approach. I've created an after routine with the following code:

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H 

ErrorCode = 0 

JobName = Trim(Field(InputArg,";",1,1))
DirName = Trim(Field(InputArg,";",2,1))

Suffix = ".txt" 

Call DSLogInfo('InputArg passed : ' : JobName , 'Job20Stat')
Call DSLogInfo('InputArg2 passed : ' : DirName , 'Job20Stat')

handlejob=DSAttachJob (JobName,DSJ.ERRNONE )

*JobName = DSGetJobInfo(handlejob,JobName) 
JobStarted = convert(" :-","_",DSGetJobInfo(handlejob,DSJ.JOBSTARTTIMESTAMP)) 

FileName = JobName:"_":JobStarted:Suffix 

StartTimeStamp = DSGetJobInfo (handlejob, DSJ.JOBSTARTTIMESTAMP) 
EndTimeStamp = DSGetJobInfo (handlejob, DSJ.JOBLASTTIMESTAMP) 

*Only retrieve the FATAL errors
GetLogSum = DSGetLogSummary(handlejob,DSJ.LOGFATAL ,StartTimeStamp,EndTimeStamp,0) 


Openpath DirName to t.fvar then 
write GetLogSum to t.fvar, FileName else 
call DSLogWarn("Failed to write file ":FileName:" to directory ":DirName, "GetJobLog") 
end 
end 
else 
call DSLogWarn("Failed to open directory ":DirName, "GetJobLog") 
end 

close t.fvar 
ErrorCode = 0      ;* set this to non-zero to stop the stage/job
Now I have a problem. The routine is called in a job which collects meta data in all cases (even if the job has run successfully).
I only want this piece of code to be executed, if the job for which meta data is collected had a fatal error. Can i do a null check on the GetLogSum ? The help guide sais it is an array so i am not sure how to do a check for empty values on it. Or can i do a check earlier in the code ?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You need to check the INTERIMJOBSTATUS first to determine after job if the job is on its way to aborting. And to connect to the current job, you don't need a handle but rather use DSJ.ME as the handle instead.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply