iSeries Navigator Job Monitor
March 21, 2007 Bruce Guetzkow
Note: The code accompanying this article can be downloaded here
As the only developer in a small company, I try to find ways to make the computer work so I don’t have to. We don’t have an operator and no one is dedicated to monitoring the QSYSOPR message queue, so when problems happen, I need a way to be notified, wherever I am. I’ve tried a couple of programming solutions that captured information from the WRKACTJOB screen, but there were always conditions that I didn’t anticipate and weren’t captured by those methods.
Then I learned about Monitors in iSeries Navigator Management Central. With a Job Monitor, I can let the iSeries check specified jobs for indicated conditions, and when one occurs have it execute a command of my choice to notify me of the problem. In my case, I am more concerned about batch jobs, as those problems tend to go unnoticed until a backlog occurs. Here’s how you can set up a Job Monitor for your own use.
Creating a Monitor
Begin by starting iSeries Navigator. Navigator is IBM‘s graphical tool for administering the iSeries. Expand the Management Central section and you will find a sub-section called Monitors. Expand Monitors to reveal the different types available. Although this discussion is about Job Monitors, the concepts are similar for each type.
If you click on Job, you may see a sample Monitor supplied by IBM. You can right-click on the monitor and select Properties to see the specifics. For our purposes, I will be creating a new Monitor. A new Monitor can be created by right-clicking on Job and selecting New Monitor. There is also an option on the File menu and an icon just below the menu. Selecting New Monitor opens up a tabbed-window where characteristics can be specified. Start on the General tab by giving the Monitor a name, such as Batch Jobs. The name and description fields are required and you can not proceed to other tabs unless these are filled in.
On the General tab, you specify which jobs to monitor. You can select jobs by any combination of Job Name, User, Subsystem and Job Type. You can be as broad or narrow as you like with your selections. Choose from available drop-down options or type over. When you have a combination that suits your needs, click on the Add button. You can add multiple selections. If any job that meets any of your criteria is affected, rules on subsequent tabs will be applied. There is also a tab labeled Servers to Monitor. I won’t go into that here, but take a look for options to consider for additional Monitors.
After you have completed entering on the General tab, select the Metrics tab. Here you specify the conditions to monitor for. For our Batch Job Monitor, I selected Job Status and clicked on Add. This changes the bottom half of the window to reveal Job Status options to monitor for. Scroll through the list and you will find the option Waiting for Message. This means that the Monitor will be looking for jobs with a status of MSGW. You can select as many conditions as you like.
There is a tab on the lower half of this window labeled Status Threshold. Here you can indicate how many times the condition must occur before an action is triggered and when the Monitor should be reset so that the condition can be monitored in the future. You can also specify an i5/OS command to be executed when the condition is triggered. I’ll go into more detail on this later.
The Collection Interval tab indicates how often the jobs will be polled for the indicated conditions. The default is 15 minutes. Specifying a shorter time can have a performance impact on your system, so use caution when changing this value. You can also specify different intervals based on different metric types. I haven’t had a need to use that feature, but in my case I am only looking at one type of metric (Job Status). If you choose to use multiple metric types these options should be considered.
Next is the Action tab. Here you indicate Navigator actions that should occur when the condition is triggered and when the Monitor is active. If you specified a command on the Metrics tab, i5/OS Command is checked and that option cannot be changed. Opening the Monitor and sounding an alarm can only happen if the event is triggered while Navigator is running. If you always have Navigator running during the day, these settings may be of value.
The Systems and Groups tab is where you specify which iSeries servers this Monitor will run on. If you have multiple iSeries servers, you can define a Monitor and have it execute on all servers that you deem appropriate. There is a Browse button that provides a list of the systems available.
The final tab is called Sharing. Monitors normally can only be viewed and maintained by the person who defined them. You can change this behavior based on the setting you choose.
Click on OK to create the Monitor. You will return to the list of Monitors where you will see your Monitor has been added. The Status column should indicate Stopped at this time, meaning that this Monitor is not yet active. You can start monitoring jobs by selecting the Monitor and selecting the Start icon, or right-clicking and selecting Start. There is also a Start option on the File menu.
Before you do this, I recommend one change to your Monitor. In releases prior to OS/400 V5R2, when an IPL was done, you needed to manually restart your Monitors–meaning, they didn’t restart automatically. At V5R2, a feature was added to automatically restart a Monitor. If you don’t remember seeing a check-box on any of the tabs, that’s because there isn’t one. Instead, you need to change the name of your Monitor by adding a single blank and the string &RESTART (in upper case) at the end of your Monitor name.
Specify a Command
Now back to the i5/OS command I mentioned earlier. We’ve identified the jobs we want to monitor, what to monitor for, how often and what Navigator functions (if any) to perform. So, if I don’t have Navigator open all day long (and all night!), how do I get the Monitor to tell me there’s a problem?
That’s where the command comes in. You can specify any valid i5/OS command, including one you’ve created yourself, and you can even pass some job information as command parameters. You could use something as simple as the Send Message (SNDMSG) command. Of course, you will only get the message if you happen to be signed on at the time. I’ve created a command that does the following:
I’ve included a version of that command that you can use (see the link at the top of this article for that). I had to modify it for this publication because we use a third-party tool to send emails from the iSeries. I have labeled that part of the code as an “Alternate Plan.” You’ll have to determine what course of action to take if no one is signed on.
There are four source members included in the code:
Compile instructions are included in each member and they should be compiled in the order listed above. Remember to review the section of the command processing program labeled “Alternate Plan”. In the area labeled i5/OS trigger command, enter:
SNDMONMSG MONITOR('&MON') JOBNAME(&JOBNAME) JOBUSER(&JOBUSER) JOBNUMBER(&JOBNUMBER) MSGID(&MSGID)
For more information on Monitors, click on Help on any tab. If you click Help on the Metrics tab, then click Thresholds for Job Log Message, then i5/OS commands, you will see a list of all variables that can be passed from a Monitor.
Now you can sleep peacefully, knowing that someone is carefully watching your iSeries for you.