Created
April 12, 2011 19:14
-
-
Save MikeWills/916185 to your computer and use it in GitHub Desktop.
Monitor for MSGW jobs on an IBM i. This example uses MAILTOOL, but also has for the built-in SNDDST.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ********************************************************************** */ | |
/* Program . . . . . ALERT */ | |
/* */ | |
/* Created on . . . 04/09/2010 */ | |
/* by . . . Mike Wills (http://mikewills.me) */ | |
/* */ | |
/* Description . . . */ | |
/* */ | |
/* CHANGE LOG: */ | |
/* Date | Name | Description */ | |
/* ---------------------------------------------------------------------- */ | |
/* | | */ | |
/* | | */ | |
/* | | */ | |
/* ************************************************************************/ | |
PGM PARM(&STS) | |
DCL VAR(&ERROR) TYPE(*CHAR) LEN(1) | |
DCL VAR(&STS) TYPE(*CHAR) LEN(4) | |
DCL VAR(&TXT) TYPE(*CHAR) LEN(60) | |
DCL VAR(&TIME) TYPE(*CHAR) LEN(6) | |
DCL VAR(&STOPTIME) TYPE(*CHAR) LEN(6) + | |
VALUE('200000') | |
ADDLIBLE LIB(MAILTOOL) | |
MONMSG MSGID(CPF0000) | |
START: | |
OVRPRTF FILE(QPDSPAJB) HOLD(*YES) | |
WRKACTJOB OUTPUT(*PRINT) | |
DLTOVR FILE(QPDSPAJB) | |
CHKOBJ OBJ(QTEMP/ALERTJOB) OBJTYPE(*FILE) | |
MONMSG MSGID(CPF9801) EXEC(DO) | |
CRTPF FILE(QTEMP/ALERTJOB) RCDLEN(132) | |
ENDDO | |
CPYSPLF FILE(QPDSPAJB) TOFILE(QTEMP/ALERTJOB) + | |
SPLNBR(*LAST) | |
DLTSPLF FILE(QPDSPAJB) SPLNBR(*LAST) | |
CALL PGM(QGPL/ALERTW) PARM(&STS &ERROR &TXT) | |
IF COND(&ERROR *EQ '1') THEN(DO) | |
MAILTOOL TOADDR('[email protected]') + | |
FROMADDR('[email protected]') + | |
SUBJECT(&TXT) | |
/*SNDDST TYPE(*LMSG) + | |
TOINTNET(([email protected])) + | |
DSTD('alert') LONGMSG(B) SUBJECT(&TXT) */ | |
SNDBRKMSG MSG(&TXT) TOMSGQ(WRKSTN1 WRKSTN2) | |
/*GOTO CMDLBL(END) */ | |
ENDDO | |
RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME) | |
IF COND(&TIME *GE &STOPTIME) THEN(GOTO CMDLBL(END)) | |
DLYJOB DLY(180) | |
GOTO CMDLBL(START) | |
END: | |
ENDPGM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ********************************************************************** */ | |
/* Program . . . . . ALERTW */ | |
/* */ | |
/* Created on . . . 04/09/2010 */ | |
/* by . . . Mike Wills (http://mikewills.me) */ | |
/* */ | |
/* Description . . . */ | |
/* */ | |
/* CHANGE LOG: */ | |
/* Date | Name | Description */ | |
/* ---------------------------------------------------------------------- */ | |
/* | | */ | |
/* | | */ | |
/* | | */ | |
/* ************************************************************************/ | |
PGM PARM(&STS &ERROR &TXT) | |
DCL VAR(&STS) TYPE(*CHAR) LEN(4) | |
DCL VAR(&ERROR) TYPE(*CHAR) LEN(1) | |
DCL VAR(&TXT) TYPE(*CHAR) LEN(60) | |
DCLF FILE(QTEMP/ALERTJOB) | |
CHGVAR VAR(&ERROR) VALUE('0') | |
READ: | |
RCVF RCDFMT(ALERTJOB) | |
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END)) | |
IF COND(%SST(&ALERTJOB 116 4) *EQ &STS) THEN(DO) | |
CHGVAR VAR(&ERROR) VALUE('1') | |
CHGVAR VAR(&TXT) VALUE(&STS *CAT ' status : ' *CAT + | |
%SST(&ALERTJOB 29 6) *CAT '/' *CAT + | |
%SST(&ALERTJOB 17 10) *TCAT '/' *CAT + | |
%SST(&ALERTJOB 4 10) *TCAT '!!!') | |
ENDDO | |
GOTO READ | |
END: | |
ENDPGM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment