Seeing which jobs use the most CPU

Log in to save
SELECT JOB_NAME, AUTHORIZATION_NAME, SUBSYSTEM,
       ELAPSED_CPU_PERCENTAGE, CPU_TIME, FUNCTION
  FROM TABLE(QSYS2.ACTIVE_JOB_INFO(RESET_STATISTICS => 'YES'))
 WHERE JOB_TYPE <> 'SYS'
 ORDER BY ELAPSED_CPU_PERCENTAGE DESC
 FETCH FIRST 15 ROWS ONLY

To look at a single subsystem:

SELECT JOB_NAME, ELAPSED_CPU_PERCENTAGE, FUNCTION
  FROM TABLE(QSYS2.ACTIVE_JOB_INFO(SUBSYSTEM_LIST_FILTER => 'QBATCH'))
 ORDER BY ELAPSED_CPU_PERCENTAGE DESC

Note

ELAPSED_CPU_PERCENTAGE is the percentage over the interval since the last reset, not since the job started. With RESET_STATISTICS => 'YES' you reset it and run the query again a few seconds later: that is how you see who is consuming now, rather than who has consumed in total.

Tip

the FUNCTION column says where the job is — which program or command it is running. On a stalled job it is often the only information needed.


Releases. QSYS2.ACTIVE_JOB_INFO is available from 7.1, but the named parameters were added over time: RESET_STATISTICS and SUBSYSTEM_LIST_FILTER are not on older releases. If the call is rejected, run the function with no parameters — TABLE(QSYS2.ACTIVE_JOB_INFO()) — and filter in the WHERE clause.

← Back to blog

Comments

No comments yet. Be the first to comment!

You need an account to comment. Log in · Sign up