Creating user-defined alert types

In addition to the predefined alert types that are provided by the web console, you can create your own alert types.

Before you begin

Ensure that you have the right privileges on the repository database to create user-defined alerts. In addition, you must provide a user ID with the correct permissions on the database to run the script for the user-defined alert type.
  • If the Can Manage Custom Alerts privilege restriction is enabled, you must have the Can Manage Custom Alerts privilege granted to create and manage user-defined alert types.
  • To run a script on a database, ensure that the user ID that runs the script has the required privileges to run the commands that are included in the script on the database. For Executable/Shell script job types, the user ID must also have permission to connect to the database server by using SSH.

    By default, the user ID that is included with the schedule is the user ID that is stored with the database connection. If that user ID does not have the correct privileges on the database server, you can assign another user ID to run the script when you schedule the script.

  • When multiple databases are targets for a scheduled script, the script will be run as the default user ID stored with the database connection for each database. If the Can Run As Default User privilege restriction is enabled, you must have the Can Run As Default User privilege granted to run a scheduled script.

About this task

In your user-defined 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 user-defined alert types:

  1. From the Open menu, click Health > User-Defined Alert Types.
  2. On the Alert Types tab, specify a script for the user-defined alert type.

    Specify a script that can run on the database or the database server. The script type sets the connection method to the database or database server. See sample scripts for user-defined alert types.

    The supported script types are SQL-only scripts and Shell/Executable scripts.
    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.
    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.
    Important: To run Executable/Shell scripts on a database, ensure that the user ID that is used to run the script has permission to log in to the database server by using SSH.

    If you want to use DB2 commands to generate an alert, you can run the DB2 commands by using the Executable/Shell script type for the user-defined alert type. Ensure that your DB2 environment is set up and initialized before you run the script.

    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
    Important: The web console does not verify that the scripts that you enter are valid. Click Test Script to run the script on a database or database server, or use other methods to verify that the script is correct and that it produces the expected results before you schedule the user-defined alert.
  3. Schedule the script to run on the database or the database server.

    A script runs according to an active schedule. A schedule defines when a script runs, whether the script is repeating, and whether the schedule is limited in number of runs or in time. The schedule also defines one or more databases on which to run the script. A schedule can be active, or inactive.

    When you schedule a script on a single database, you can define the user ID that runs the script. If you schedule a script to run on more than one database, the script runs on each database with the user ID that is stored in the database connection for that database.

  4. Click Save All to save the user-defined alert type.

Feedback