Page 1 of 1

Job Info

Posted: Sun Jun 13, 2004 9:36 am
by amsh76
I have a situation where I need to log Job information in the file. There are DS routines that I can use ? And is it anyways I can run them afterstage or afterjob ? I want the timestamp, row count, job name..all these write into flat file in same job.

And if someone can tell me in steps as to how to run this in afterjob or afterstage ?

Posted: Sun Jun 13, 2004 12:32 pm
by kcbland
You can write a routine to be called in the after-job routine or in a controlling job. The appropriate API's (DS*) are in your DS BASIC manual. The steps are to attach to a job, get its stage list, loop thru the stage list getting the link list and for each link the row count. You'll have to learn about opening a sequential file (OPENSEQ), writing data to a sequential file (WRITESEQ) and close it when finished (WEOFSEQ, CLOSESEQ). Have fun!

Posted: Sun Jun 13, 2004 3:09 pm
by ray.wurlod
Question your need. This information is already captured into the job's own log (which happens to be a table in the Repository). You can print, or print to file, from the Director client on those odd occasions you genuinely need to capture these data into a file.

Yes, you can do it all in code, but why re-invent the wheel?

Posted: Sun Jun 13, 2004 6:31 pm
by amsh76
yeah thats true Ray, but thats the Client requirement....thats how they want. That was the first thing I suggested but they wanted it to be written in the file as soon as the job is executed. :cry:

Can you throw more light on this.

Posted: Sun Jun 13, 2004 7:52 pm
by ray.wurlod
Yes, you can have a great deal of free time by requiring their specifications to be documented. For example:
  • Which row count? Row counts are different on different links (for example they are ideally zero on reject-handling links).

    What is their business rule for "timestamp"? That is, which particular timestamp do they want? Job start, job finish, active stage start/finish, and so on.

    What naming convention is required for the output file? Should it be overwritten or appended to. How is it to be further processed? (If you don't get an answer on this, don't do the time-wasting work.)

    What is their business rule for capturing the invocation ID should you, the developer, elect for performance reasons to create multiple-instance jobs and run them in parallel? What are the implications then for the output file name?
You create a before/after subroutine as a new Routine, and choose "before/after subroutine" as its type. There are exactly two arguments; the first (by default called "InputArg") accepts whatever is in the Input Value field of its caller (job parameter references are resolved before the before/after subroutine is called). The second argument (by default called ErrorCode and initialized to zero) is used to halt execution of the job if necessary (I believe that jobs should be written so that abort is never necessary.).

Functions you need include DSGetJobInfo (for job name and job start time stamp) and DSGetLinkInfo (for row counts). In intermediate steps you will probably also need DSGetStageInfo (to get a list of the link names attached to an active stage).

As Ken suggested, the statements needed for manipulating the output file are OpenSeq, WriteSeq and CloseSeq (and possibly WeofSeq if you're going to truncate or Seek if you're going to append).
All of these functions and statements are in on-line help from Designer.

Posted: Sun Jun 13, 2004 8:04 pm
by kduke
There is a job on ADN you can download called DSJobReport.dsx. I modifed this to dump straight to 3 Oracle tables. One for job stats, one for row stats and one for parameter stats. I should post it back this week with my changes.

You need to job stats because not all jobs have row counts like sequences. The next you need history to show rows per second over time. Is this job getting slower. The last thing is parameter history because if a job fails it may be because the parameter had the wrong value.

Posted: Mon Jun 14, 2004 4:43 am
by girishoak
Hi All,

I have recently prepered a DSJob to get log that takes input as file name. this Input file contains list of job names for those log is required. After running this job. It creates a text file containinng jobname, stagename, no. of rows (in as well as out) and time elapsed. If you wish I wont mind to share it.

It would be great if kim, ray and other DS Guru review the code and fine tune that. I will try to upload this code in next few days.

Regards

Girish Oak