View Full Version : Writting a CL to handle shutdown during a power outage
Guest.Visitor
01-01-1995, 02:00 AM
I had a 9406 lose power in Chicago over the weekend and the UPS was able to handle the load for some time, but once the battery was drained, the AS/400 was shutdown abnormally, which made for a call to placed by service director for my 530 external disk unit, when I brought the system back up. (which took some time) Rodchester determined that the 530 problem was a "fluke" and the CE informed me that there really was no hardware problem. Anyway, I know there is program that can be written to moniter a MSGQ that is specified in qupsmsgq sys val, and shutdown the system normally. The online mauals do not have the entire souce example, where as the Backup and Recovery manual has a code snipet and more of an explanation (left my manual in Rockford). Can someone post this code and/or explain a little more about writting this pocedure?
Guest.Visitor
10-10-2000, 02:18 PM
Greg, For what it's worth here's some CL to get you started. This is the main program we run. It runs in it's own subsystem MONITOR (with other jobs), has it's own lib and dtaara. Only the dtaara is important as you can see from the code. The called CLPs are self explanatory (I think). Let me know if you have any questions. /************************************************** ******************/ /* Program name . . . . . . . . . . . . . . : UPSCTLCL */ /* Library name . . . . . . . . . . . . . . : UPSMONITOR */ /* User profile . . . . . . . . . . . . . . : *USER */ /* Text . . . : UPSMonitor: Main Processing Program */ /* Owner . . . . . . . . . . . . . . . . . : QSECOFR */ /************************************************** ******************/ PGM DCL &NOPWR *LGL VALUE('0') DCL &PWRRST *LGL VALUE('0') DCL &PWRON *LGL VALUE('0') DCL &WAIT *DEC (4 0) DCL &MINUTES *DEC (5 0) 0 DCL &COUNT *DEC (2 0) 0 DCL &MODE *CHAR 1 DCL &THRESHOLD *DEC (2 0) DCL &MAXOFF *DEC (2 0) DCL &MSGID *CHAR 7 DCL &USER *CHAR 10 DCL &CHAR2 *CHAR 2 DCL &PWRSTART *CHAR 6 DCL &PWRNOW *CHAR 6 DCL &DIFF *CHAR 4 DCL &EXITTYPE *CHAR 7 CHGCURLIB CURLIB(UPSMONITOR) RTVDTAARA (UPSMONITOR/UPSMONITOR (1 1)) &MODE RTVDTAARA (UPSMONITOR/UPSMONITOR (2 2)) &CHAR2 CHGVAR &MAXOFF &CHAR2 RTVDTAARA (UPSMONITOR/UPSMONITOR (4 2)) &CHAR2 CHGVAR &THRESHOLD &CHAR2 RTVDTAARA (UPSMONITOR/UPSMONITOR (6 10)) &USER CHGVAR &WAIT (30 * 60) CHGVAR &EXITTYPE ('UNKNOWN') SNDUSRMSG MSGID(UPS0001) MSGF(UPSMONITOR/UPSMONITOR) + MSGTYPE(*INFO) TOMSGQ(&USER) SNDUSRMSG MSGID(UPS5001) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&CHAR2) MSGTYPE(*INFO) TOMSGQ(&USER) IF (&MODE *NE 'A') + SNDUSRMSG MSGID(UPS0002) MSGF(UPSMONITOR/UPSMONITOR) + MSGTYPE(*INFO) TOMSGQ(&USER) LOOPA: ALCOBJ ((UPSMONITOR/UPSMSGQ *MSGQ *EXCL)) LOOPB: RCVMSG MSGQ(UPSMONITOR/UPSMSGQ) WAIT(&WAIT) MSGID(&MSGID) MONMSG MSGID(CPF0001) EXEC(GOTO LOOPB) IF (&MSGID *EQ 'UPS9999') DO CHGVAR &EXITTYPE 'USERREQ' GOTO ENDIT ENDDO IF (&MSGID *EQ 'CPF1816') (GOTO FAILED) IF (&MSGID *EQ 'CPF1817') (GOTO PWRBCK) IF (&MSGID *EQ 'CPI0994') (GOTO PWRBCK) IF (&NOPWR *AND %SST(&MSGID 1 1) *EQ ' ') GOTO TEST3 IF (&PWRON) GOTO PWRBCK GOTO FAILEDB FAILED: CHGVAR &NOPWR '1' CHGVAR &PWRRST '0' RTVSYSVAL QTIME &PWRSTART IF (&MODE *NE 'A') + SNDMSG MSG('** ALERT ** Power has been lost to the + AS/400. Please sign off system IMMEDIATELY.') + TOUSR(&USER) ELSE + SNDBRKMSG MSG('** ALERT ** Power has been lost to the + AS/400. Please sign off system IMMEDIATELY.') + TOMSGQ(*ALLWS) IF (&PWRON *EQ '0') DO CALL UPSHJQCL &MODE /* HOLD JOBQS */ CALL UPSEWTCL &MODE /* END WRITERS */ CALL UPSESBCL &MODE /* END SUBSYSTEMS */ ENDDO CHGVAR &COUNT (&COUNT + 1) CHGVAR &CHAR2 &COUNT SNDUSRMSG MSGID(UPS5000) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&CHAR2) MSGTYPE(*INFO) TOMSGQ(&USER) IF (&COUNT *GE &THRESHOLD) DO CHGVAR &CHAR2 &THRESHOLD SNDUSRMSG MSGID(UPS0199) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&CHAR2) MSGTYPE(*INFO) TOMSGQ(&USER) GOTO PWRIMMD ENDDO CHGVAR &WAIT (5 * 60) GOTO LOOPB FAILEDB: IF (&NOPWR) DO RTVSYSVAL QTIME &PWRNOW CALL UPSTIMECL (&PWRSTART &PWRNOW &DIFF) CHGVAR &MINUTES &DIFF IF (&MINUTES *GE &MAXOFF) GOTO TIMEUP ENDDO IF (&MODE *NE 'A') DO CHGVAR VAR(&CHAR2) VALUE(&COUNT) SNDUSRMSG MSGID(UPS5000) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&CHAR2) MSGTYPE(*INFO) TOMSGQ(&USER) IF (&NOPWR) + SNDUSRMSG MSGID(UPS5011) MSGF(UPSMONITOR/UPSMONITOR) + MSGTYPE(*INFO) TOMSGQ(&USER) IF (&PWRRST) + SNDUSRMSG MSGID(UPS5021) MSGF(UPSMONITOR/UPSMONITOR) + MSGTYPE(*INFO) TOMSGQ(&USER) ENDDO /* RESTART SUBSYSTEMS */ IF (&NOPWR *EQ '0' *AND &PWRRST *EQ '0') DO SBMJOB CMD(CALL PGM(UPSMONITOR/UPSSBSUCL)) + JOB(UPS_UPDATE) JOBD(UPSMONITOR/UPSJOBD) MSGQ(*NONE) CHGVAR &WAIT (30 * 60) ENDDO IF (&PWRRST) DO CHGVAR &COUNT 0 CHGVAR &PWRRST '0' ENDDO GOTO LOOPB PWRBCK: IF (&NOPWR) DO CHGVAR &PWRON '1' CHGVAR &NOPWR '0' CHGVAR &WAIT (5 * 60) SNDUSRMSG MSGID(UPS0300) MSGF(UPSMONITOR/UPSMONITOR) + MSGTYPE(*INFO) TOMSGQ(&USER) GOTO LOOPA ENDDO IF (&PWRON *AND &PWRRST *EQ '0') DO CHGVAR &PWRON '0' CHGVAR &PWRRST '1' ENDDO IF (&PWRRST) DO IF (&PWRON *EQ '0') + SNDMSG MSG('Power + has been restore to the system. You may + continue working as you were. Thank + you.') TOUSR(JAY) CALL UPSSSBCL &MODE /* START SUBSYSTEMS */ CALL UPSRJQCL &MODE /* RELEASE JOBQS */ CALL UPSSWTCL &MODE /* START WRITERS */ CHGVAR &MINUTES 0 CHGVAR &PWRON '0' ENDDO CHGVAR &NOPWR '0' CHGVAR &PWRRST '1' PWRBCK2: CHGVAR &WAIT (30 * 60) GOTO LOOPA TEST3: RTVSYSVAL QTIME &PWRNOW CALL UPSTIMECL (&PWRSTART &PWRNOW &DIFF) CHGVAR &MINUTES &DIFF SNDUSRMSG MSGID(UPS0100) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&DIFF) MSGTYPE(*INFO) TOMSGQ(&USER) IF (&NOPWR *AND &MINUTES *GE &MAXOFF) GOTO TIMEUP CHGVAR &WAIT (5 * 60) GOTO LOOPA TIMEUP: CHGVAR &CHAR2 &MAXOFF SNDUSRMSG MSGID(UPS0101) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&CHAR2) MSGTYPE(*INFO) TOMSGQ(&USER) IF (&MODE *EQ 'A') DO GOTO PWRCNTRLD ENDDO PWRCNTRLD: SNDUSRMSG MSGID(UPS0200) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA('*CNTRLD') MSGTYPE(*INFO) TOMSGQ(&USER) IF (&MODE *EQ 'A') DO PWRDWNSYS OPTION(*CNTRLD) DELAY(1800) RESTART(*NO) ENDDO GOTO ENDIT PWRIMMD: SNDUSRMSG MSGID(UPS0200) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA('*IMMED') MSGTYPE(*INFO) TOMSGQ(&USER) IF (&MODE *EQ 'A') DO PWRDWNSYS OPTION(*IMMED) ENDDO GOTO ENDIT ENDIT: SNDUSRMSG MSGID(UPS9998) MSGF(UPSMONITOR/UPSMONITOR) + MSGDTA(&EXITTYPE) MSGTYPE(*INFO) TOMSGQ(&USER) ENDPGM
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.