Scenario: Job monitor with Advanced Job Scheduler notification

See an example job monitor that sends an e-mail to an operator when the threshold limit of a job is exceeded.

Situation

You are currently running an application on your iSeries™ server, and you want to be notified if the CPU utilization reaches the specified threshold.

If the Advanced Job Scheduler is installed on the endpoint system, you can use the Send Distribution using JS (SNDDSTJS) command to notify someone by e-mail when the threshold is exceeded. For instance, you could specify that the notification escalate to the next person if the intended recipient does not respond by stopping the message. You could create on-call schedules and send the notification to only those people that are on-call. You can also send the notification to multiple e-mail addresses.

Job monitor configuration example

This example uses the SNDDSTJS command to send a message to a recipient named OPERATOR, which is a user-defined list of e-mail addresses. You can also specify an e-mail address instead of a recipient or both. To set up a job monitor that accomplishes this goal, complete the following steps:

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
  1. In iSeries Navigator, expand Management Central > Monitors, right-click Job monitor, and select New Monitor...
  2. On the General page, enter the following values:
    1. Specify a name and description for this monitor.
    2. On the Jobs to monitor tab, enter the following values:
      1. For the Job name, specify the name of the job you want to watch for (for example, MKWIDGET).
      2. Click Add.
  3. Click the Metrics tab, and enter the following information:
    1. In the Available metrics list, expand Summary Numeric Values, select CPU Percent Utilization, and click Add.
    2. On the Threshold 1 tab for the metrics settings, enter the following values:
      1. Select Enable trigger.
      2. For the threshold trigger value, specify >= 30 (greater than or equal to 30 percent busy).
      3. For Duration, specify 1 interval.
      4. For the i5/OS™ trigger command, specify the following:
        SNDDSTJS RCP(OPERATOR) SUBJECT('Job monitor trigger') MSG('Job
        &JOBNAME is still running!')
      5. Click Enable reset.
      6. For the threshold reset value, specify < 20 (less than 20 percent busy).
  4. Click the Collection Interval tab, and select 15 seconds. This will override the Collection Services setting.
  5. Click the Actions tab, and select Log event in both the Trigger and Reset columns.
  6. Click the Servers and groups tab, and select the servers and groups you want to monitor for this job.
  7. Click OK to save the new monitor.
  8. From the list of job monitors, right-click the new monitor and select Start.

Message monitor configuration example

If you use a message monitor, you can send the message text to the recipient. Here is an example of a CL program that retrieves the message text and sends an e-mail to all on-call recipients with the SNDDSTJS command.

Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
PGM PARM(&MSGKEY &TOMSGQ &TOLIB)

DCL &MSGKEY  *CHAR 4
DCL &TOMSGQ  *CHAR 10
DCL &TOLIB   *CHAR 10

DCL &MSGTXT  *CHAR 132

RCVMSG   MSGQ(&TOLIB/&TOMSGQ) MSGKEY(&MSGKEY)
         RMV(*NO)  MSG(&MSGTXT)
                 MONMSG CPF0000 EXEC(RETURN)
                 
SNDDSTJS RCP(*ONCALL) SUBJECT('Message queue trigger') 
MSG(&MSGTXT)
     MONMSG MSGID(CPF0000 IJS0000)
         
ENDPGM

This is the command that would call the CL program:

CALL SNDMAIL PARM('&MSGKEY' '&TOMSG' '&TOLIB')

Results

The monitor checks the QINTER subsystem every 15 seconds, and if the job MKWIDGET is consuming more than 30 percent of the CPU, the monitor sends an e-mail to the operator. The monitor resets when the job uses less than 20% CPU capacity.

See Work with notification for more information on the Advanced Job Scheduler notification function.