Creating custom alerts

You can use IBM® Db2® Intelligence Center to create custom alerts using SQL scripts and schedule them to run at specific times.

About this task

In your custom alert type definition, you must specify a script that returns an exit value. The exit value determines the severity of the alert to generate. You can also specify a schedule for running the script against one or more target database servers.

Procedure

To create and manage custom alerts:

  1. Log in to IBM Db2 Intelligence Center.
  2. Open the Create alert page by using one of the following ways:
    Option 1:
    1. Click Administration and select Monitoring profile.

      The Monitoring profile page displays. To modify the settings for the existing profile, expand the vendor that matches your database (Example: Db2), select your monitoring profile and then click Edit.

    2. To create a new profile, from the Monitoring profile page, click Create profile.
    3. Click Custom alerts tab.
    Option 2:
    1. Click Administration and select Jobs.
    2. Click Custom alerts tab.
  3. To create and schedule alerts to run on specified databases, click Create alert.
  4. Enter the name of the custom alert to be created.
  5. Optional: Provide a short description of the alert.
  6. Click Next.
  7. Select one or more databases. The alert will run on each of the selected database.
  8. Click Next.
  9. Select the type of script for the custom alert. The supported script types are SQL-only scripts and Shell/Executable scripts. The script type sets the connection method to the database or database server.
    SQL-only script
    SQL Only scripts are run on the database. To run the job, the job manager connects to the database and runs the SQL commands that are included in the job script directly on the database. For more information see, Sample SQL scripts for custom alert types.
    Executable/Shell script
    Executable/Shell scripts are run on the database server. To run the script, the system logs in to the database server by using SSH as the user ID that is defined in the database connection, and then runs shell commands directly on the server. For more information see, Sample shell scripts for custom alert types.
    The script must return an exit value to indicate the severity of the alert to be generated. The valid return values are:
    0
    Normal condition (that is, no alert to be generated)
    -1
    Generate a warning alert
    -2
    Generate a critical alert

    If you use stored procedures, an OUT parameter must be included in the stored procedure to return an exit value (-2,-1, or 0) to indicate the severity of the alert to be generated. Sample stored procedures for custom alert types.

  10. Optional: Select the Alert severity.
  11. Define the Timeout settings.

    Specify an action to perform if the script execution duration exceeds a timeout period. You can enable the option to stop the script if the script runs longer than the specified duration. You can also enable the option to generate an alert (Critical, Warning, or Information) if the execution exceeds the specified duration.

  12. Click Next.
  13. Click the Select when to run toggle button, to schedule the alert.
  14. Specify the Start date, and Time, for scheduling the alert.
  15. Click Next.
  16. Review the alert details and click Finish.
    The custom alert is created and listed under the Custom alerts tab.
  17. To save the custom alert, click Save on the Monitoring profile page.
  18. To view the custom alerts, select a custom alert under the Custom alerts tab and click View history.
    The alert history table displays.

    Select the alert in the history table and click View or View log.

    The detailed information of the alert including its severity level and script output are displayed as shown in the following example:
    Database        : <connection name>             
    Host name       : <hostname>        
    Authorization id:  <username>            
    Run method      : <Shell script/SQL script>        
    Date            : <time and date>
    Status          : <status>             
    
    
    
    =======================================================================================
    <script>
    
    Run time (seconds): <run time>
    SEVERITY OUTPUT
    -------- ------
    <severity <script output>
     level>