/* REXX PACKLOGS Combine saved ISPF logs into a monthly summary deleting the daily logs behind. Written by Frank Clarke, Oldsmar, FL Impact Analysis . SYSPROC TRAPOUT Modification History 19980629 fxc add REXXSKEL v.19980225 19981015 fxc catch the 'nothing found' condition 19981129 fxc upgrade from v.19980225 to v.19991109; 20000124 fxc qualify dsn with E instead of D for Y2K compliance 20000201 fxc FREE output dataset after HBACKDS 20020923 fxc better HELP text; */ arg argline address TSO /* REXXSKEL ver.19991109 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = trace(tv) info = parms /* to enable parsing */ call A_INIT /* -*/ call B_BUILD_DSLIST /* -*/ call C_COPY_ORIG_LOGS /* -*/ if \sw.0fatal_error then, call D_DELETE_ORIG_LOGS /* -*/ call ZB_SAVELOG /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ PACKLOGS */ /* . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO call AA_SETUP_LOG /* */ parse var info month . /* 9405, for instance */ parse var yyyymmdd yy 5 mm 7 . /* 2000 01 maybe */ save_rc = -1 /* 'nothing found' case */ if month = "AUTO" then do mm = mm - 1 /* last month ! 00 ? */ if mm = 0 then do; yy = yy - 1; mm = 12; end /* 1999 12 */ month = Right(yy,2)Right(mm,2,0) /* 9912 maybe ? */ end ; else, if month = "FORCE" then do month = Right(yy,2)Right(mm,2,0) /* 0001 maybe ? */ end if month = "" then do helpmsg = "MONTH (YYMM) must be specified or implied." call HELP /* -*/ end prefix = Userid()".SAVELOG" long_pref = prefix".E"month /* SMITH.SAVELOG.D9908 */ dsstak = "" dset_ct = 0 return /*@ A_INIT */ /* . ----------------------------------------------------------------- */ AA_SETUP_LOG: /*@ */ if branch then call BRANCH address TSO parse value "0" with, log# log. parse value Date("S") Time("S") Time("N") with, yyyymmdd sssss hhmmss . parse var yyyymmdd 4 yrdigit 5 mm 7 dd /* 9 12 14 maybe */ if Pos(yrdigit,"13579") > 0 then mm = mm + 12 /* mm=24 */ logtag = Substr("ABCDEFGHIJKLMNOPQRSTUVWX",mm,1) /* logtag=X */ subid = logtag""dd""Right(sssss,5,0) /* X1423722 ? */ vb4k.0 = "NEW CATALOG UNIT(SYSDA) SPACE(1 5) TRACKS", "RECFM(V B) LRECL(4096) BLKSIZE(0)" vb4k.1 = "SHR" /* if it already exists... */ logdsn = "@@LOG."exec_name"."subid".#CILIST" call ZL_LOGMSG("Log started by" Userid() yyyymmdd hhmmss) call ZL_LOGMSG("Arg:" argline) return /*@ AA_SETUP_LOG */ /* LISTCAT all the SAVELOG datasets. Collect the ones for the specified month into . . ----------------------------------------------------------------- */ B_BUILD_DSLIST: /*@ */ if branch then call BRANCH address TSO rc = Outtrap("lc.") "LISTC LVL("prefix")" rc = Outtrap("off") call ZL_LOGMSG(lc.0 "lines in catalog") do lx = 1 to lc.0 if Word(lc.lx,1) = "NONVSAM" then, /* line contains DSN */ if Pos(long_pref,Word(lc.lx,3)) <> 0 then do /* candidate DS */ if Word(lc.lx,3) = long_pref then iterate /* base dataset */ dsstak = dsstak "'"Word(lc.lx,3)"'" /* add quoted DSN */ dset_ct = dset_ct + 1 end end /* lx */ call ZL_LOGMSG(dset_ct "input datasets") call ZL_LOGMSG(dsstak) long_pref = "'"long_pref"'" /* now a dataset name */ return /*@ B_BUILD_DSLIST */ /* Copy all the individual SAVELOG datasets to a single month-specific dataset. . ----------------------------------------------------------------- */ C_COPY_ORIG_LOGS: /*@ */ if branch then call BRANCH address TSO if dsstak <> "" then do "ALLOC FI(SYSUT1) DA("dsstak") SHR REU" /* input datasets */ alloc.0 = "NEW CATALOG UNIT(SYSDA) SPACE(3 2) TRACKS", "LIKE("Word(dsstak,1)")" alloc.1 = "MOD" /* if it already exists... */ tempstat = Sysdsn(long_pref) = "OK" /* 1=exists, 0=missing */ "ALLOC FI(SYSUT2) DA("long_pref") REU" alloc.tempstat "ALLOC FI(SYSIN) DUMMY REU" "ALLOC FI(SYSPRINT) DA(*) REU" if \noupdt then, "IEBGENER" else rc = 12 save_rc = rc end say "IEBGENER ended, rc="save_rc if save_rc = -1 then do /* in its original condition */ sw.0fatal_error = "1" /* kill this process */ zerrlm = exec_name "("BRANCH("ID")")", "No matches were found in HSM. Nothing was packed. ", "D_DELETE_ORIG_LOGS will be bypassed." call ZL_LOGMSG(zerrlm) end return /*@ C_COPY_ORIG_LOGS */ /* All the individual logs have been combined into one monthly log. The individual datasets are no longer needed and can be deleted to save space. . ----------------------------------------------------------------- */ D_DELETE_ORIG_LOGS: /*@ */ if branch then call BRANCH address TSO "FREE FI(SYSUT1 SYSUT2 SYSIN SYSPRINT)" if save_rc = 0 then do /* NOUPDT=12 Failure=-1 */ call ZL_LOGMSG("DELETE ("dsstak")") "DELETE ("dsstak")" "HBACKDS" long_pref /* ensure a back-up copy */ end "FREE DA("long_pref")" return /*@ D_DELETE_ORIG_LOGS */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* . ----------------------------------------------------------------- */ ZB_SAVELOG: /*@ */ if branch then call BRANCH address TSO if Symbol("LOG#") = "LIT" then return /* not yet set */ "ALLOC FI($LOG) DA("logdsn") REU" vb4k.0 "EXECIO" log# "DISKW $LOG (STEM LOG. FINIS" "FREE FI($LOG)" return /*@ ZB_SAVELOG */ /* This is a non-standard LOGMSG. It inserts a "." at the front of every message. This enables someone viewing the log to TFLOW any long lines without affecting following lines. . ----------------------------------------------------------------- */ ZL_LOGMSG: Procedure expose, /*@ */ (tk_globalvars) log. log# rc = Trace("O") address TSO parse arg msgtext parse value log#+1 "." msgtext with, zz log.zz 1 log# . if monitor then say, msgtext return /*@ ZL_LOGMSG */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO "CLEAR" if helpmsg <> "" then do; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" Combine daily ISPF logs into a monthly log. The " say " individual logs are collected as " say " .SAVELOG.D " say " and the daily logs are deleted. " say " " say " Syntax: "ex_nam" " say " " say " A month-value in the form 'yymm' must be specified or implied." say " " say " If the month-value is 'AUTO', last month is used as the " say " default value. " say " " say " If the month-value is 'FORCE', the current month is used as " say " the default value. " say " " say " It is an error to call "ex_nam" without parameters. " say " " "NEWSTACK" ; pull ; "CLEAR" ; "DELSTACK" say " Debugging tools provided include: " say " " say " MONITOR: displays key information throughout processing. " say " Displays most paragraph names upon entry. " say " " say " BRANCH: show all paragraph entries. " say " " say " TRACE tv: will use value following TRACE to place the execution " say " in REXX TRACE Mode. " say " " say " " say " Debugging tools can be accessed in the following manner: " say " " say " TSO" exec_name "parameters (( debug options " say " " say " For example: " say " " say " TSO" exec_name "(( MONITOR TRACE ?R " address ISPEXEC "CONTROL DISPLAY REFRESH " exit /*@ HELP */ /* . ----------------------------------------------------------------- */ BRANCH: Procedure expose, /*@ */ sigl exec_name rc = trace("O") /* we do not want to see this */ arg brparm . origin = sigl /* where was I called from ? */ do currln = origin to 1 by -1 /* inch backward to label */ if Right(Word(Sourceline(currln),1),1) = ":" then do parse value sourceline(currln) with pgfname ":" . /* Label */ leave ; end /* name */ end /* currln */ select when brparm = "NAME" then return(pgfname) /* Return full name */ when brparm = "ID" then do /* wants the prefix */ parse var pgfname pgfpref "_" . /* get the prefix */ return(pgfpref) end /* brparm = "ID" */ otherwise say left(sigl,6) left(pgfname,40) exec_name "Time:" time("L") end /* select */ return /*@ BRANCH */ /* . ----------------------------------------------------------------- */ DUMP_QUEUE: /*@ Take whatever is in stack */ rc = trace("O") /* and write to the screen */ address TSO "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return say "Total Stacks" rc , /* rc = #of stacks */ "Begin Stacks" tk_init_stacks , /* Stacks present at start */ "Stacks to DUMP" stk2dump do dd = rc to tk_init_stacks by -1 /* empty each one. */ say "Processing Stack #" dd "Total Lines:" queued() do queued();pull line;say line;end /* pump to the screen */ "DELSTACK" /* remove stack */ end /* dd = 1 to rc */ return /*@ DUMP_QUEUE */ /* . ----------------------------------------------------------------- */ KEYWD: Procedure expose info /*@ hide all vars, except info*/ arg kw kw_pos = wordpos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ kw_val = word(info,kw_pos+1) /* get the next word */ info = Delword(info,kw_pos,2) /* remove both */ return kw_val /*@ KEYWD */ /* . ----------------------------------------------------------------- */ KEYPHRS: Procedure expose, /*@ */ info helpmsg exec_name /* except these three */ arg kp wp = wordpos(kp,info) /* where is it? */ if wp = 0 then return "" /* not found */ front = subword(info,1,wp-1) /* everything before kp */ back = subword(info,wp+1) /* everything after kp */ parse var back dlm back /* 1st token must be 2 bytes */ if length(dlm) <> 2 then /* Must be two bytes */ helpmsg = helpmsg "Invalid length for delimiter("dlm") with KEYPHRS("kp")" if wordpos(dlm,back) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg "No matching second delimiter("dlm") with KEYPHRS("kp")" if helpmsg <> "" then call HELP /* Something is wrong */ parse var back kpval (dlm) back /* get everything b/w delim */ info = front back /* restore remainder */ return Strip(kpval) /*@ KEYPHRS */ /* . ----------------------------------------------------------------- */ NOVALUE: /*@ */ say exec_name "raised NOVALUE at line" sigl say " " say "The referenced variable is" condition("D") say " " zsigl = sigl signal SHOW_SOURCE /*@ NOVALUE */ /* . ----------------------------------------------------------------- */ SHOW_SOURCE: /*@ */ call DUMP_QUEUE /* Spill contents of stacks -*/ if sourceline() <> "0" then /* to screen */ say sourceline(zsigl) rc = trace("?R") nop exit /*@ SHOW_SOURCE */ /* . ----------------------------------------------------------------- */ SS: Procedure /*@ Show Source */ arg ssbeg ssend . if ssend = "" then ssend = 10 if \datatype(ssbeg,"W") | \datatype(ssend,"W") then return ssend = ssbeg + ssend do ssii = ssbeg to ssend ; say sourceline(ssii) ; end return /*@ SS */ /* . ----------------------------------------------------------------- */ SWITCH: Procedure expose info /*@ */ arg kw sw_val = Wordpos(kw,info) > 0 /* exists = 1; not found = 0 */ if sw_val then /* exists */ info = Delword(info,Wordpos(kw,info),1) /* remove it */ return sw_val /*@ SWITCH */ /* . ----------------------------------------------------------------- */ SYNTAX: /*@ */ errormsg = exec_name "encountered REXX error" rc "in line" sigl":", errortext(rc) say errormsg zsigl = sigl signal SHOW_SOURCE /*@ SYNTAX */ /* Can call TRAPOUT. . ----------------------------------------------------------------- */ TOOLKIT_INIT: /*@ */ address TSO info = Strip(opts,"T",")") /* clip trailing paren */ parse source sys_id how_invokt exec_name DD_nm DS_nm, as_invokt cmd_env addr_spc usr_tokn parse value "" with tv helpmsg . parse value 0 "ISR00000 YES" "Error-Press PF1" with, sw. zerrhm zerralrm zerrsm if SWITCH("TRAPOUT") then do "TRAPOUT" exec_name parms "(( TRACE R" info exit end /* trapout */ if Word(parms,1) = "?" then call HELP /* I won't be back */ "QSTACK" ; tk_init_stacks = rc /* How many stacks? */ parse value SWITCH("BRANCH") SWITCH("MONITOR") SWITCH("NOUPDT") with, branch monitor noupdt . parse value mvsvar("SYSNAME") sysvar("SYSNODE") with, #tk_cpu node . sw.nested = sysvar("SYSNEST") = "YES" sw.batch = sysvar("SYSENV") = "BACK" sw.inispf = sysvar("SYSISPF") = "ACTIVE" parse value KEYWD("TRACE") "O" with tv . tk_globalvars = "tk_globalvars exec_name tv helpmsg sw. zerrhm", "zerralrm zerrsm zerrlm tk_init_stacks branch", "monitor noupdt" call LOCAL_PREINIT /* for more opts -*/ return /*@ TOOLKIT_INIT */