Trailing-Edge
-
PDP-10 Archives
-
SRI_NIC_PERM_SRC_3_19910112
-
utilities/crakup.fai
There are no other files named crakup.fai in the archive.
TITLE CRAKUP - Crash & Uptime Report Generator
SEARCH MONSYM
A=1
B=2
C=3
D=4
W=5
X=6
Y=7
Z=10
P=17
PDLEN=100
OPDEF CALL [PUSHJ P,]
OPDEF RET [POPJ P,]
IJFN: 0
OJFN: 0
PDLIST: BLOCK PDLEN
PRUPTM: 0
UPTIME: 0
DOWNTM: 0
WON: 0
LOST: 0
THISUP: 0
THISDW: 0
FIRSUP: 0
IBFLN==40
INBUF: BLOCK IBFLN
HRS: 0
MIN: 0
SEC: 0
OBFLN==100
OBUF: BLOCK OBFLN
OBUF1: BLOCK 40
OCNT: 0
OPTR: 0
SUBTTL MAIN
START: RESET
HRROI A,[ASCIZ/Welcome to CRAKUP!
/]
PSOUT
MOVE P,[IOWD PDLEN,PDLIST]
CALL GETINP ;setup input file
CALL GETOUP ;setup output file
SETOM PRUPTM ;special for first line, no prev up.
SETZM UPTIME ;total uptime
SETZM DOWNTM ;total downtime
SETZM WON
INLOOP: CALL RREC ;read a record
JRST INEOF ;end of file
MOVE A,THISUP
SKIPG PRUPTM ;first record?
MOVEM A,FIRSUP ;yes. save first uptime.
SUB A,THISDW ;less first downtime =
MOVEM A,LOST ;downtime for this record.
ADDM A,DOWNTM ;augment total downtime
SKIPG PRUPTM ;first record
JRST NOUP ;yes. can't do uptime
MOVE A,THISDW
SUB A,PRUPTM
MOVEM A,WON ;amt of uptime.
ADDM A,UPTIME
NOUP: CALL PREC ;print record
MOVE A,THISUP
MOVEM A,PRUPTM
JRST INLOOP
INEOF: CALL PRSUM ;print summary.
MOVE A,IJFN
CLOSF
ERJMP .+1
CALL OFIN
MOVE A,OJFN
CLOSF
ERJMP .+1
HRROI A,[ASCIZ/Done
/]
PSOUT
HALTF
JRST START
SUBTTL Initialize IO
GETINP: HRROI A,[ASCIZ/Input file: /]
PSOUT
MOVE A,[GJ%OLD!GJ%MSG!GJ%CFM!GJ%FNS!GJ%SHT]
MOVE B,[.PRIIN,,.PRIOU]
GTJFN
ERJMP [MOVEI A,[ASCIZ/Error. please try again
/]
PSOUT
JRST GETINP]
HRRZM A,IJFN
MOVE B,[070000,,OF%RD]
OPENF
ERJMP [MOVEI A,[ASCIZ/Error in OPENF
/]
PSOUT
HRRZ A,IJFN
SETZM IJFN
RLJFN
ERJMP GETINP
JRST GETINP]
RET
GETOUP: HRROI A,[ASCIZ/Output file: /]
PSOUT
MOVE A,[GJ%FOU!GJ%MSG!GJ%CFM!GJ%FNS!GJ%SHT]
MOVE B,[.PRIIN,,.PRIOU]
GTJFN
ERJMP [MOVEI A,[ASCIZ/Error. please try again
/]
PSOUT
JRST GETOUP]
HRRZM A,OJFN
MOVE B,[070000,,OF%WR]
OPENF
ERJMP [MOVEI A,[ASCIZ/Error in OPENF
/]
PSOUT
HRRZ A,OJFN
SETZM OJFN
RLJFN
ERJMP GETOUP
JRST GETOUP]
CALL OINIT
HRROI B,[ASCIZ/
Crash & Uptime Report
Startup Time Crash Time Uptime Lost Time
/] ;setup string. fall into OSTR
CALL OSTR
RET
SUBTTL OSTR, OPUT, OINIT, OFIN
;Call with B=byte pointer to string.
OSTR: TLC B,-1
TLCN B,-1
HRLI B,440700
OSTR1: ILDB A,B
JUMPE A,CPOPJ
CALL OPUT
JRST OSTR1
OINIT: MOVE A,[POINT 7,OBUF]
MOVEM A,OPTR
MOVEI A,OBFLN*5-1
MOVEM A,OCNT
RET
OFIN: PUSH P,A
PUSH P,B
PUSH P,C
MOVEI A,0
IDPB A,OPTR
MOVE A,OJFN
HRROI B,OBUF
MOVEI C,0
SOUT
ERJMP .+1
CALL OINIT
POP P,C
POP P,B
POP P,A
RET
OPUT1: CALL OFIN ;finish this buffer-full.
OPUT: JUMPE A,CPOPJ
SOSGE OCNT ;decrement byte count
JRST OPUT1 ;no room left in buffer
IDPB A,OPTR
RET
SUBTTL INPUT SCAN.
RREC: MOVE A,IJFN
HRROI B,INBUF
MOVEI C,IBFLN*5-2
MOVEI D,12
SIN
ERJMP SINNER
MOVEI A,0
IDPB A,B
MOVE A,[POINT 7,INBUF]
MOVEI B,":"
CALL SKIPIN
JRST ILFMT
MOVE B,[IT%AIS!IT%AAC] ;expect seconds and colons.
IDTIM
ERJMP INVTIM ;invalid time
MOVEM B,THISUP
MOVEI B,":"
CALL SKIPIN
JRST ILFMT
MOVE B,[IT%AIS!IT%AAC]
IDTIM
ERJMP INVTIM
MOVEM B,THISDW
CAMG B,THISUP
JRST CPOPJ1
HRROI B,[ASCIZ/Reject Bad record:
/]
CALL OSTR
HRROI B,INBUF
CALL OSTR
HRROI B,[ASCIZ/
/]
CALL OSTR
MOVE A,THISDW
ADDI A,5000
MOVEM A,THISUP
JRST CPOPJ1
SKIPIN: ILDB C,A
CAMN C,B
CPOPJ1: AOSA (P)
JUMPN C,SKIPIN
CPOPJ: RET
INVTIM: HRROI A,[ASCIZ/Error in Date & Time Scan
/]
INERR: PSOUT
HRROI A,INBUF
PSOUT
HALTF
JRST RREC
ILFMT: HRROI A,[ASCIZ/Error in input line format
/]
JRST INERR
SINNER: MOVE A,IJFN
GTSTS
TDNE B,[GS%EOF]
RET
HRROI A,[ASCIZ/Input error other than EOF
/]
PSOUT
HALTF
SUBTTL PRINT REPORT
PREC: SKIPG B,PRUPTM
JRST [HRROI B,[ASCIZ/ /]
CALL OSTR
JRST PREC1]
HRROI A,OBUF1
MOVEI C,0
ODTIM
ERJMP .+1
IDPB C,A
HRROI B,OBUF1
CALL OSTR
PREC1: HRROI B,[ASCIZ/ /]
CALL OSTR
MOVE B,THISDW
MOVEI C,0
HRROI A,OBUF1
ODTIM
ERJMP .+1
HRROI B,OBUF1
CALL OSTR
HRROI B,[ASCIZ/ /]
CALL OSTR
SKIPG PRUPTM
JRST [HRROI B,[ASCIZ/ /]
CALL OSTR
JRST PREC2]
MOVE A,WON
CALL PRHMS
PREC2: HRROI B,[ASCIZ/ /]
CALL OSTR
MOVE A,LOST
CALL PRHMS
HRROI B,[ASCIZ/
/]
CALL OSTR
RET
PRSUM: HRROI A,OBUF1
MOVEI C,0
MOVE B,PRUPTM
ODTIM
ERJMP .+1
HRROI B,OBUF1
CALL OSTR
HRROI B,[ASCIZ/ Totals (/]
CALL OSTR
MOVE A,UPTIME
MULI A,1750*144 ;note double-word result
MOVE C,UPTIME
ADD C,DOWNTM
DIV A,C ;pct uptime times 1000
IDIVI A,1750
PUSH P,B ;.000 pct
MOVEI C,2
MOVEI D," "
CALL PRDEC
MOVEI A,"."
CALL OPUT
POP P,A
MOVEI C,3
MOVEI D,"0"
CALL PRDEC
HRROI B,[ASCIZ/% up) /]
CALL OSTR
MOVE A,UPTIME
CALL PRHMS
HRROI B,[ASCIZ/ /]
CALL OSTR
MOVE A,DOWNTM
CALL PRHMS
HRROI B,[ASCIZ/
/]
CALL OSTR
RET
;in this time format, 1,,0 = 24 hours. Call with A=time
PRHMS: HLRZ B,A ;copy days portion
IMULI B,30 ;times 24 is hours
MOVEM B,HRS ;save hours, thus far.
HRRZ A,A
LSH A,20 ;shift 16 bits. 200000,,0=24 hrs
IDIV A,[<200000,,>/<74*74*30>] ;divide by 86,000 sec/day
IDIVI A,74 ;seconds in B, H:M in A
MOVEM B,SEC
IDIVI A,74
MOVEM B,MIN
ADDB A,HRS
MOVEI C,4 ;number of digits to print
MOVEI D," " ;fill character
CALL PRDEC
MOVEI A,":"
CALL OPUT
MOVE A,MIN
MOVEI C,2
MOVEI D,"0"
CALL PRDEC
MOVEI A,":"
CALL OPUT
MOVE A,SEC
MOVEI C,2
MOVEI D,"0"
CALL PRDEC
MOVEI A," "
JRST OPUT
PRDEC: IDIVI A,12
HRLM B,(P)
SUBI C,1
JUMPE A,PRDEC1
CALL PRDEC
PRDEC2: HLRZ A,(P)
ADDI A,"0"
JRST OPUT
PRDEC1: JUMPLE C,PRDEC2
MOVE A,D
CALL OPUT
SOJA C,PRDEC1
END START