This week's API by Example from Carsten Flensburg provides a sample program showing how to use the QRYOLJOB API to fetch the CPU usage for all active jobs. For each job using more than 50 percent of the available interactive processor resources, the program sends a message to the message queue of the user currently running the CPU-intensive program.
The sample RPG IV program uses the following APIs:
Open List of Jobs (QGYOLJOB)
This API generates a list of jobs on the system based on specified selection
criteria.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/qgyoljob.htm
Retrieve Call Stack (QWVRCSTK)
QWVRCSTK returns the call stack information for the specified thread.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/qwvrcstk.htm
Send Nonprogram Message (QMHSNDM)
This API sends a message to a nonprogram message queue so your program can
communicate with another job or user.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/QMHSNDM.htm
Get List Entries (QGYGTLE)
QGYGTLE allows requests to get entries from previously opened lists on the
iSeries server. A list will exist if an initial request has already been
made and the list was not closed using the Close List (QGYCLST) API.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/qgygtle.htm
Close List (QGYCLST)
This closes a previously opened list.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/qgyclst.htm
Materialize Resource Management Data (MATRMD)
This API materializes the resource management data.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/sm18/c0924180.pdf
Copy Bytes (MEMMOVE)
MEMMOVE copies count bytes of src to dest. This function allows copying
between objects that may overlap as if src is first copied into a temporary
array.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/books/c4156071.pdf
sleep(), Suspend Processing for Interval of Time
This suspends a thread for a specified number of seconds.
http://publib.boulder.ibm.com/iseries/v5r2/ic2924/info/apis/sigsleep.htm
You can obtain the RPG IV program at
http://www.iseriesnetwork.com/noderesources/code/clubtechcode/LstCPUHogs.zip.
The above source code was written by Carsten Flensburg. For questions regarding this tip, contact Carsten at mailto:flensburg@novasol.dk.