Page 1 of 1

How to set up alert mechanisms based on the DS logs

Posted: Wed Feb 06, 2008 3:07 pm
by pavanns
Hi
ANy idea how do we set up alert mechanisms using DS Logs. I want to put an alert set up if i see a particular message in the Log and send out an email?

thanks
Pavan

Re: How to set up alert mechanisms based on the DS logs

Posted: Wed Feb 06, 2008 3:10 pm
by sud
You can do such kind of processing in a job sequence where through basic routines you can look for whatever message you are looking for in the job's log and send notifications.

Posted: Wed Feb 06, 2008 5:11 pm
by kduke
There is a job in EtlStats which loops through the log file and gets row counts. You might be able to modify it to do what you want.

capturing part of Log masg

Posted: Mon Apr 07, 2008 4:05 am
by Roopanwita
How can I capture the status of job from job Log(basically a part of log msg like 'no of recorded inserted in table') and send it as subject of mail notification in DS sequence stage,using routine (BASIC/C code)

Posted: Mon Apr 07, 2008 4:34 am
by ray.wurlod
DataStage will never report "number of records inserted in table". DataStage reports "number of rows sent to table" - whether or not they are successfully inserted depends upon the database server. If it generates error messages, these are returned to DataStage and logged. Thus, if you want to calculate "number of records inserted" you need to do some log browsing and some arithmetic.

But, yes, it can all be done with the DataStage API functions.

Re: capturing part of Log masg

Posted: Mon Apr 07, 2008 4:40 am
by PhilHibbs
Roopanwita wrote:How can I capture the status of job from job Log(basically a part of log msg like 'no of recorded inserted in table') and send it as subject of mail notification in DS sequence stage,using routine (BASIC/C code)
You are mixing terminology up, I think - job status is very different to the row count. There are DS Basic functions that return various information about a job given the name. Here is my Routine for job status:

Arguments: JobName, InfoID
$INCLUDE DSINCLUDE JOBCONTROL.H
Ans = 0
handleJob = DSAttachJob(JobName, DSJ.ERRNONE)
If NOT(handleJob) Then
Ans = -99
End
Else
Ans = DSGetJobInfo(handleJob, InfoID)
End
DetachResult = DSDetachJob(handleJob)

and my Routine for link count:

Arguments: JobName, StageName, LinkName
$INCLUDE DSINCLUDE JOBCONTROL.H
Ans = 0
handleJob = DSAttachJob(JobName, DSJ.ERRNONE)
If NOT(handleJob) Then
Ans = -99
End
Else
Ans = DSGetLinkInfo (handleJob, StageName, LinkName, DSJ.LINKROWCOUNT)
End
DetachResult = DSDetachJob(handleJob)

The Link Count routine needs to be passed the job name, and the name of an active stage and link. Active stages in a Server job would be Transformer, Sort, etc., but not Sequential File for instance. So you need to know the job design to get the row count info through this route - it doesn't use the Job Log, and you can only get info about the latest run.

InfoID can be passed such as DSJ.JOBSTATUS, DSJ.JOBSTARTTIMESTAMP, DSJ.JOBLASTTIMESTAMP, DSJ.JOBELAPSED.

I'm sure the gurus will correct me if this information is not applicable or different for PX jobs.

Posted: Mon Apr 07, 2008 5:35 am
by Roopanwita
Sorry for miscommunication.
Actully i wanted to capture part of msg Log ,i'e no of records procrssed..
if there is any fatal error in job,then from Log want to capture error msg line.
Thanks

Posted: Mon Apr 07, 2008 6:25 am
by ray.wurlod
So you want to do in code what you do manually in Director log view?

Look at the Help for DSGetNewestLogID() and DSGetLogEvent() functions.

Posted: Mon Apr 07, 2008 7:08 am
by AmeyJoshi14
Roopanwita wrote:Sorry for miscommunication.
Actully i wanted to capture part of msg Log ,i'e no of records procrssed..
if there is any fatal error in job,then from Log want to capture error msg line.
Thanks
Hi,
You can also get the above result from "dsjob" commands.
For the number of records you can use :

Code: Select all

$DSHOME/bin/dsjob -report project_name job_name DETAIL
For Fatal error in the job you can use:

Code: Select all

$DSHOME/bin/dsjob -lognewest project_name job_name FATAL
:!: Store the result in the sequential file and by using "mailx" command of unix you can mail the results. :wink: