DB Monitor Service

The DB Monitor service monitors the database for common conditions that might be signs of problems with database health.

The following table provides an overview of the DB Monitor service:

System Name DBMonitorService
Graphical Process Modeler (GPM) categories) All Services
Description This service monitors the database for common conditions that may be signs of system problems. May be scheduled to run at regular intervals.
Business usage The DB Monitor service is used by the Schedule_DBMonitorService business process. Together they are used by the system to notify the system administrator if key database health thresholds are exceeded or if maintenance is needed. This maintenance includes indexes, rebuilds, and analyze table actions. By default, this service is scheduled to run every Monday at 4:00 A.M.
Usage example The DB Monitor service is scheduled to run once a week. If the service determines that a key indicator has exceeded its threshold, the system will notify the system administrator by e-mail. It also monitors the database maintenance needs and provides the instructions (SQL commands) necessary to rebuild indexes and analyze tables.
Preconfigured? Yes
Requires third-party files? No
Platform availability All supported Sterling B2B Integrator platforms
Related services None
Application requirements The database must support the requested functionality. Functionality available is dependent on the database's ability to support it. For example, DB2 and MySQL do not support providing statistics on database size.
Initiates business processes? The DB Monitor service invokes an associated system business process, Schedule_DBMonitorService.
Invocation Scheduler
Business process context considerations None
Returned status values N/A
Restrictions None
Persistence level System Default
Testing considerations None

How the DB Monitor Service Works

The DB Monitor service sends notification, as configured by the Sterling B2B Integrator event alert system, of any recommended maintenance. If the DB Monitor service determines that the system administrator needs to rebuild the index, or analyze database tables, the service will produce a primary document that provides information about the recommended maintenance. The DB Monitor service will also provide notification if key database health thresholds are exceeded. By default, the system will send an e-mail to the system administrator.

The preconfigured instance of the DB Monitor service, named DBMonitorService, has an associated business process named Schedule_DBMonitorService that performs all the available actions of the DB Monitor service by using default values for each. The DBMonitorService instance is scheduled to run each Monday at 4:00 A.M. You can change the run day and time using the Scheduler.

Note: The Schedule_DBMonitorService BP, with ACTION=CHECK_DB_INDEX and EXECUTE_QUERY=true, can do a lot of database updates to rebuild the indexes and analyze the database tables. It could lead to deadlocks if done while Sterling B2B Integrator is running. If you want to run this BP with these settings while Sterling B2B Integrator is running, you should run it during non-peak times. To prevent the deadlocks, keep the default value of EXECUTE_QUERY=false.

If you create a new instance of the DB Monitor service and specify a schedule in the service configuration, the system will create an associated business process using the name of your instance (minus any spaces) preceded by Schedule_. For example, if you name your instance My DB Monitor Service, the business process name will be Schedule_MyDBMonitorService. If you do not use a schedule in the service configuration, a business process will not automatically be created.

You can change settings by editing the BPML in the associated business process. You can also use the DB Monitor service in your own business process and specify settings in the Graphical Process Monitor, or directly in your BPML.

Implementing the DB Monitor Service

To implement the DB Monitor service, complete the following tasks:
  1. Create a new configuration of the DB Monitor service. For basic information about creating service configurations, see Managing Services and Adapters.
  2. Specify field settings for scheduling the service configuration in the Sterling B2B Integrator Admin Console.
  3. If necessary, specify settings in the GPM, or using BPML in your business processes. This step is not necessary if you want to use the pre-configured business process with default settings.

Configuring the DB Monitor Service

Creating a Service Configuration in the Admin Console

Use the field definitions in the following table to create a new configuration of the DB Monitor service.

Field Description
Name Unique and meaningful name for the service configuration. Required.
Description Meaningful description for the service configuration, for reference purposes. Required.
Select a Group Select one of the options:
  • None – Do not include the configuration in a service group at this time.
  • Create New Group – Enter a unique name for a new group, which will be created with this configuration. (You can then add other services to the group as well.)
  • Select Group – If service groups already exist for this service type, they are displayed in the list. Select a group from the list.
Note: For more information about service groups, see Managing Services and Adapters.
Run As User Type the user ID to associate with the schedule, or click the icon and select a user ID from the list. Valid values: Any valid Sterling B2B Integrator user ID.
Use 24 Hour Clock Display Check the box to use the 24-hour clock instead of the default 12-hour clock.
Schedule Specify the scheduling information for running the Auto Terminate service. Valid values:
  • Do not use schedule If you select this field, the service does not run on a schedule.
  • Run based on timer Valid values are the hour and minutes at which to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any schedule exclusions or date exclusions. Indicate whether you want the service to run at startup.
  • Run daily Valid values are the hour and minutes at which to run the service each day. If you choose to select a time interval, the valid values are the hour and minute for the interval. Add or delete selections as necessary. Specify any date exclusions. Indicate whether you want the service to run at startup.
  • Run based on day(s) of the week Valid values are the day of the week, the hour, and the minute that specify when to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any date exclusions.
  • Run based on day(s) of the month Valid values are the day of the month, hour, and minute that specify when to run the service. If you choose to select a time interval, the valid values are the hours and minutes for the intervals. Add or delete selections as necessary. Specify any date exclusions.
Note: Any value except Do not use schedule will cause a Schedule_InstanceName business process to be automatically created. See How the DB Monitor Service Works for more information. If you select Do not use schedule, you must specify service settings in the GPM.

Setting Up the Service in the GPM

Use the field definitions in the following table to set up the service configuration in the GPM:

Field Description
Config Select the name of the service configuration from the list.
ACTION Specifies an action to take. Required. Valid Values:
  • Check DB Full – Check the current size of the database and provide the result as a percentage of the maximum database size.
  • Check DB Grown – Check how much the database has grown since the last time it was checked and provide the result as a percentage.
  • Check DB Index – Check whether indexes need to be rebuilt or check whether tables need to be analyzed. Either REBUILD_INDEXES or ANALYZE must be set to true.
Note: The Schedule_instanceName business process that is automatically created with an implementation of the DB Monitor service performs all three actions using the default values for each.
ANALYZE Used only if ACTION is set to Check DB Index. Specifies whether to check whether tables need to be analyzed. Optional. Valid values:
  • true – Check whether tables need to be analyzed.
  • false – Do not check whether tables need to be analyzed. Default.
DO_AII_TABLE Used only if ACTION is set to Check DB Index. Specifies whether to check all the tables from the database. Optional. Valid values:
  • true – Check all the database tables.
  • false – Check the tables that recorded on the database since last time rebuilds Default.
LAST_ANALYZED_DATE Used only if ACTION is set to Check DB Index. The expiration date and time to check against the database. If the table is expired since the last check, it is placed in a list for index rebuilding or analysis. Optional. Example value: 20051230-12:12:12.000. Default is current date.
MAX_PERCENT_FULL Used only if ACTION is set to Check DB Full. The percentage of maximum database size the database must reach before a notification is sent to the event framework. Optional. Default is 80.
MAX_PERCENT_GROWN Used only if ACTION is set to Check DB Grown. The percentage of maximum database size that the database must have grown since last time checked before a notification is sent to the event framework. Optional. Default is 30.
REBUILD_INDEXES Used only if ACTION is set to Check DB Index. Specifies whether to check whether the indexes need rebuilt. Optional. Valid values:
  • true – Check whether indexes need to be rebuilt.
  • false – Do not check whether indexes need to be rebuilt. Default.
SAVE_STATUS Used only if ACTION is set to For Check DB Full or Check DB Grown. Specifies whether to save the database usage to the database to allow comparison of the difference for the next check. Optional. Valid values
  • true – Save the database usage to the database.
  • false – Do not save the database usage to the database. Default.

