/*********************************************************************/ /* PICAPCPU REXX TO put a CAP on CPU-load */ /* THIS version maintains a history of the load */ /* Martin Truebner 18.11.08 */ /*********************************************************************/ /* */ /* This REXX controls CPU-LOAD and adjust usage by deactivating */ /* and reactivating BATCH-partitions */ /* any command-combination is possible and can be specified here */ /* even a simple PAUSE BG,EOJ (to introduce an artifical delay at jobend) */ /* is possible- You should (if you want to do that) then look for */ /* the correct REPLID to end the PAUSE */ /* */ /* TRACE R? */ LOW_CPU = 10 /* CPU must be below this to reactivate */ HIGH_CPU = 50 /* CPU must be above this to start acting */ measure_int = 30 /* size in seconds of an interval */ /* the above should be big enough to have multiple GETJA */ rolling_avg = 10 /* rolling average for so many intervalls */ /* for a rolling average of 4 hours and an intervall of 10 Minutes */ /* a value of 24 would yield the desired result */ cmds = 3 /* there are so many levels to react */ cut.1 = 'SUSPEND F8' /* watch this...there is a */ inc.1 = 'RESUME F8' /* one to one relation of the commands */ cut.2 = 'SUSPEND F9' /* the commands are handled like a */ inc.2 = 'RESUME F9' /* PUSH-DOWN or */ inc.3 = '* BELOW LIMIT' /* LIFO-stack */ cut.3 = 'MARTIN PLEASE HELP' /*********************************************************************/ acci=0 /* we currently are at this level */ ADDRESS LINK 'PICC01 INIT' hist.= 30 /* assume this as average for not covered items */ hist.0= rolling_avg /* so many items in hist */ REQ='RUN' CALL OPERMSG 'ON' DO UNTIL REQ='STOP' CALL SLEEP measure_int ADDRESS LINK 'PICC01 DATA' CCPULOAD=RC REQ = OPERMSG('MSGDATA') /* Any operator comm request */ if LENGTH(REQ)<>0 & REQ <> 'STOP' THEN CALL TALK_USER IF CCPULOAD > 100 THEN DO CALL ASSGN 'STDOUT','SYSLOG' SAY 'PICAPCPU saw wrong (time-expired?)' CCPULOAD CALL ASSGN 'STDOUT','SYSLST' ITERATE end CPULOAD=CCPULOAD CALL ASSGN 'STDOUT','SYSLOG' DO I=2 to hist.0 II=I-1 hist.II=hist.I CPULOAD = hist.II+CPULOAD /* say 'sum is now=' CPULOAD */ END I=HIST.0 hist.I = CCPULOAD CPULOAD = CPULOAD / I SAY "PICAPCPU current:" ccpuload "rolling:" FORMAT(CPULOAD,3,2) CALL ASSGN 'STDOUT','SYSLST' IF CPULOAD < LOW_CPU THEN DO IF acci > 0 THEN CALL REACT_LOW END IF CPULOAD > HIGH_CPU THEN DO IF acci < cmds THEN CALL REACT_HIGH END END EXIT /* End of Main Line */ TALK_USER: CALL ASSGN 'STDOUT','SYSLOG' SAY 'This REXX does only understands STOP ' SAY 'the current CMDs to reduce CPU-load are' DO I= 1 TO CMDS SAY I"="CUT.I END SAY 'the current CMDs to increase CPU-load are' DO I= 1 TO CMDS SAY I'='INC.I END SAY 'Cmd-level =' ACCI SAY 'the system will use this level to increase load' SAY 'and the next higher level for a decrease in load' CALL ASSGN 'STDOUT','SYSLST' RETURN REACT_HIGH: acci=acci+1 ADDRESS LINK 'DTRIATTN' cut.acci RETURN REACT_LOW: ADDRESS LINK 'DTRIATTN' inc.acci acci=acci-1 RETURN