Return to the iSeriesTools Tips
Monitors the QSYSMSG queue for disabled User profiles
/* */ /* S. Corbett 17 July 2007 */ /* Based on an IBM sample program, this program monitors the */ /* QSYSMSG queue. If a user profile is disable due to too many */ /* attempts to log on, this job waits until a specified length */ /* of time after the profile was disabled (ie 30 minutes) and */ /* then enables that profile. */ /* */ /* This program should be compiled to run with the owner's */ /* authority and the owner should be changed to QSYSOPR. */ /* */ /* Set as a QBATCH autostart entry using: */ /* ADDAJE SBSD(QSYS/QBATCH) JOB(MONQSYSMSG) + */ /* JOBD(IJASUSER/ MONQSYSMSG) */ /* */ PGM DCL &HH *DEC LEN(2 0) DCL &MM *DEC LEN(2 0) DCL &SS *DEC LEN(2 0) DCL &DLY *DEC LEN(6 0) DCL &MSGID *CHAR LEN( 7) DCL &MSGDTA *CHAR LEN(100) DCL &MSG *CHAR LEN(132) DCL &MSGF *CHAR LEN( 10) DCL &MSGFLIB *CHAR LEN( 10) DCL &QDAY *CHAR LEN( 2) DCL &QMONTH *CHAR LEN( 2) DCL &QYEAR *CHAR LEN( 2) DCL &QHOUR *DEC LEN(2 0) DCL &QMINUTE *DEC LEN(2 0) DCL &QSECOND *DEC LEN(2 0) DCL &QTIME *CHAR LEN( 6) DCL &SENDER *CHAR LEN( 80) DCL &SENDDATE *CHAR LEN( 6) DCL &SENDTIME *DEC LEN(6 0) DCL &SYSTIME *DEC LEN(6 0) DCL &USRPRF *CHAR LEN( 10) /* Default wait time, in seconds! */ DCL &WAITTIME *DEC LEN(6 0) Value(600) MONMSG CPF0000 EXEC(GOTO PROBLEM) /*********** ********* ********* ********* ********* ********* **/ /* FETCH MESSAGES FROM QSYSMSG MESSAGE QUEUE */ /*********** ********* ********* ********* ********* ********* **/ LOOP: RCVMSG MSGQ(QSYS/QSYSMSG) MSGTYPE(*INFO) WAIT(*MAX) + RMV(*NO) MSG(&MSG) MSGDTA(&MSGDTA) + MSGID(&MSGID) SENDER(&SENDER) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(EXIT) ) IF (&MSGID *EQ 'CPF1393') /* Disabled profile */ + THEN(DO) /* If not the same date as now, delay by wait time */ RTVSYSVAL SYSVAL(QDAY ) RTNVAR(&QDAY) RTVSYSVAL SYSVAL(QMONTH) RTNVAR(&QMONTH) RTVSYSVAL SYSVAL(QYEAR) RTNVAR(&QYEAR) CHGVAR VAR(&SENDDATE) VALUE(%SST(& SENDER 44 6)) IF COND((&QYEAR *CAT &QMONTH *CAT &QDAY) *NE &SENDDATE) THEN(DO) CHGVAR VAR(&DLY) VALUE(&WAITTIME) ENDDO ELSE CMD(DO) /* Calculate the wait time (we might have been waiting for */ /* profile A to reset when profile B was disabled. */ CHGVAR VAR(&HH) VALUE(%SST(& SENDER 50 2)) CHGVAR VAR(&MM) VALUE(%SST(& SENDER 52 2)) CHGVAR VAR(&SS) VALUE(%SST(& SENDER 54 2)) CHGVAR VAR(&SENDTIME) VALUE((((&HH * 60) + &MM) * 60) + &SS) CHGVAR VAR(&SENDTIME) VALUE(&SENDTIME + &WAITTIME) RTVSYSVAL SYSVAL(QTIME) RTNVAR(&QTIME) CHGVAR VAR(&QHOUR) VALUE(%SST(& QTIME 1 2)) CHGVAR VAR(&QMINUTE) VALUE(%SST(& QTIME 3 2)) CHGVAR VAR(&QSECOND) VALUE(%SST(& QTIME 5 2)) CHGVAR VAR(&SYSTIME) VALUE((((&QHOUR * 60) + + &QMINUTE) * 60) + &QSECOND) CHGVAR VAR(&DLY) VALUE(&SENDTIME - &SYSTIME) ENDDO /* DMPCLPGM */ /* MONMSG MSGID(CPF0000) */ IF COND(&DLY *GT 0) THEN(DO) DLYJOB DLY(&DLY) ENDDO CHGVAR &USRPRF %SST(&MSGDTA 11 10) CHGUSRPRF USRPRF(&USRPRF) STATUS(*ENABLED) MONMSG MSGID(CPF0000) EXEC(DO) SNDPGMMSG MSG('Attempt to re-enable user ' *CAT &USRPRF + *BCAT 'has failed') TOMSGQ(STEVE) DMPCLPGM ENDDO SNDPGMMSG MSG('User ' *CAT &USRPRF *BCAT 'has been + enabled automatically' ) TOMSGQ(QSYSOPR) MONMSG MSGID(CPF0000) ENDDO ELSE DO /*********** ********* ********* ********* ********* ********* / /* Other message - Resend to QSYSOPR */ /*********** ********* ********* ********* ********* ********* / IF (&MSGID *NE ' ') THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/ &MSGF) + MSGDTA(&MSGDTA) TOMSGQ(STEVE) /* SNDPGMMSG would fail if the message does */ /* not have a MSGID or is not in QCPFMSG */ MONMSG MSGID(CPF0000) /* MONMSG MSGID(CPF0000) + EXEC(SNDPGMMSG MSG(&MSG) TOMSGQ(QSYSOPR) ) */ ENDDO ENDDO GOTO LOOP /* Go fetch next message */ /*********** ********* ********* ********* ********* ********* **/ /* Notify QSYSOPR of abnormal end */ /*********** ********* ********* ********* ********* ********* **/ PROBLEM: SNDPGMMSG MSG('MONQSYSMSG job has abnormally ended') + TOMSGQ(QSYSOPR) MONMSG CPF0000 /* SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGTYPE(*ESCAPE) + */ /* MSGDTA('Unexpected error occurred') */ /* MONMSG CPF0000 */ Exit: ENDPGM
[report a broken link by clicking here]