program qse cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c c QSE - Accounting file preformatter program c c This program scans the accounting file created by the KMS c accounting system and inserts STOP records when they are c missing (which occurs when the system accounting was abnormally c terminated, ie. system crash). This program also produces a c subset file by date range. The raw accounting file must pass c through this program before being analysed! c c Author: Don Rubin Version: 1.0 May 1981 c cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc c integer*2 ibuf(13),nmdays(12),today(3),stdate(3),stpdat(3) integer*2 curtim(3),curdat(3),uics(2,50),zero(3) integer*4 iqios,cputim logical*1 infile(24),lfile(24),totals,sumday,termid(2),uic(2) logical*1 uichel(50),uicbye(50),q,ok c common uics c c -- start record c equivalence (irec,ibuf(1)) equivalence (ihr,ibuf(2)) equivalence (imin,ibuf(3)) equivalence (isec,ibuf(4)) equivalence (iyear,ibuf(5)) equivalence (imonth,ibuf(6)) equivalence (iday,ibuf(7)) c c -- hel/bye record c equivalence (termid,ibuf(5)) equivalence (iacnt,ibuf(6)) equivalence (uic,ibuf(7)) equivalence (cputim,ibuf(8)) ! i*4 word matches 2 bfr words equivalence (iqios,ibuf(10)) ! i*4 word matches 2 bfr words equivalence (irunct,ibuf(12)) equivalence (insct,ibuf(13)) c data nmdays /31,29,31,30,31,30,31,31,30,31,30,31/,lun2/2/ c c c prompt for and open input file c type 99 99 format('$Enter input filename ') accept 81,j,infile if(j.le.0)call exit infile(J+1)=0 c open(unit=2, ! open default file - name = infile, !'LB:[1,4]SYSLOG.DAT', - readonly, ! - form = 'UNFORMATTED', ! - type = 'OLD', ! - access = 'SEQUENTIAL', ! - shared, ! log... must have write acces - err = 9000) ! c call idate(today(1),today(2),today(3)) c type 90 90 format('$Enter start date in the form DD,MM,YY [default 1,1,80] ') accept 80,stdate if(stdate(1).eq.0)stdate(1)=1 !default day if(stdate(2).eq.0)stdate(2)=1 !default month if(stdate(3).eq.0)stdate(3)=80 !default year c type 91 91 format('$Enter stop date in the form DD,MM,YY [default today ] ') accept 80,stpdat if(stpdat(1).eq.0)stpdat(1)=today(2) !default day if(stpdat(2).eq.0)stpdat(2)=today(1) !default month if(stpdat(3).eq.0)stpdat(3)=today(3) !default year c c see if stop date is greater than or equal to start date c do 22 j=3,1,-1 if(stpdat(j).lt.stdate(j))goto 3 !branch if error 22 continue goto 10 3 stop 'Stop day must be <= start day' c c position file to the start date c 10 read(2,err=9100,end=9990) ibuf if(irec.ne.1)goto 10 call daybeg(ibuf,stdate,ok) !check date if(.not.ok)goto 10 !branch if not at start date yet c call dayend(ibuf,stpdat,ok) !check to see if past stop date if(.not.ok)goto 600 c last=-1 !mark last record read as STOP c c prompt for and open output file c type 92 92 format('$Enter output filename ') accept 81,j,lfile if(j.le.0)call exit lfile(J+1)=0 c open(unit = 1, - name = lfile, - form = 'UNFORMATTED', - type = 'NEW', - access = 'SEQUENTIAL', - err = 9000) c q=.false. goto 200 !branch to START c c loop for each record in the input file c 100 nrec=nrec+1 !bump number of records read read(2,end=150,err=9100)ibuf c call notequ(ibuf(2),zero,ok) !if time is zero then record isnt valid if(ok)goto 101 c if(irec.eq.1) goto 200 !START record call copy(ibuf(2),curtim,3) !copy new start time to current time if(irec.eq.-1)goto 300 !STOP record if(irec.eq.5) goto 400 !HEL record if(irec.eq.6) goto 500 !BYE record 101 ibad=ibad+1 !bump number of bad records goto 100 c c end of file c 150 if(last.eq.-1)goto 600 !normal EOF q=.true. goto 201 !process as if no STOP record c c START record c 200 if(last.eq.-1)goto 250 !last record was STOP 201 last=-1 !mark as if last was STOP goto 300 !generate STOP record 250 call copy(ibuf(5),curdat,3) !copy new start date to current date call copy(ibuf(2),curtim,3) !copy new start time to current time write(1)ibuf !write out record last=1 !last was START goto 390 c c STOP record c 300 if(numuic.le.0)goto 360 !no one logged on while system was up do 350 j=1,numuic !do for each account present if(.not.uicbye(j))write(1)6,curtim,uics(1,j),0,uics(2,j),0,0,0,0,0,0 350 continue c 360 if(last.ne.-1)goto 370 write(1)-1,curtim,curdat,0,60,0,0,0,0 !generate stop record goto 250 !go back and output START record 370 write(1)ibuf c c clear accounting pointers c 390 do 395 j=1,numuic uicbye(j)=.false. uichel(j)=.false. 395 continue last=-1 !last was a STOP record numuic=0 goto 100 c c HELLO record c 400 j=iuic(ibuf,numuic) !get pointer to this account if(j.le.0)goto 101 !bad account uichel(j)=.true. !mark account in use last=5 !last is HELLO write(1)ibuf !write record to output file goto 100 c c BYE record c 500 j=iuic(ibuf,numuic) !get pointer to this account if(j.le.0)goto 101 !bad account uicbye(j)=.true. !mark account not in use last=6 !last is BYE write(1)ibuf !write record to output file goto 100 c 600 type 987,nrec-ibad,ibad 987 format(1x,'Number of good,bad records=',2i6) close (unit=1) close (unit=2) call exit 80 format(3i5) 81 format(q,24a1) 9100 stop 'error during read' 9000 stop 'error during open' 9990 stop 'requested date not in file' end