Business Process Example

The following example illustrates a business process containing the DB Monitor service. The following BPML is from the Schedule_DBMonitorService business process invoked by the DB Monitor service.

<process name="Schedule_DBMonitorService">
  <sequence name="Start">
    <operation name="SetLock">
      <participant name="SystemLockService"/>
      <output message="Xout">
        <assign to="LOCK_KEY">DBMonitorService_Lock</assign>
        <assign to="DURATION">86400000</assign>
        <assign to="CLEAR_ON_START_UP">true</assign>
        <assign to="." from="*"></assign>
      </output>
      <input message="Xin">
        <assign to="." from="*"></assign>
      </input>
    </operation> 
Check for database percentage grown beyond threshold since last check
    <sequence name="Process">
      <operation name="DBMonitorService_1">
        <participant name="DBMonitorService"/>
        <output message="Xout">
          <assign to="ACTION">CHECK_DB_GROWN</assign>
          <assign to="MAX_PERCENT_GROWN">30</assign>
          <assign to="SAVE_STATUS">true</assign>
          <assign to="." from="*"></assign>
        </output>
        <input message="Xin">
          <assign to="." from="*"></assign>
        </input>
      </operation>

Check for database percentage full.

      <operation name="DBMonitorService_2">
        <participant name="DBMonitorService"/>
        <output message="Xout">
          <assign to="ACTION">CHECK_DB_FULL</assign>
          <assign to="MAX_PERCENT_FULL">80</assign>
          <assign to="SAVE_STATUS">true</assign>
          <assign to="." from="*"></assign>
        </output>
        <input message="Xin">
          <assign to="." from="*"></assign>
        </input>
      </operation> 
Check for whether or not the database should be re-indexed
      <operation name="DBMonitorService_3">
        <participant name="DBMonitorService"/>
        <output message="Xout">
          <assign to="ACTION">CHECK_DB_INDEX</assign>
          <assign to="REBUILD_INDEXES">true</assign>
          <assign to="ANALYZE">true</assign>
          <assign to="DO_All_TABLE">false</assign>
          <assign to="." from="*"></assign>
        </output>
        <input message="Xin">
          <assign to="." from="*"></assign>
        </input>
      </operation>
      <sequence name="UnLock">
        <operation name="UnLock">
          <participant name="SystemLockService"/>
          <output message="Xout">
            <assign to="ACTION">unlock</assign>
            <assign to="LOCK_KEY">DBMonitorService_Lock</assign>
            <assign to="." from="*"></assign>
          </output>
          <input message="Xin">
            <assign to="." from="*"></assign>
          </input>
        </operation>
        <onFault>
          <assign to="UnLock_Msg" append="true">Failed to obtain a unlock!</assign>
        </onFault>
      </sequence>
      <onFault>
        <operation>
          <participant name="SystemLockService"/>
          <output message="Xout">
            <assign to="ACTION">unlock</assign>
            <assign to="LOCK_KEY">DBMonitorService_Lock</assign>
            <assign to="." from="*"></assign>
          </output>
          <input message="Xin">
            <assign to="." from="*"></assign>
          </input>
        </operation>
      </onFault>
    </sequence>
    <onFault>
      <assign to="Lock_Msg" append="true">Failed to obtain a lock!</assign>
    </onFault>
  </sequence> 
</process>

Parameters Passed From Service to Business Process

The following table contains the parameters passed from the DB Monitor service to the business process:

Parameter Description
UsagePercentFull The current percent used of maximum database size.
UsageUsed The current amount of space, in MB, used by the database.
UsageTotal The total amount of space, in MB, used by the database.
UsageUsedKB The current amount of space, in KB, used by the database.
PercentGrown The percentage the database has grown since the last time it was checked.
SQL_<Number_of_SQL> The actual SQL statements for index rebuild and analyze tables.