星期四, 11月 09, 2023

2016-02-02 即時監控工作站錯誤訊息 CPF5140,並終止該工作站


即時監控工作站錯誤訊息 CPF5140,並終止該工作站

Monitor interactive job which got CPF5140 error message and end it
即時監控工作站錯誤訊息 CPF5140,並終止該工作站。
因為使用者有時會因等待輸入暫停過久,直接將5250工作站直接點擊右上角關閉方塊,
此時系統會拋出 CPF5140 錯誤,此時若該工作站正執行大量資料的存取,系統仍會繼續
執行,但最終仍無法傳回資訊,導致系統浪費資源,要防止此狀況發生,就須即時監控並
終止該工作站 JOB。


File  : QCLSRC
Member: WCHCPF5140
Type  : CLP
Usage : CRTCLPGM PGM(QGPL/WCHCPF5140)
        Start 
		  STRWCH SSNID(WCHCPF5140) WCHPGM(QGPL/WCHCPF5140)                 
          WCHMSG((CPF5140))                                         
          WCHMSGQ((*JOBLOG))                                        
          WCHJOB((*ALL/*ALL/*ALL))
		End
		  WRKWCH *ALL use option 2 to End Watch
		
        




/* ================================================================ */
/*                                                                  */
/* Program    : WCHCPF5140                                          */
/*                                                                  */
/* Description: Monitor interactive job which got CPF5410           */
/*              and end it to prevent system from high CPU usage    */
/*                                                                  */
/* Date       : 2016/02/01                                          */
/*                                                                  */
/* Author     : Vengoal Chang                                       */
/* ================================================================ */
/*                                                                  */
/*                                                                  */
/* CRTCLPGM PGM(WCHCPF5140)                                         */
/*                                                                  */
/*                                                                  */
/* STRWCH SSNID(WCHCPF5140) WCHPGM(QGPL/WCHCPF5140)                 */
/*        WCHMSG((CPF5140))                                         */
/*        WCHMSGQ((*JOBLOG))                                        */
/*        WCHJOB((*ALL/*ALL/*ALL))                                  */
/*                                                                  */
/* ================================================================ */

     Pgm        Parm(&Type &Session &Error &Data)
     Dcl        Var(&Type)      Type(*Char) Len(10)
     Dcl        Var(&Session)   Type(*Char) Len(10)
     Dcl        Var(&Error)     Type(*Char) Len(10)
     Dcl        Var(&Data)      Type(*Char) Len(2000)

     Dcl        Var(&LenEvtDta) Type(*Int)  Len(4) +
                     Stg(*Defined) DefVar(&Data   1)
     Dcl        Var(&Job)       Type(*Char) Len(10) +
                     Stg(*Defined) DefVar(&Data 33)
     Dcl        Var(&User)      Type(*Char) Len(10) +
                     Stg(*Defined) DefVar(&Data 43)
     Dcl        Var(&Nbr )      Type(*Char) Len( 6) +
                     Stg(*Defined) DefVar(&Data 53)
     Dcl        Var(&MSGID)     Type(*Char) Len(7) +
                     Stg(*Defined) DefVar(&Data 5)
     Dcl        Var(&MsgF)      Type(*Char) Len(10) +
                     Stg(*Defined) DefVar(&Data 391)
     Dcl        Var(&MsgFLib)   Type(*Char) Len(10) +
                     Stg(*Defined) DefVar(&Data 401)
     Dcl        Var(&OffRplDta) Type(*Int)  Len(4) +
                     Stg(*Defined) DefVar(&Data 441)
     Dcl        Var(&LenRplDta) Type(*Int)  Len(4) +
                     Stg(*Defined) DefVar(&Data 445)
     Dcl        Var(&OrgLenRpl) Type(*Int)  Len(4) +
                     Stg(*Defined) DefVar(&Data 59)

     Dcl        Var(&MsgDtaPtr) Type(*Ptr)
     Dcl        Var(&MsgDta)    Type(*Char) Len(1010) +
                     Stg(*Based)   BasPtr(&MsgDtaPtr)

     /* CPF5140 char data */
     Dcl        Var(&MsgUser  )    Type(*Char) Len(10) +
                     Stg(*Defined) DefVar(&MsgDta  1)
     Dcl        Var(&Host     ) Type(*Char) Len(255) +
                     Stg(*Defined) DefVar(&MsgDta 11)

     Dcl        Var(&QualMsgf)   Type(*Char) Len(20)
     Dcl        Var(&MsgTxt )    Type(*Char) Len(1024)
     Dcl        Var(&Rtvm0100  ) Type(*Char) Len(1024)
     Dcl        Var(&RplDta )    Type(*Char) Len(1024)
     Dcl        Var(&SysValTo)   Type(*Char) Len(500)
     Dcl        VAR(&MsgTxtLenC) Type(*Char) Len(4)
     Dcl        VAR(&MsgTxtLen ) Type(*Dec ) Len(5 0)
     Dcl        VAR(&RplDtaLenC) Type(*Char) Len(4)
     Dcl        VAR(&ErrCode)    Type(*Char) Len(15) /* Error Code */

/* Check to make sure this is a *MSGID watch                         */
    If         Cond(&Type = '*MSGID') Then(Do)
/* Check to make sure this is for CPF5140                            */

     If      Cond(&MsgID = 'CPF5140') Then(Do)

             ChgVar Var(&MsgDtaPtr) Value(%Addr(&Data))
             Chgvar Var(%Offset(&MsgDtaPtr)) +
                    Value(%Offset(&MsgDtaPtr) + &OffRplDta)

             ChgVar &RplDta       %sst(&MsgDta 1 &LenRplDta)
             ChgVar &QualMsgf     (&MsgF *Cat &MsgFLib)

             ChgVar     %BIN(&MSGTXTLENC)        1024
             ChgVar     %BIN(&RplDtaLenC)        &LenRplDta
             ChgVar     %BIN(&ErrCode     1  4)    15
             Call       QMHRTVM ( +
                                 &Rtvm0100               +
                                 &MsgTxtLenC             +
                                 'RTVM0100'              +
                                 &MSGID                  +
                                 &QUALMSGF               +
                                 &RplDta                 +
                                 &RplDtaLenC             +
                                 '*YES      '            +
                                 '*NO       '            +
                                 &Errcode)

             ChgVar &MsgTxtLenC    %SST(&Rtvm0100  9 4)
             ChgVar &MsgTxtLen     %BIN(&MsgTxtLenC)
             ChgVar &MsgTxt (&MSGID *CAT ':' *BCAT               +
                             %SST(&Rtvm0100 25 &MsgTxtLen) *BCAT  +
                             'Job ' *BCAT    +
                      &Nbr *CAT '/' *CAT &User *Tcat '/' *CAT &Job +
                      *BCAT 'was ended by watch program')

             EndJob     Job(&NBR/&USER/&JOB) Option(*IMMED)
             MonMsg     CPF0000
             SndPgmMsg  MsgId(CPF9898) Msgf(QCPFMSG) MsgDta(&MsgTxt) +

                          ToUsr(*SYSOPR)

     EndDo

    EndDo /* End If &Type = *MSGID */

    ChgVar       Var(&Error) Value('          ')
    EndPgm



						
						


參照: STRWCH - Watch Exit Programs Explained with CL Example





沒有留言: