#!/usr/local/bin/rxx parse arg fn fo fp ft . /* (c) copyright 1995, Paul Zarnowski and Cornell University (see "Legal Information", below) fn = name of file containing raw activity log fo = name of output file to contain filtered activity log fp = name of prefix file to contain activity log header messages ft = name of tape history file to contain tape-related messages Author Information: Paul Zarnowski Cornell Information Technologies Ithaca, NY 14853-2601 psz1@cornell.edu Update History: 9-Oct-95 psz1: Initial version */ DEBUG=0 /* Summarize the count of the following messages */ summsg="ANR8213W ANR8214W ANR2716E" SKIP. = 0 SKIPLINE. = '' SESSION. = 0 SESSION.0 = '' eof=0 eor=0 if (fo <> "") then do "/bin/test -f" fo if (rc=0) then 'rm' fo end if (fp <> "") then do "/bin/test -f" fp if (rc=0) then 'rm' fp end /* first, get list of normally ended sessions and of aborted sessions. */ G.$PASS=1 sesslist='' badsesslist='' termsesslist='' do until (eof) do until (eor | eof) l=getline(fn) end if (eof) then iterate sess = getsession(l) if (endmsg(msg) | termmsg(msg)) then do if (msg = "ANR0484W") then termsesslist = termsesslist sess else sesslist = sesslist sess end /* note: most messages between 0420 and 0598 are summarized. */ if (abortmsg(msg)) then do sess = getsession(l) if (wordpos(sess,badsesslist)=0) then badsesslist = badsesslist sess end end eof=0 eor=0 l=linein(fn,1,0) /* reset to beginning of file */ l=getline(fn) G.$PASS=1 do until (eor | eof) /* copy prefix lines to prefix file */ rc=lineout(fp,l) l=getline(fn) end do until (eof) tapeout=tapemsg(msg l) out=filter(msg l) if (out) then do if summarize(msg l) then do out=0 if (^eof) then l=getline(fn) iterate end end do until (eor | eof) if (out) then rc=lineout(fo,l) if (tapeout) then rc=uniqout(ft,l) l=getline(fn) end end n = SKIP.0 do i = 1 to n rc=lineout(fo," ") ts=SKIPSTART.i te=SKIPEND.i if (SKIPL.i.0 > 2) then ms = "sequence" else ms = "message" select when (SKIP.i = 1) then rc=lineout(fo,"This" ms "occurred once:") when (SKIP.i = 2) then rc=lineout(fo,"This" ms "occurred twice" , "("ts "-" te"):") otherwise rc=lineout(fo,"This" ms "occurred" SKIP.i "times ("ts "-" te"):") end do j = 1 to SKIPL.i.0 if (SKIP.i=1) & (j <= 2) & (left(SKIPL.i.j,10)="mm/dd/yyyy") then SKIPL.i.j=overlay(ts,SKIPL.i.j) if (SKIPL.i.j <> "") then rc=lineout(fo,SKIPL.i.j) end end ss=SESSION.0 if (ss<>"") then rc=lineout(fo,"- - -") do while (ss<>"") parse value ss with s ss do j = 1 to SESSION.s.0 if (left(SESSION.i.j,10)="mm/dd/yyyy") then SESSION.i.j=overlay(ts,SESSION.i.j) if (SESSION.i.j <> "") then rc=lineout(fo,SESSION.i.j) end end rc=lineout(fo) exit /* filter: return 1, if message should be included. */ filter: procedure expose sesslist badsesslist termsesslist G. parse arg msg line if (skipmsg(msg)) then return 0 if (beginmsg(msg) | endmsg(msg)) then do sess = getsession(line) if (wordpos(sess,badsesslist)<>0) then return 1 if (wordpos(sess,sesslist)<>0) then return 0 end return 1 summarize: procedure expose fn eof summsg SKIP. SKIPLINE. , SKIPL. SKIPSTART. SKIPEND. sesslist badsesslist termsesslist , SESSION. DEBUG G. parse arg msg line aborted=0 msgno=substr(msg,4,4) if ( abortmsg(msg) | beginmsg(msg) | endmsg(msg) ) then do sess = getsession(line) if (sess <> "") & (wordpos(sess,badsesslist)<>0) then aborted=1 end if (wordpos(msg,summsg)=0) & (^aborted) then do return 0 end timestamp=subword(line,1,2) line1=overlay("mm/dd/yyyy hh:mm:ss",line) if (aborted) then line1=masksession(line1) msg1=msg line2=getline(fn) if (eor) then do /* reset current line pointer */ linesleft=lines(fn) call lineout fn filesize=lines(fn) reset=filesize-linesleft x=linein(fn,reset,0) line2="" end else do if (aborted) then line2=masksession(line2) line3=getline(fn) if (eor) then do linesleft=lines(fn) call lineout fn filesize=lines(fn) reset=filesize-linesleft x=linein(fn,reset,0) line3="" end else do line2=line2 line3 end end /* if (aborted & (wordpos(sess,sesslist)<>0)) then do */ if (aborted) then do sl=SESSION.sess.0 if (sl=0) then SESSION.0 = SESSION.0 sess sl=sl+1 SESSION.sess.sl=line1 if (line2<>"") then do sl=sl+1 SESSION.sess.sl=line2 end SESSION.sess.0=sl endsession=0 select when (beginmsg(msg1)) then SESSION.sess.TIMESTART=timestamp when (endmsg(msg1) | termmsg(msg1)) | , ((wordpos(sess,sesslist)=0) & (wordpos(sess,termsesslist)=0)) then do linex=strip(SESSION.sess.1) do i = 2 to sl liney=SESSION.sess.i if (left(liney,2)=" ") then linex=linex strip(liney) else linex=linex';'strip(liney) end endsession=1 end otherwise nop /* middle of complete (aborted) session */ end if (^endsession) then return 1 wp = wordpos(sess,SESSION.0) if (wp <> 0) then SESSION.0=delword(SESSION.0,wp,1) end else linex=line1';'line2 n = SKIP.0 found = 0 do i = 1 to n until (found) if (linex = SKIPLINE.i) then do found = 1 SKIP.i = SKIP.i + 1 SKIPEND.i = timestamp leave end end if ^(found) then do n = n + 1 SKIP.0 = n SKIPLINE.n = linex SKIP.n = 1 if (aborted) then do SKIPSTART.n = SESSION.sess.TIMESTART do i = 1 to SESSION.sess.0 SKIPL.n.i = SESSION.sess.i end SKIPL.n.0 = SESSION.sess.0 end else do SKIPSTART.n = timestamp SKIPL.n.1 = line1 SKIPL.n.2 = line2 SKIPL.n.0 = 2 end end return 1 /* getline: returns next line of activity log. sets 'msg' to message number. sets 'eor' to true, if message number exists on line. sets 'eof' to true, if no more lines remain in activity log. */ getline: procedure expose eof eor msg G. parse arg fn . eor=0 msg="x" if (lines(fn) = 0) then do eof=1 return "" end l=linein(fn) parse value l with . . msg . if (left(msg,2)="AN") then eor=1 return l /* masksession: take message text and replace session number with "nn" */ masksession: procedure expose DEBUG G. parse arg msg umsg=upper(msg) sessword=wordpos("SESSION",umsg) if (sessword=0) then return msg sess=subword(msg,sessword+1,1) if (right(sess,1)==".") then sess=substr(sess,1,length(sess)-1) if ^(datatype(sess,"W")) then return msg sesspos=wordindex(msg,sessword+1) prefix=substr(msg,1,sesspos-1) suffix=substr(msg,sesspos+length(subword(msg,sessword+1,1))) msg=prefix".."suffix return msg abortmsg: procedure parse arg msg notmsg="0480 0482" msgno=substr(msg,4,4) select when (wordpos(msgno,notmsg)<>0) then return 0 when ((msgno>="0420") & (msgno<="0598")) then return 1 otherwise return 0 end return 0 /* tapemsg: return 1 if message should be appended to tape history file */ tapemsg: procedure parse arg msg line tape_include_messages="ANR1040I ANR1041I ANR8337I ANR8328I ANR8341I" tape_include_messages=tape_include_messages "ANR8359I" /* should be an E message */ msgno=substr(msg,4,4) msgtype=right(msg,1) msgprefix=left(msg,3) select when (msgprefix<>"ANR") then return 0 when (wordpos(msg,tape_include_messages)<>0) then nop when ((msgno>=8309) & (msgno<=8553) & (msgtype="E")) then nop otherwise return 0 end return 1 uniqout: procedure expose UNIQUE G. parse arg file, line line=strip(line,T) if (UNIQUE="UNIQUE") then UNIQUE=1 /* Assume record is unique */ firstrec=(left(line,2)<>" ") if (firstrec) then do parse value line with x1 x2 xrest line=x1 x2" "xrest '/bin/grep -F -q -s "'line'"' file if (RC=0) then UNIQUE=0 else UNIQUE=1 end if (UNIQUE) then do if (firstrec) then rc=lineout(file,"") /* append CR/LF to end of previous record */ if (^firstrec) then line=" "strip(line) rc=charout(file,line) return 1 end return 0 getsession: procedure expose G. parse arg line sess = "" ul = upper(line) parse value ul with . . . x y . if ((x = "SESSION") & (datatype(y,W))) then sess = y else do parse value ul with "SESSION" y . if (right(y,1)==".") then y=left(y,length(y)-1) if datatype(y,W) then sess = y end if (sess = 1) & (G.$PASSLINE <> line) then do G.$PASS = G.$PASS + 1 G.$PASSLINE = line end if (sess <> "") then sess = sess||":"||G.$PASS return sess /* Messages indicating abnormally terminated session */ termmsg: procedure expose G. parse arg msgno . if (msgno="ANR0484W") then return 1 else return 0 /* parse value msgno with 1 prefix 3 num 8 type if (prefix <> "ANR") then return 0 if (num >= 0480) & (num <= 0489) then return 1 return 0 */ /* Messages indicating the beginning of a session */ beginmsg: procedure parse arg msgno . if (wordpos(msgno,"ANR0400I ANR0402I") <> 0) then return 1 else return 0 /* Messages indicating the end of a session (normally filtered out) */ endmsg: procedure parse arg msgno . if (wordpos(msgno,"ANR0403I ANR0405I ANR0480W ANR0482W") <> 0) then return 1 else return 0 /* Skip the following messages */ skipmsg: procedure parse arg msgno . skiplist="ANR2813I ANR0811I ANR0812I ANR2562I ANR2563I" , "ANR2561I ANR2102I ANR2103I ANR2564I" if (wordpos(msgno,"skiplist") <> 0) then return 1 else return 0 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ /* Legal Information: Although copyrighted, this software is being licensed to you for your use free of charge. However, ownership of and interest in this software shall remain with the author. Use and distribution of this software is governed by the following terms. This software is owned by the author and contains valuable and proprietary information of the author. If you violate any part of this agreement, your right to use this software terminates automatically. In the event of termination of this agreement, you must destroy all copies of this software and derivatives of this software in your possession and cease distributing the same. This software is being licensed to you as provided by the terms of this agreement. You may: 1. Use this software on as many computers as you want at any given time. 2. Make as many backup copies of this software as you want. 3. Alter the software in any manner you see fit FOR YOUR OWN PERSONAL USE. Such altered versions should not be distributed. The creation of such derivatives shall not diminish the author's title to this software. 4. Terminate this agreement at any time by destroying all copies of this software and derivatives of this software and cease distributing the same. You may not: 1. Create any derivative works from this software for distribution. 2. Re-distribute this software for commercial (for-profit) purposes. Contact the author at the address within this document if you wish to distribute this software for commercial usage, or if you have any questions about its redistribution. Disclaimer of warranty: In using this software, you understand and agree that this software is provided "as is" without warranty of any kind. The entire risk as to the results of and performance of using this software lies entirely with you, the user. The author does not make any warranties, either expressed or implied, including but not limited to implied warranties of merchantability and fitness for a particular purpose, with respect to this software. In no event shall the author be liable for any consequential, incidental, or special damages whatsoever arising out of the use or inability to use this software. */