Log to file

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

Moderators: chulett, rschirm, roy

mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Log to file

Post by mdbatra »

Hi All,
How do we dump the latest log of a job to a text file? there's is a requirement where we need to send the log to client in case of a failure. Due to time constaint, i was able to browse a few of the posts on this topic, but didn't quite get it.

Would prefer if somebody can guide using BASIC/server job ?
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

i had tried the same some months ago, that's here:
viewtopic.php?t=141047
I believe that will help you more
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

even if any guide could be provided on fetching the EVENT_ID for the first event of the latest run, i would be able to get the desired results.
Would appreciate any help on this.
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Code: Select all

#                      maillog.sh                                          #
#Author:Pandeeswaran                                                       #
#This is used to retrieve the warnings and fatals alone in the recent run  #

START_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user username -password pwd -logsum -type STARTED Projectname Jobname| nawk 'ORS=(FNR%2)?FS:RS' | grep Starting | tail -1 | awk '{print $1 }'`

WARN_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logsum -type WARNING Projectname Jobname| grep WARNING | awk '{print $1 }'`

FATAL_ID=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logsum -type FATAL Projectname Jobname| grep FATAL | awk '{print $1 }'`

echo "WARNINGS AND FATALS:" > /path/log.txt

ALL_ID=`echo "${WARN_ID} ${FATAL_ID}"` 

for ID in ${ALL_ID} 
do 
if [[ "${ID}" -gt "${START_ID}" ]] 
then 
ALL_DTL=`/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server Servername -user username -password pwd -logdetail Projectname Jobname ${ID}` 
echo ${ALL_DTL}\n >> /path/log.txt
echo "\n" >>/path/log.txt
fi 
done 
(cat /path/log.txt)|mailx -s  "find the fatals and warnings" "mailid"

exit 0
Last edited by pandeesh on Wed Feb 15, 2012 4:52 am, edited 2 times in total.
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

Thanks pandeesh, but i would prefer the solutions given in your thread earlier, as i am not very keen to use UNIX for this solution. I should be able to manage now from BASIC. let me try , will get back. and thanks so much for this quick response.
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

I believe you have BASIC guide.Everything is documented over there.
You can check

Code: Select all

DSJ.LOGSTARTED
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

yeah...i am just working on those LOGSTARTED/LOGANY to give me the latest start and event ID, so that i can loop through.

Thanks to your posts dear :)
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Please resolve the topic, once your problem gets solved.

Thanks for your co-operation
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

LOGSTARTED and LOGANY in DSNewestLogId is yielding the same results, which is the last event id for latest run :(

i am using code(this is just a draft version):

job = pJobName
log_file = pJobLogFile

control = DSJobName

Call DSLogInfo("job name is ":job,control)
Call DSLogInfo("Output log file is ":log_file,control)

hJob = DSAttachJob(job,DSJ.ERRFATAL)

Call DSLogInfo("job attached now",control)

st_id= DSGetNewestLogId(hJob,DSJ.LOGSTARTED)
Call DSLogInfo("Start id is: ":st_id, control)
end_id= DSGetNewestLogId(hJob,DSJ.LOGANY)
Call DSLogInfo("End id is: ":end_id, control)

please let me know if i am missing anything here.
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

I think you are facing the same issue whichever i faced.
Please reread my older post and finally you can find the suggestion provided by evee1:

Code: Select all

However, when I changed the routine to do the following instead:
Code:
NewestStartId = DSGetNewestLogId(DSJ.ME, DSJ.LOGSTARTED)
NewestLogId = DSGetNewestLogId(DSJ.ME, DSJ.LOGANY)
the routine is able to locate the starting event correctly.  
But i din't face any issues in the unix script i have posted(Because of this only, i went for unix solution at that time :) )
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

But wouldn't DSJ.ME point to the current job. I am writing the control in a separate job to read the log of a different job.
Rgds,
MB
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Yes, so you'll need to get a handle to that other job and use that rather than DSJ.ME and release it when you are done.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

That's what the problem is. If you can have a quick look at the sample code above, i used a separate job handle for that job.

But the problem here is LOGSTARTED & LOGANY are returning same event id(last event id for latest run), instead of last start event id and last event id of that particular job, respectively.
Rgds,
MB
pandeesh
Premium Member
Premium Member
Posts: 1399
Joined: Sun Oct 24, 2010 5:15 am
Location: CHENNAI, TAMIL NADU

Post by pandeesh »

Honestly, i have never tried that in routine and implemented the same in shell script.
pandeeswaran
mdbatra
Premium Member
Premium Member
Posts: 175
Joined: Wed Oct 22, 2008 10:01 am
Location: City of London

Post by mdbatra »

i understand pandeesh :) ...but i am interested to know why this things is not wondering. I would be left with no other option than to use the unix solution, but my first love is BASIC :)
Rgds,
MB
Post Reply