Q: I need to develop a monitoring system that should be able to send an alert to let people know the following:
a) When a pre-defined job (job name only or job name and user name) enters a subsystem
b) If the job is held by a user or is stuck at MSGW status
c) How the job ended, either normally or abnormally
I looked at the Job Notification exit program, but it does not help us monitor a job’s status changes. Other Work Management APIs ask you to fetch all active jobs at a given point of time, but don’t tell if the job has ended.
Is there an API or other workaround available to address this problem?
A: The answer to the problem is to use the Job Notification exit program in conjunction with the Retrieve Job Information (QUSRJOBI) API.
For those not familiar with exit programs, an exit program is a program that gets called by the operating system when a particular event occurs. This event is called an “exit point,” so the program that is called at that point is known as an “exit program.”
For example, if you want to call a program whenever a device description is initialized by the telnet server, you could register a “Telnet Device Initialization” exit program. This program can then have some control over how the device gets initialized.
In the case of monitoring a job entering or exiting the system, the exit point that we’ll use is called QIBM_QWT_JOBNOTIFY and is described as the “Job Notification” exit point.
The Job Notification exit point is unusual in that it does not call a program like the other exit points do. Instead, it writes a message to a data queue. You can read that data queue from a program to get information about a new job entering the system or an existing job ending.
Your other requirement was to know when a job gets held or gets stuck at message waiting (“MSGW”) status. Since you can get the job’s identification from the Job Notification data queue, you can then call the QUSRJOBI API to retrieve its status. You’ll want to check at regular intervals until the job ends.
For this week’s APIs by Example newsletter, Carsten Flensburg has written a utility that does that.