如何自動監控 QSYSOPR message queue 內的硬體重要 Attention 訊息?
此範例自動監控含有 *Attention* 訊息的系統硬體相關錯誤訊息 Message ID,並將之傳送到所指定人員的 Message queue 及 e-mail 信箱。
File : QCLSRC
Member : MONSYSOPRC
Type : CLP
Usage : CRTCLPGM MONSYSOPRC
CALL MONSYSOPRC 將自動 SBMJOB CMD(MONSYSOPRC) JOB(MONSYSOPRC) JOBQ(QCTL)
若要將此 MONSYSOPRC Job 結束,在 WRKACTJOB 畫面,於 QCLT subsystem 中
MONSYSOPRC Job 前,選擇 option '4',即可將之結束。
/*-----------------------------------------------------------------*/
/* MONSYSOPRC- BATCHING PROGRAM */
/*-----------------------------------------------------------------*/
PGM +
DCL &JOBTYPE *CHAR 1
DCL &ERRMSG *CHAR 512
DCL &MSG *CHAR 512
DCL &MSGID *CHAR 7
DCL &MSGKEY *CHAR 4
DCL &MSGQ *CHAR 10 'QSYSOPR '
DCL &MSGQLIB *CHAR 10 '*LIBL '
DCL &RCVMSGTYPE *CHAR 2
DCL &SENDER *CHAR 80
DCL &SNDJOB *CHAR 10
DCL &RQS *CHAR 2 '08'
DCL &RQS_PMPT *CHAR 2 '10'
MONMSG CPF0000 EXEC( GOTO ERROR )
RTVJOBA TYPE(&JOBTYPE)
IF (&JOBTYPE *EQ '1') DO
SBMJOB CMD(CALL PGM(MONSYSOPRC)) JOB(MONSYSOPRC) +
JOBQ(QCTL)
GOTO END
ENDDO
START:
RCVMSG MSGQ(QSYSOPR) WAIT(*MAX) RMV(*NO) MSG(&MSG) +
MSGID(&MSGID) SENDER(&SENDER) +
RTNTYPE(&RCVMSGTYPE)
IF ((&MSGID *EQ CPPEA01) *OR +
(&MSGID *EQ CPPEA02) *OR +
(&MSGID *EQ CPPEA03) *OR +
(&MSGID *EQ CPPEA04) *OR +
(&MSGID *EQ CPPEA05) *OR +
(&MSGID *EQ CPPEA06) *OR +
(&MSGID *EQ CPPEA10) *OR +
(&MSGID *EQ CPPEA11) *OR +
(&MSGID *EQ CPPEA12) *OR +
(&MSGID *EQ CPPEA13) *OR +
(&MSGID *EQ CPPEA14) *OR +
(&MSGID *EQ CPPEA26) *OR +
(&MSGID *EQ CPPEA28) *OR +
(&MSGID *EQ CPP1604) *OR +
(&MSGID *EQ CPP8982) *OR +
(&MSGID *EQ CPP8983) *OR +
(&MSGID *EQ CPP8984) *OR +
(&MSGID *EQ CPP8985) *OR +
(&MSGID *EQ CPP8986) *OR +
(&MSGID *EQ CPP8987) ) DO
SNDPGMMSG MSGID(&MSGID) MSGF(QCPFMSG) TOUSR(CHANCY)
SNDDST TYPE(*LMSG) TOINTNET((vengoal@ddsc.com.tw)) +
DSTD('Emergency Event') LONGMSG(&MSGID +
*BCAT &MSG)
ENDDO
GOTO START
END:
RETURN
ERROR:
RCVMSG MSGTYPE( *EXCP ) +
MSG( &ERRMSG )
CHGVAR &ERRMSG ( 'ERROR:' |> &ERRMSG )
SNDBRKMSG MSG( &ERRMSG ) +
TOMSGQ( &SNDJOB )
ENDPGM
在執行 CALL MONSYSOPRC 後 執行測試程式 TSTMONSYSC,
File : QCLSRC
Member : TSTMONSYSC
File : CLP
Usage : CRTCLPGM TSTMONSYSC
: CALL TSTMONSYSC
PGM
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('This is +
test message') TOUSR(*SYSOPR) MSGTYPE(*INFO)
SNDPGMMSG MSGID(CPPEA12) MSGF(QCPFMSG) TOUSR(*SYSOPR) +
MSGTYPE(*DIAG)
ENDPGM
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期三, 11月 01, 2023
2002-01-14 如何自動監控 QSYSOPR message queue 內的硬體重要 Attention 訊息?
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言