Bookmark and Share
RSS

Recent Posts

Search the Job Log of an Active Job

May 31, 2018

Job logs for ended jobs, where the job log is in a spooled file, are easy to search on the green screen. When viewing the spooled job log, you simply enter your search text in the find field and press F16. In addition, you can use F14 to limit the columns in which your search is performed, then press F16 to search.
 
However, when using the green screen, there is no find field when viewing the job log of an active job. Jobs with pending job logs have a similar problem.
 
There are two alternatives to view the job log that also have the ability to search. This is an example where IBM has provided improved management functionality unavailable with a 5250 session.
 
Navigator for i
 
Using Navigator for i, you can easily view the job logs of active jobs. Simply go to Work Management --  Active Jobs and right click on the desired job and select the Job Log option. 

iCan-1.jpg
 
You can find active jobs in other ways as well, such as Server Jobs, jobs in an active memory pool, or jobs in an active subsystem.
 
To find a job that has *PNDING output, you need to explicitly find the job. Basic Operations -- User Jobs is an easy way to find sets of jobs. Go into the Include… dialog, select the job of interest, and (optionally) turn off the “Active Jobs” status. Make sure to leave the “Completed Job with output” status selected. 
iCan-2.jpg
 
iCan-3.jpg

Jobs with pending job logs have a status of “Completed - Job log pending”.
 
 
Regardless of how you find the job, Navigator has a number of useful features for reviewing jobs logs.

iCan-4.jpg
 
  • There is a search box to search the job log.
    The search results are immediate; just start typing and the table is updated dynamically with the search results.  Do not press enter.
  • You can specify filter criteria.
    The arrows to the right of the search box bring up a filter dialog that allows you to specify criteria for the search.  You can limit the search by column, including, excluding, starting with, ending with, etc.
 
iCan-5.jpg
 
  • The most recent messages are at the top. 
    When I’m looking at a job log, I often want to see what happened recently.  Sure, there are times when I want to see what happened at the start of the job (there are often interesting messages logged at the beginning of the job log), but if I’m investigating a problem, the most recent messages are generally more interesting.
  • You can add more information to the job log table with the Columns… dialog and easily search on additional fields such To Program or From Program. On the green screen, you can only see these additional fields by pressing F1 to see the message details.
 
iCan-6.jpg
 
 
JOBLOG_INFO IBM i Service
 
The QSYS2.JOBLOG_INFO service allows you to use SQL to access the job log of an active job or a job whose output is pending. With this service, you can get at even more information in the job log, including the second level text of the message.
 
Using Run SQL Scripts in ACS, you can easily look at the job log of a specific job with the following SQL statement, which gives you all of the available columns of information.
 
SELECT * FROM TABLE(QSYS2.JOBLOG_INFO('156616/Quser/Qzdasoinit')) A;
 
This next example, which is provided as an example on the QSYS2.JOBLOG_INFO developerWorks page, retrieves the last command entered by a specific interactive user:
 
SELECT MESSAGE_TEXT FROM TABLE(QSYS2.JOBLOG_INFO('200836/dawnm/Dawnmaya0')) A
  WHERE A.MESSAGE_TYPE = 'REQUEST' 
  ORDER BY ORDINAL_POSITION DESC
  FETCH FIRST 1 ROW ONLY;
 
 
These are very simple examples. With IBM i Services, you can create more complex queries to get more specific with your searches. Perhaps you want to see all the messages with a severity greater than 70, search for specific text in a message, find messages from a specific program—whatever you have a need to find in a job log, the JOBLOG_INFO service is a powerful way to do so.
 
You can combine services as well - you can use the QSYS2.ACTIVE_JOB_INFO service to select which jobs you are interested in, then combine it with the QSYS2.JOBLOG_INFO service to find out which jobs had some information logged to their job log. In your shops, you may have information logged to a number of job logs that you want to search; IBM i Services provide you a tool to do that.
 
Here’s a contrived example:
I want to find all the primary jobs for the HTTP server instances on the lab system that was used for the Spring COMMON conference. This SQL statement looks at all the active jobs in the QHTTPSVR subsystem, checking the job logs for the HTP8084 message (“This is the primary job for HTTP Server instance &1”), and parses the fully qualified job name so the results can be sorted on the simple job name.
 
WITH TT(AUTHORIZATION_NAME, FQ_JOB_NAME, JOB_NAME, CPU_TIME)
    AS (SELECT AUTHORIZATION_NAME, JOB_NAME, SUBSTR(SUBSTR(JOB_NAME,8),POSSTR(SUBSTR(JOB_NAME,8),'/')+1)  AS JOB_NAME, CPU_TIME
            FROM TABLE(QSYS2.ACTIVE_JOB_INFO(SUBSYSTEM_LIST_FILTER => 'QHTTPSVR')) X)
    SELECT AUTHORIZATION_NAME, SS.MESSAGE_TEXT, FQ_JOB_NAME, JOB_NAME, CPU_TIME
        FROM TT, TABLE(QSYS2.JOBLOG_INFO(FQ_JOB_NAME)) SS
        WHERE MESSAGE_ID = 'HTP8084' 
        ORDER BY JOB_NAME ASC LIMIT 25;
 
Below is what was returned from this query:

iCan-7.jpg
 
I know many of us live and die by our green screens, but Navigator and IBM i Services have much more flexibility for IBM i management.

For the sake of completeness, I want to note the following:
  • Watches
    Don’t forget about watches. While watches are not intended to search a job log for a text string, they can be very useful for being notified when specific messages are sent to a job log.
  • IBM i Access Client Solutions
    IBM i Access Client Solutions does not have ability to access the job logs of active jobs or pending job logs; you can only view printed output, which means spooled files on output queues. 

Posted May 31, 2018| Permalink

Post a Comment

Note: Comments are moderated and will not appear until approved

comments powered by Disqus