Documente Academic
Documente Profesional
Documente Cultură
28 February 2013
Introduction
The DataStage and QualityStage Operations Database (DSODB) is a back-end database for the
IBM InfoSphere DataStage and QualityStage Operations Console web-based application. DSODB
is designed as a relational database, and the schema for it is publicly documented. DSODB
consists of several tables that store information for a job whenever a job is run.
When using DataStage, it is important that you know how the running jobs performed, and it is
also good to be automatically alerted based on certain criteria. Because the job-related information
gets stored in the DSODB tables as the jobs are running, you can set up database triggers on the
tables to receive email alertsafter you understand how the tables get updated and how to use
the data in these tables.
Copyright IBM Corporation 2013
Designing an alerts mechanism on the IBM InfoSphere
DataStage and QualityStage Operations Console Database, Part
1: Alerts for common scenarios
Trademarks
Page 1 of 9
developerWorks
ibm.com/developerWorks/
This article steps you through creating triggers for some common scenarios and sending an email
alert to the specified user from within the trigger. The article also describes how the DSODB tables
get updated and how to use the data that is available in these tables within the trigger.
More information on the DSODB schema, including the tables and columns can be found from the
documents that are listed in Resources.
Knowledge prerequisites
To follow along with the article, you should have a basic understanding of the following areas:
DataStage and Operations Console
DB2 and database triggers
Database concepts
Alert actions
The first part of this article series explains how to create email alerts using database triggers for
some common and simple scenarios, such as:
You can use the DB2 provided emailing facility and built-in stored procedure UTL_MAIL to send
emails. To successfully send emails using this module, you must set a valid SMTP server address
to the database configuration parameter SMTP_SERVER in the DB2 database that is used to hold the
operational data.
To do this, issue the commands that are shown in Listing 1 at the DB2 command prompt.
Page 2 of 9
ibm.com/developerWorks/
developerWorks
Creating alerts
AlertFailedJobs
In this alert action, you should send email to the specified email ID if any of the running jobs
failed. When a job is started, a row corresponding to this job is inserted into the JobRun table,
and as the job continues to run this row is updated periodically. When the job finishes, the
RunMajorStatus column is updated to 'FIN' (meaning the job is finished). If the job fails, there will
be at least one fatal message, so the NumMessagesFatal column is updated to a number that
is greater than 0. So for this alert action, you must create a trigger on update of DSODB.JobRun
table's RunMajorStatus column and check for the conditions, RunMajorStatus = 'FIN' and
NumMessagesFatal > 0.
Listing 2 shows the code to create the trigger for this alert action.
hostName VARCHAR(255);
projectName VARCHAR(255);
jobName VARCHAR(255);
message VARCHAR(1500);
Within the trigger body, you get the host name, project name, and job name of the triggered row
(NEWROW) by querying the tables DSODB.Host, DSODB.JobExec, and DSODB.JobRun. You also
call the UTL_MAIL module with the required values to send email.
The jobType column in the DSODB.JobExec table indicates whether the job is a server job (SRV),
a parallel job (PAR), or a sequence job (SEQ). So, if you want to send alerts for a particular job
type (for example, parallel jobs), then you must get the jobType and compare this value to 'PAR'.
After comparing, you must call the UTL_MAIL from within the trigger body, as shown in Listing 3.
Page 3 of 9
developerWorks
ibm.com/developerWorks/
ExceededElapsedTime
In this alert action, you can send details of a job that is finished but has taken more than N minutes
(say 60 minutes) to complete the run. The elapsed time for a particular job run is stored in the
ElapsedRunSecs column in the DSODB.JobRun table. In fact, the ElapsedRunSecs column is
updated every 10 seconds until the job is complete. The job completion information is available
in the RunMajorStatus column. Therefore, the trigger involves checking the finish status on the
RunMajorStatus column and the value in the ElapsedRunSecs column. The trigger code for this
alert action is shown in Listing 4.
hostName VARCHAR(255);
projectName VARCHAR(255);
jobName VARCHAR(255);
message VARCHAR(1500);
In the previous trigger, you can collect the host name, project name, and job name of the triggered
row and send email with the details.
SignalHostDelete
In this alert action, you are able to send an email and signal error if anyone is trying to delete a
row from the HOST table. If anyone deletes a row from this table, because of the cascading delete
Designing an alerts mechanism on the IBM InfoSphere
DataStage and QualityStage Operations Console Database, Part
1: Alerts for common scenarios
Page 4 of 9
ibm.com/developerWorks/
developerWorks
constraints, all the data of the jobs that ran on this system and all the related resource usage
records are deleted from the ODB tables at the same time. To avoid accidentally deleting a row
from this table, you can set a trigger, and this trigger, if set, will not let anyone remove rows from
the HOST Table. Listing 5 lists the code for this alert action.
ON DSODB.HOST
REFERENCING
Note: The SIGNAL SQLSTATE statements within the trigger body report error conditions and roll
back any changes that are made by the trigger. The SIGNAL statement in Listing 5, after the delete
trigger, rolls back the deleted row in the HOST table.
TooFewRowsProduced
In this action, you can create an alert by sending an email if a specific job is finished and produced
less than N rows (that is, a job that hasn't produced as much output as you expect). This alert
again involves checking the RunMajorStatus column for the finish condition. Inside the trigger
body, you can fetch the host name, project name, and job name from the ODB tables and compare
them with the required job details on which you would like to monitor the total rows produced.
Listing 6 shows the trigger code for this alert.
Listing 6. Trigger code to alert job runs that produced insufficient rows
CREATE TRIGGER DSODB.TOOFEWROWSPRODUCED AFTER UPDATE OF RUNMAJORSTATUS ON
DSODB.JOBRUN REFERENCING NEW AS NEWROW FOR EACH ROW MODE DB2SQL
WHEN ( NEWROW.RUNMAJORSTATUS = 'FIN' )
BEGIN ATOMIC
DECLARE
DECLARE
DECLARE
DECLARE
hostName VARCHAR(80);
projectName VARCHAR(255);
jobName VARCHAR(255);
message VARCHAR(1500);
Page 5 of 9
developerWorks
ibm.com/developerWorks/
|| '; Project name = ' || projectName || '; Job name = ' || jobName
|| '; Invocation id = ' || NEWROW.INVOCATIONID || '; Run end time stamp = '
|| NEWROW.RUNENDTIMESTAMP;
CALL UTL_MAIL.SEND( <Sender Email>, <Recipients Email>, NULL, NULL,
'Too few rows produced alert triggered', message);
END IF;
END
If you have multiple engine installations on the same host, then you need to use Host ID instead
of Host Name in the code in Listing 6, because the host name is the same for different engine
installations on the same machine. The value for the host ID needs to be taken from the HOST
table matching the host name and the installed engine directory of the job being monitored.
The method in Listing 6 is optimal if you have a small number of jobs. If you want to monitor
several conditions, you can create another table to hold many conditions. So, for the example in
Listing 6, create a table, TooFewRowsProducedConfig, with details for HostName, ProjectName,
JobName, and TotalRows for all of the jobs. Then, inside the trigger body, get the host name,
project name, and job name of the triggered job run by querying the ODB tables. You must query
the TooFewRowsProducedConfig table for this particular tuple and get the total rows. If Totalrows
is available in the config table, then compare this value with the TotalRowsProduced value from
the triggered job run. Listing 7 shows the code for creating the TooFewRowsProducedConfig table.
Listing 8 then shows how to set up the alert.
newRowHostName VARCHAR(80);
newRowProjectName VARCHAR(255);
newRowJobName VARCHAR(255);
message VARCHAR(1500);
expectedRows BIGINT;
Page 6 of 9
ibm.com/developerWorks/
developerWorks
Conclusion
In this article, you have learned how the DataStage Operations Database tables get updated as
well as how to construct email alerts on the operations database using database triggers.
Page 7 of 9
developerWorks
ibm.com/developerWorks/
Resources
Page 8 of 9
ibm.com/developerWorks/
developerWorks
Len Greenwood
Len Greenwood was a member of the small development team that produced the first
version of DataStage in 1996, prior to it being acquired from Ascential Software by
IBM in 2005. It now forms a mainstay of the IBM InfoSphere Information Server suite.
He has worked in the related areas of data and metadata integration for the past
15 years and is currently the main product architect for the core components of the
DataStage and QualityStage development and production tools. He recently designed
the database schema that underlies the Information Server Operations Console, used
to monitor activity at the DataStage engine level.
Copyright IBM Corporation 2013
(www.ibm.com/legal/copytrade.shtml)
Trademarks
(www.ibm.com/developerworks/ibm/trademarks/)
Page 9 of 9