如何檢查系統中每個 Job 的 Temporary Storage(qtemp sapce) 大小?(使用 API QUSLJOB)
於系統中的每個 Job 均有自己的 QTEMP 程式館,由於開關機時間不一,會導致系統的
temp space 逐漸增加,若能定時作開關機動作,則系統會自動釋放出 temp space 空間
,但由於作業需求有可能無法常常作開關機動作,此時若某些 AP 作業由於未考慮周詳,
QTEMP 中的 temp space 有可能暴增,此時系統作業效率下降,唯一的解決方式就是將系
統關機在開機,系統才會自動釋放出 temp space 空間,但你並很難確切指出哪一個 Job
使用多少的 temp space,找出問題所在。這裡我提供一個指令 CHKTMPSTG (Check Temporary
Storage) 依照所想檢查的 temp space Mb 大小並利用 API QUSLJOB 列出取得符合檢查條
件的每一個Job。
File : QRPGLESRC
Member: CHKTMPSTGR
Type : RPGLE
Usage : CRTBNDRPG CHKTMPSTG
**********************************************************************************************
* CHKTMPSTG: Check jobs for Temporary storage over 50Mb
**********************************************************************************************
**********************************************************************************************
* Data Structures
**********************************************************************************************
* Standard error code DS for API error handling
D Error_Code DS
D BytesProvd 10I 0 INZ(0)
D BytesAvail 10I 0 INZ(0)
D Except_ID 7
D Reserved 1
D Exception 256
* Receiver value DS for user space header info
* (used in first call to QUSRTVUS)
D GenRcvrDS DS
D UserArea 64
D GenHdrSize 10I 0
D StrucLevel 4
D FormatName 8
D APIUsed 10
D CreateStamp 13
D InfoStatus 1
D SizeUsUsed 10I 0
D InpParmOff 10I 0
D InpParmSiz 10I 0
D HeadOffset 10I 0
D HeaderSize 10I 0
D ListOffset 10I 0
D ListSize 10I 0
D ListNumber 10I 0
D EntrySize 10I 0
*****************************************************************
* Type Definition for the JOBL0100 format.
*****************************************************************
D ListDataDS DS
D L_JobName 10
D L_JobUser 10
D L_JobNbr 6
D L_JobIdent 16
D L_Status 10
D L_JobType 1
D L_JobSubTy 1
D L_Reserved 2
D L_JobInfoSts 1
D L_Reserved2 3
D L_NbrFldsRtn 10I 0
D L_LenInfoRtn 10I 0
D L_KeyFld 10I 0
D L_DataType 1
D L_Reserved3 3
D L_LenDataRtn 10I 0
D L_KeyValue 10I 0
**********************************************************************************************
* Field definitions
**********************************************************************************************
D DataLength S 10I 0 INZ(140)
D CurrentEnt S 5P 0 INZ(1)
D ExtendAttr S 10 INZ('USRSPC ')
D InitialSiz S 10I 0 INZ(1024)
D InitialVal S 1 INZ(X'00')
D JobStatus S 10 INZ('*ACTIVE ')
D JobType S 1 INZ('*')
D ListFormat S 8 INZ('JOBL0200')
D NbrToRtn S 10I 0 INZ(1)
D KeysToRtn S 10I 0 INZ(2009)
D P_DataLength S 10I 0
D P_MsgData S 512
D P_MsgFile S 20 INZ('QCPFMSG *LIBL')
D P_MsgID S 7 INZ('CPDA0FF')
D P_MsgKey S 4
D P_MsgType S 10
D P_PgmQueue S 10
D P_PgmStack S 10I 0
D PublicAut S 10 INZ('*ALL ')
D QualifyJob S 26 INZ('*ALL *ALL *ALL ')
D ReplaceSpc S 10 INZ('*YES ')
D StartPos S 10I 0 INZ(1)
D TextDescrp S 50 INZ('User space for List Job API')
D UserSpace S 20 INZ('CHKTMPSTG QTEMP ')
D StgLmtChk S 5 0 INZ(50)
**********************************************************************************************
* MAINLINE:
**********************************************************************************************
C *ENTRY PLIST
C PARM iStgLmtChk 5 0
C EVAL StgLmtChk = iStgLmtChk
**********************************************************************************************
* Create a user space to hold the job list entries
C CALL 'QUSCRTUS'
C PARM UserSpace
C PARM ExtendAttr
C PARM InitialSiz
C PARM InitialVal
C PARM PublicAut
C PARM TextDescrp
C PARM ReplaceSpc
C PARM Error_Code
* List all the jobs on the system
C CALL 'QUSLJOB'
C PARM UserSpace
C PARM ListFormat
C PARM QualifyJob
C PARM JobStatus
C PARM Error_Code
C PARM JobType
C PARM NbrToRtn
C PARM KeysToRtn
* Get the header info for this space
C CALL 'QUSRTVUS'
C PARM UserSpace
C PARM StartPos
C PARM DataLength
C PARM GenRcvrDS
C PARM Error_Code
* Check to see if any entries returned
B001 C IF ListNumber > 0
* Set the initial offset for the start of the list entries
C EVAL ListOffset = ListOffset + 1
* Loop through the entries held in the list section of the user space
B002 C DOW CurrentEnt <= ListNumber
* Get the header info for this space
C CALL 'QUSRTVUS'
C PARM UserSpace
C PARM ListOffset
C PARM EntrySize
C PARM ListDataDS
C PARM Error_Code
*
B003 C IF L_KeyValue > StgLmtChk
C EVAL P_MsgData = 'Job ' + L_JobNbr + '/' +
C %TRIM(L_JobUser) + '/' + %TRIM(L_JobName) +
C ' is using temp storage of ' +
C %EDITC(L_KeyValue : 'Z') + 'Mb'
C
C EVAL P_DataLength = 78
C EVAL P_PgmStack = 0
C EVAL P_PgmQueue = '*EXT'
C EVAL P_MsgType = '*INFO'
*
C CALL (E) 'QMHSNDPM'
C PARM P_MsgID
C PARM P_MsgFile
C PARM P_MsgData
C PARM P_DataLength
C PARM P_MsgType
C PARM P_PgmQueue
C PARM P_PgmStack
C PARM P_MsgKey
C PARM Error_Code
E003 C ENDIF
* Bump up the counter & offset for the next entry
C EVAL ListOffset = ListOffset + EntrySize
C EVAL CurrentEnt = CurrentEnt + 1
E002 C ENDDO
E001 C ENDIF
*
C EVAL *INLR = *ON
C RETURN
File : QCMDSRC
Member: CHKTMPSTG
Type : CMD
Usage : CRTCMD CMD(CHKTMPSTG) PGM(*LIBL/CHKTMPSTGR)
CHKTMPSTG TMPSTG(50) 顯示 temp space 大於 50 Mb 的 Job
/********************************************************************/
/* Title: CHKTMPSTG: Check jobs for Temporary storage */
/* */
/* Description - This command performs the machine temporary */
/* storage checked in every job. */
/* */
/* The Create Command command should include the following: */
/* */
/* CRTCMD CMD(CHKTMPSTG) PGM(CHKTMPSTGR) */
/* */
/********************************************************************/
/*------------------------------------------------*/
/* Command Definition */
/*------------------------------------------------*/
Cmd Prompt('Check Temporary Storage')
/*------------------------------------------------*/
/* Parameter Definition */
/*------------------------------------------------*/
PARM KWD(TMPSTG) TYPE(*DEC) LEN(5 0) DFT(50) +
REL(*GT 0) PROMPT('Temp Storage greater +
than (Mb)')
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期四, 11月 02, 2023
2002-10-07 如何檢查系統中每個 Job 的 Temporary Storage(qtemp sapce) 大小?(使用 API QUSLJOB)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言