|
This is old but should help. CLP name was UPSMONITOR. --- Doug Hart PGM /**/ /* UNINTERRUPTIBLE POWER SUPPLY MONITOR */ /**/ /*********************************************************************/ /* */ /* MOBIL CHEMICAL COMPANY PROGRAM MODIFICATION LOG */ /* ----------------------------------------------- */ /* */ /* DATE PGMR SPR# DESCRIPTION OF MODIFICATION */ /* -------- ---- ---- --------------------------------- */ /* */ /* 06/29/90 DIV 0000 PROGRAM CREATED. */ /* */ /* */ /* */ /* */ /*********************************************************************/ /**/ /*********************************************************************/ /* */ /* WARNING TO PROGRAMMER */ /* --------------------- */ /* */ /* THIS PROGRAM MUST BE COMPILED WITH THE FOLLOWING OPTION: */ /* */ /* USRPRF(*OWNER) */ /* */ /* THE UPS MONITOR PROGRAM EXPECTS THE FOLLOWING SYSTEM VALUES */ /* IN ORDER TO OPERATE CORRECTLY: */ /* */ /* QUPSMSGQ = QUSRSYS / UPSMSGQ */ /* QUPSDLYTIM = *NOMAX */ /* QPWRRSTIPL = '1' */ /* */ /* THIS JOB RUNS IN THE CONTROLLING SUBSYSTEM. */ /* */ /* SUBSYSTEM CTL01 JOBQ QCTL ALLOWS *NOMAX JOBS, HOWEVER */ /* THIS UPS MONITOR PROGRAM ALLOWS ONLY ONE. ATTEMPTS TO START */ /* DUPLICATE UPS MONITOR JOBS WILL BE ENDED AUTOMATICALLY. */ /* */ /*********************************************************************/ /**/ DCL VAR(&JOB) TYPE(*CHAR) LEN(10) DCL VAR(&USER) TYPE(*CHAR) LEN(10) DCL VAR(&JOBNUMBER) TYPE(*CHAR) LEN(6) /**/ DCL VAR(&UPSMSGQLIB) TYPE(*CHAR) LEN(20) DCL VAR(&UPSMSGQ) TYPE(*CHAR) LEN(10) DCL VAR(&UPSLIB) TYPE(*CHAR) LEN(10) /**/ DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) /**/ DCL VAR(&JOBCNLREQ) TYPE(*CHAR) LEN(1) DCL VAR(&TENSECOUNT) TYPE(*DEC) LEN(5) /* Ten + Second Power Failure Loop Counter. */ DCL VAR(&WAITSEC) TYPE(*DEC) LEN(5 0) /* Declare + Variable For The Time The System Should + Wait Before Beginning Power Down. */ DCL VAR(&AWAITSEC) TYPE(*CHAR) LEN(5) /* Declare + Alpha Version Of &WAITMIN. */ DCL VAR(&WAITCYCLES) TYPE(*DEC) LEN(5) /* Declare + Variable For Number Of Wait Cycles Which + Must Occur Before System Is Powered Down. */ DCL VAR(&MCCCUSMSG) TYPE(*CHAR) LEN(50) /* + Declare Variable For Mobil Customized + Message To Users. */ /**/ DCL VAR(&LOOP_LABEL) TYPE(*CHAR) LEN(10) /**/ DCLF FILE(MTXTSRC) /* Declare Mobil Controlled + Source File. */ /**/ /*********************************************************************/ /**/ SETUP_JOB: /**/ RTVJOBA JOB(&JOB) USER(&USER) NBR(&JOBNUMBER) /* + Retrieve This Job's Attributes. */ /**/ /************CHGJOB*****LOG(4 00 *SECLVL) LOGCLPGM(*YES)*************/ CHGJOB RUNPTY(5) /**/ OVRDBF FILE(MTXTSRC) MBR(UPSMONITOR) SECURE(*YES) + /* Override To Member UPSMONITOR In + MTXTSRC File. */ /**/ NEXRCD: /**/ RCVF /* Read Outfile. */ /**/ MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(UPDVAR)) /* + If End-Of-File Reached, Update User + Controlled Variables. */ /**/ GOTO CMDLBL(NEXRCD) /* Read All Records Until + End-Of-File. */ /**/ UPDVAR: /**/ CHGVAR VAR(&WAITSEC) VALUE(%SUBSTRING(&SRCDTA 1 5)) CHGVAR VAR(&MCCCUSMSG) VALUE(%SUBSTRING(&SRCDTA 10 + 50)) /**/ IF COND(&WAITSEC <= 00000) THEN(CHGVAR + VAR(&WAITSEC) VALUE(00180)) /* If Value Is + Not Valid, Substitute 180 Seconds. */ /**/ CHGVAR VAR(&WAITCYCLES) VALUE(&WAITSEC / 10) /**/ CHGVAR VAR(&AWAITSEC) VALUE(&WAITSEC) /**/ /*********************************************************************/ /**/ CHECK_MSGQ: /**/ RTVSYSVAL SYSVAL(QUPSMSGQ) RTNVAR(&UPSMSGQLIB) /* + Retrieve UPS Message Queue Value. */ /**/ CHGVAR VAR(&UPSMSGQ) VALUE(%SUBSTRING(&UPSMSGQLIB 1 + 10)) CHGVAR VAR(&UPSLIB) VALUE(%SUBSTRING(&UPSMSGQLIB 11 + 10)) /* Break UPS Message Queue System + Value Into Two Variables. */ /**/ CHKOBJ OBJ(&UPSLIB/&UPSMSGQ) OBJTYPE(*MSGQ) /* + Verify That UPS Message Queue Exist. */ MONMSG MSGID(CPF9801) EXEC(DO) /**/ SNDPGMMSG MSG('WARNING -- Job ' || &JOBNUMBER |< '/' || + &USER |< '/' || &JOB |< ' has found + Uninterruptible Power Supply *MSGQ ' || + &UPSLIB |< '/' || &UPSMSGQ |< ' missing. + If system has been recently reloaded, this + condition is normal. Since this *MSGQ is + always allocated by the UPS monitor job, it + can not be saved during normal backups. NO + OPERATOR ACTION OR INTERVENTION IS + REQUIRED. This job will re-create the + required UPS *MSGQ automatically.') + TOMSGQ(QSYSOPR) /**/ CRTMSGQ MSGQ(&UPSLIB/&UPSMSGQ) TEXT('Uninterruptible + Power Supply Monitor Message Queue') + SIZE(12) AUT(*EXCLUDE) /* Re-Create UPS + Message Queue. */ /**/ CHGOBJOWN OBJ(&UPSLIB/&UPSMSGQ) OBJTYPE(*MSGQ) + NEWOWN(QSECOFR) /* Force Owner Of Message + Queue To Be QSECOFR. */ /**/ ENDDO /* If The UPS Message Queue Is Not Found, + Create A New One, Change The Object Owner + To MCCSYSCTL, And Warn System Operator Of + This Condition. Program Will Continue To + Execute. */ /**/ /*********************************************************************/ /**/ ALLOC_MSGQ: /**/ ALCOBJ OBJ((&UPSLIB/&UPSMSGQ *MSGQ *EXCL)) WAIT(2) + /* Attempt To Exclusively Allocate UPS + Monitor Message Queue. */ MONMSG MSGID(CPF1002) EXEC(DO) /**/ SNDPGMMSG MSG('WARNING -- Job ' || &JOBNUMBER |< '/' || + &USER |< '/' || &JOB |< ' is unable to + exclusively allocate Uninterruptible Power + Supply *MSGQ ' || &UPSLIB |< '/' || + &UPSMSGQ |< '. This condition is caused + when a second UPS monitor job has been + started. Only 1 UPS monitor job is + permitted to execute. This job will be + ended (normally) automatically. NO + OPERATOR ACTION OR INTERVENTION IS + REQUIRED. If message re-occurs, eliminate + cause of second UPS monitor job + submission.') TOMSGQ(QSYSOPR) GOTO CMDLBL(END) ENDDO /* If UPS Monitor Message Queue Cannot Be + Allocated, Advise System Operator And End + The Duplicate Job. */ /**/ /*********************************************************************/ /**/ MON_UPS: /**/ CHGVAR VAR(&MSGID) VALUE(' ') /* Initialize + This Variable. */ CHGVAR VAR(&TENSECOUNT) VALUE(0) /* Initialize The + Ten Second Power Failure Loop Counter. */ /**/ RCVMSG MSGQ(&UPSLIB/&UPSMSGQ) WAIT(300) + MSGID(&MSGID) /* Attempt To Receive Any UPS + Related Messages. */ /**/ IF COND(&MSGID = 'CPF1816') THEN(GOTO + CMDLBL(PWR_FAILED)) /* If Utility Power Has + Been Lost, Jump To Power Failed Loop + Section Of Program. */ /**/ RTVJOBA ENDSTS(&JOBCNLREQ) /* Retrieve Job Attribute + Regarding Job Cancel Status. */ /**/ IF COND(&JOBCNLREQ = '1') THEN(DO) SNDPGMMSG MSG('WARNING -- Job ' || &JOBNUMBER |< '/' || + &USER |< '/' || &JOB |< ' is currently in + cancel status. The Uninterruptible Power + Supply monitor program has been cancelled + by another job or by the system operator. + View the system operator message queue for + additional information. This job will be + ended (normally) automatically. NO + OPERATOR ACTION OR INTERVENTION IS + REQUIRED. UPS monitor job should be + restarted as soon as possible.') + TOMSGQ(QSYSOPR) GOTO CMDLBL(END) ENDDO /* If UPS Monitor Job Has Been Cancelled, + Advise System Operator And End This Job + Immediately. */ /**/ IF COND(&MSGID ¬= ' ') THEN(DO) CHGVAR VAR(&LOOP_LABEL) VALUE('MON_UPS ') GOTO CMDLBL(OTHER_MSGS) ENDDO /* If Other Messages Have Been Received, Set + Return Loop Label, And Goto Other Messages + Section Of Program. */ /**/ GOTO CMDLBL(MON_UPS) /* If Message ID Is Blank, + Continue To Monitor UPS Power. */ /**/ /*********************************************************************/ /**/ PWR_FAILED: /**/ NEXT_MSG: /**/ CHGVAR VAR(&MSGID) VALUE(' ') /* Initialize + This Variable. */ CHGVAR VAR(&TENSECOUNT) VALUE(&TENSECOUNT + 1) /* + Increment Ten Second Power Failure Loop + Counter. */ /**/ RCVMSG MSGQ(&UPSLIB/&UPSMSGQ) WAIT(10) MSGID(&MSGID) + /* Attempt To Receive Any UPS Related + Messages. */ /**/ IF COND(&MSGID = 'CPF1817') THEN(DO) /**/ IF COND(&TENSECOUNT > 1) THEN(DO) SNDBRKMSG MSG('ATTENTION ALL USERS -- Electrical + power to the computer room has been + RESTORED. You may continue to use the + computer system at this time. Additional + messages will be sent if electrical power + is lost again. Contact ' || &MCCCUSMSG + |< ' if you have any questions.') + TOMSGQ(*ALLWS) /* Advise Users Of Power + Restoration. */ ENDDO /* If Previous Message Has Been Sent + Advising Users That Power Has Failed, Now + Send Message That Power Has Been Restored. */ /**/ GOTO CMDLBL(MON_UPS) ENDDO /* If Utility Power Has Been Restored, Advise + Users Of Power Restoration, And Jump To The + Monitor UPS Loop Section Of Program. */ /**/ IF COND(&TENSECOUNT = 1) THEN(DO) SNDBRKMSG MSG('ATTENTION ALL USERS -- Electrical + power to the computer room has been + LOST. Unless power is restored within + the next ' || &AWAITSEC || ' seconds, + this computer will automatically begin to + shut down. PLEASE CANCEL YOUR CURRENT + TRANSACTION AND PROCEED BACK TO YOUR MAIN + MENU. If utility power is restored in ' + || &AWAITSEC || ' seconds, a message will + be sent advising you that the system is + now available for use. Otherwise, + contact ' || &MCCCUSMSG |< ' for + assistance.') TOMSGQ(*ALLWS) /* Warn + Users Of Power Failure. */ ENDDO /**/ IF COND(&MSGID ¬= ' ') THEN(DO) CHGVAR VAR(&LOOP_LABEL) VALUE('NEXT_MSG ') GOTO CMDLBL(OTHER_MSGS) ENDDO /* If Other Messages Have Been Received, Set + Return Loop Label, And Goto Other Messages + Section Of Program. */ /**/ IF COND(&TENSECOUNT < &WAITCYCLES) THEN(GOTO + CMDLBL(NEXT_MSG)) /* If System Has Not + Waited For Required Cycles (At Ten Seconds + Each), Force Another Loop. Once Required + Cycles Has Been Completed, And Utility + Power Restored Message Has NOT Been + Received, Proceed With Next Step To Power + Down System. */ /**/ POWER_DOWN: /**/ QSYS/PWRDWNSYS OPTION(*IMMED) /* Since Utility Power Has Not + Been Restored, Power Down System + Immediately. Since System Is On UPS Power, + A "Quick Power Down" Process Will Be + Initiated. */ /**/ /*********************************************************************/ /**/ OTHER_MSGS: /**/ IF COND(&MSGID = 'CPF1816') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + ANOTHER CPF1816 indicating utility power + has failed. Receiving this message again + without a subsequent CPF1817 (utility power + restored) may indicate a problem exists + with the UPS, the UPS attachment, or + possible internal processing routines. + This potential problem should be + investigated. NO OPERATOR ACTION OR + INTERVENTION IS REQUIRED. UPS monitor job + will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPF1817') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + ANOTHER CPF1817 indicating utility power + has restored. Receiving this message again + without a subsequent CPF1816 (utility power + failed) may indicate a problem exists with + the UPS, the UPS attachment, or possible + internal processing routines. This + potential problem should be investigated. + NO OPERATOR ACTION OR INTERVENTION IS + REQUIRED. UPS monitor job will continue + running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0961') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0961 indicating the Uninterruptible + Power Supply (UPS) has been taken off-line + and is no longer attached to system. If + utility power should fail, the system will + not be protected. If this is not a true or + known condition, the situation must be + investigated and corrected. UPS monitor + job will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0962') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0962 indicating the Uninterruptible + Power Supply (UPS) has been put on-line and + is attached to system. If utility power + should fail, the system will be protected. + If this is not a true or known condition, + the situation must be investigated and + corrected. UPS monitor job will continue + running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0963') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0963 indicating the Uninterruptible + Power Supply (UPS) is currently supplying + system power. If this is not a true or + known condition, the situation must be + investigated and corrected. UPS monitor + job will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0964') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0964 indicating the Uninterruptible + Power Supply (UPS) has a weak battery + condition. If the system loses utility + power, the UPS monitor will release control + of the processing. The system will perform + an immediate power down. If this is not a + true or known condition, the situation must + be investigated and corrected. UPS monitor + job will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0965') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0965 indicating a hardware problem in + the model B10 or B20 UPS features. If this + is not a true or known condition, the + situation must be investigated and + corrected. UPS monitor job will continue + running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0966') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0966 indicating a hardware problem in + the model B10 or B20 UPS features. If this + is not a true or known condition, the + situation must be investigated and + corrected. UPS monitor job will continue + running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0973') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0964 indicating the Uninterruptible + Power Supply (UPS) no longer has a weak + battery condition. If the system loses + utility power, the UPS monitor will control + processing. The system will not perform an + immediate power down. If this is not a + true or known condition, the situation must + be investigated and corrected. UPS monitor + job will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0974') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0974 indicating the Uninterruptible + Power Supply (UPS) has been taken off-line + and is no longer attached to system. If + utility power should fail, the system will + not be protected. If this is not a true or + known condition, the situation must be + investigated and corrected. UPS monitor + job will continue running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0975') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0975 indicating the Uninterruptible + Power Supply (UPS) has been put on-line and + is attached to system. If utility power + should fail, the system will be protected. + If this is not a true or known condition, + the situation must be investigated and + corrected. UPS monitor job will continue + running.') TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0976') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0976 indicating the Uninterruptible + Power Supply (UPS) monitor could not send a + message to the UPS message queue. If this + is true, how was this message ever + received?. There is definitely a problem. + UPS monitor job will continue running.') + TOMSGQ(QSYSOPR)) /**/ IF COND(&MSGID = 'CPI0981') THEN(SNDPGMMSG + MSG('WARNING -- Job ' || &JOBNUMBER |< '/' + || &USER |< '/' || &JOB |< ' has received + CPI0981 indicating the Automatic IPL system + value (QPWRRSTIPL) has been disabled. + Refer to prior messages in system operator + message queue for additional information. + UPS monitor job will continue running.') + TOMSGQ(QSYSOPR)) /**/ /**********/ /**/ IF COND(&LOOP_LABEL = 'MON_UPS ') THEN(GOTO + CMDLBL(MON_UPS)) /* If Loop Label Return + Point Is MON_UPS, Then Return There To + Monitor For Additional Messages. */ /**/ ELSE CMD(IF COND(&LOOP_LABEL = 'NEXT_MSG ') + THEN(GOTO CMDLBL(NEXT_MSG))) /* If Loop + Label Return Point Is NEXT_MSG, Then Return + There To Monitor For Additional Messages. */ /**/ ELSE CMD(DO) SNDPGMMSG MSG('WARNING -- Job ' || &JOBNUMBER |< '/' || + &USER |< '/' || &JOB |< ' is operating + improperly. The Uninterruptible Power + Supply monitor program is processing "other + UPS related messages" and has requested a + loop label return point which does not + exist. Value in field LOOP_LABEL is ' || + &LOOP_LABEL |< '. Advise programmer of + this problem immediately. NO OPERATOR + INTERVENTION IS REQUIRED. UPS monitor job + will continue running at MON_UPS loop label + return point, but may operate + incorrectly.') TOMSGQ(QSYSOPR) GOTO CMDLBL(MON_UPS) ENDDO /* If An Unknown Loop Label Return Point Has + Been Identified, Advise System Operator, + And Continue Processing Normally. */ /**/ /*********************************************************************/ /**/ END: /**/ ENDPGM > > ----- Original Message ----- > From: "William Washington III" <w.washington3@xxxxxxxxxxxxx> > To: "Midrange" <midrange-l@xxxxxxxxxxxx> > Sent: Friday, February 20, 2004 11:32 PM > Subject: Shutdown programs when UPS starts > > >> Hello All, >> >> Does the iSeries have a system value that holds the name of a >> program to > run for certain events, like a UPS startup? >> >> I'd like to shut down my iSeries in an orderly manner when the USP is > activated, but I cannot find a "hook" to start my program. >> >> It's kind of like my STARTUP program when I restart (IPL) my >> machine. I > have everything I want to start there... I wonder if the reverse > functionality is there. >> >> If it doesn't exist, can monitoring the QUPSMSGQ work? Other ideas? >> Thanks!
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.