Page 1 of 1
Capturing the director log metadata
Posted: Mon Aug 03, 2009 7:10 am
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
Posted: Mon Aug 03, 2009 7:20 am
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
Posted: Mon Aug 03, 2009 7:45 am
by chulett
Right, you would need to use a combination of -lognewest and -logdetail to get what you want.
Posted: Tue Aug 04, 2009 2:22 am
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 ?
Posted: Tue Aug 04, 2009 5:37 am
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.