INHOA1 ; JMB; 6 Jul 99 15:30; Background Process Monitor cont.
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
Q
;
; PART 1: VERIFY STATUS
;
DISV ;Display Verify Status
N INQ,INK
;
;Display Main header, verify status header
D HD,HDV
;
S INQ="" F S INQ=$O(INDAT(INQ)) Q:'INQ S INK="" F S INK=$O(INDAT(INQ,INK)) Q:'$L(INK) D
.D:$$OVF HDV
.W !
.I '$L(INDAT(INQ,INK,"RUN")) W " Y"
.E W ?1,INDAT(INQ,INK,"RUN")
.W:'INK ?TAB(1),"MAIN"
.W:INK>0 ?TAB(1),"SERVER ",INK
.;Display Last Run Update Stats
.D DISV1(0)
.W:$L($G(INDAT(INQ,INK,"MES"))) !,?TAB(1)+2,$E(INDAT(INQ,INK,"MES"),1,28)
.;Display Last Event Stats
.D:$L($G(INDAT(INQ,INK,1,"ELS"))) DISV1(1)
D MSG
Q
;
DISV1(DA) ;Display Stats
;INPUT: DA = 0 - Last Run Update Stats
; 1 - Last Event Stats
;
I DA=1,'$L($G(INDAT(INQ,INK,"MES"))) W !
W ?TAB(2),$J($$FT0^INHUTS($G(INDAT(INQ,INK,DA,"LRU"))),10)
W ?TAB(3),$J($$FT1^INHUTS($G(INDAT(INQ,INK,DA,"ELS")),1),7)
W ?TAB(4),$J($$FT1^INHUTS($G(INDAT(INQ,INK,DA,"MIN")),2),6)
W ?TAB(5),$J($$FT1^INHUTS($G(INDAT(INQ,INK,DA,"MAX")),2),6)
W ?TAB(6),$J($$FT1^INHUTS($G(INDAT(INQ,INK,DA,"AET")),2),6)
Q
;
HDV ;Verify Status Header
W !!,"**RUN STATUS** $JOB: ",$P(^INTHPC(BPC,0),U,4)
D HD1
S SEL=$S(INPAR("DETAIL"):"DET",1:"BRF") D @SEL
W !,"---"
W ?TAB(1),"------------------------------",?TAB(2),"----------"
W ?TAB(3),"-------"
F X=TAB(4),TAB(5),TAB(6) W ?X,"------"
Q
DET ;Verify Status, Detail Report Header
W !,"Run",?TAB(1),"Server/",?TAB(2),"Last Run/"
W ?TAB(3)+6,"(defaults in seconds)"
W !,?TAB(1)+2,"Message",?TAB(2)," Last Msg",?TAB(3),"Elapsed"
W ?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
Q
BRF ;Verify Status, Brief Report Header
W !,?TAB(3)+6,"(defaults in seconds)",!
W "Run",?TAB(1),"Server",?TAB(2),"Last Run"
W ?TAB(3),"Elapsed"
W ?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
Q
;
MSG ;Verify Status, special message
; Diplay legend if at least one process has RUN status equal to "Q".
W:INSIG !!,"NOTE: RUN=Q Stands for ""Background Process Signaled to Quit"""
Q
;
HD1 ;Verify Status, Display warning message
Q:'INWARN
W !," WARNING: Report being run elsewhere. Results may not be accurate."
Q
;
; PART 2: QUEUE SIZE
;
DISQ ;Display Queue Size
N INQ,IN0,P,T
I $$OVF
D HDQ
;Work through INDAT array
; IN0 - Flag
S INQ=0 F S INQ=$O(INDAT(INQ)) Q:'INQ S IN0=0 D
. S P="" F S P=$O(INDAT(INQ,P)) Q:(+P'=P)!('INPAR("DETAIL")) S T="" F S T=$O(INDAT(INQ,P,T)) Q:'$L(T) D DPRI(INQ,P,T,.IN0)
.;Display queues with 0 totals
.;If there is only one priority level for queue INQ, do not
.; display total by priority, since data is repeated
.;Display overall totals
.;Display Brief report
.I ('INDAT(INQ,"COUNT"))&(IN0=0)!(IN0>1)!(INQ>300)!('INPAR("DETAIL")) D DTOT(INQ,IN0)
;
D FTR
Q
;
DPRI(INQ,P,T,IN0) ;Display queue size by priority level
W !
S IN0=IN0+1
W ?TAB(2)+5,P W:T="ST" " STAT"
W ?TAB(3)+1,$J(INDAT(INQ,P,T,"COUNT"),6)
W ?TAB(4),$J(INDAT(INQ,P,T,"MIN"),6)
W ?TAB(5),$J(INDAT(INQ,P,T,"MAX"),6)
W ?TAB(6),$J(INDAT(INQ,P,T,"AVG"),6)
D:$$OVF HDQ
Q
;
DTOT(INQ,IN0) ;Display queue totals
;
; New line before displaying "Total" string, "Transactions
; identified per hour"
W:INQ'=700 !
; multiple priority totals
W:IN0>1 ?TAB(2)," Total:"
; One blank line before "Messages created per hour"
W:INQ=700 !!
; If there is overflow display Messages created per hour and
; Transactions identified per hour in the same page.
I INQ=700,$$OVF D HDQ W !
W:INQ>200 $J(INDAT(INQ,"NAME"),45)_":"
W ?TAB(3)+1,$J(INDAT(INQ,"COUNT"),6),?TAB(4),$J(INDAT(INQ,"MIN"),6)
W ?TAB(5),$J(INDAT(INQ,"MAX"),6),?TAB(6),$J(INDAT(INQ,"AVG"),6)
Q
;
HDQ ;Queue Size Header
N T
W !!,"**QUEUE SIZE (#entries)**"
W:INPAR("DETAIL") ?TAB(2)+2,"Priority"
W ?TAB(3)," Curr",?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
W !
W:INPAR("DETAIL") ?TAB(2)+2,"--------"
W ?TAB(3)+1,"------"
F T=4:1:6 W ?TAB(T),"------"
Q
;
; PART 3: TOP ENTRIES
;
DIST ;Display TOP Entries
N INQ,IN1,P,T,TAB
S TAB(1)=7,TAB(2)=19,TAB(3)=28,TAB(4)=40,TAB(5)=51
I $$OVF
;Paint header
D HDT(.TAB)
;Display data
;Work through INDAT array
; IN1 - Flag to display queue name only once
S INQ=0 F S INQ=$O(INDAT(INQ)) Q:'INQ S P="" F S P=$O(INDAT(INQ,P)) Q:+P'=P D
.S T="" F S T=$O(INDAT(INQ,P,T)) Q:'$L(T) D
.. W !,$J(P,3),?TAB(1),$J(INDAT(INQ,P,T),10)
.. W ?TAB(2),$J(INDAT(INQ,P,T,"DIFF"),7)
.. W ?TAB(3),$J($E(INDAT(INQ,P,T,"MSGID"),1,10),10)
.. W ?TAB(4),$J(INDAT(INQ,P,T,"DA"),9)
.. W ?TAB(5),$E(INDAT(INQ,P,T,"TT"),1,29)
I $$OVF D HDT(.TAB)
Q
;
HDT(TAB) ;TOP entries header
W !!,"**TOP ENTRIES**"
W !,"Prio",?TAB(1),"Scheduled",?TAB(2)," Age",?TAB(3),"Message Id"
W ?TAB(4)," Record",?TAB(5),"Transaction Type"
W !,"-----",?TAB(1),"----------",?TAB(2),"-------",?TAB(3),"----------",?TAB(4),"---------",?TAB(5),"-----------------------------"
Q
;
; COMMON SUBROUTINES:
;
HD ;Display main header
;
;Calculate run time = now-start
S INRUN=$$TDIF^INHUTS(INPAR("START"),$H),INRUNASC=$$FORMAT^INHUTS(INRUN)
;Calculate average run time per iteration
S INRUNAVG=$$FORMAT^INHUTS(INRUN\INITER,2)
W @IOF
W $P(INPAR("PROCESS"),U,2),?55,$$CDATASC^UTDT($$NOW^UTDT,1,1)
W !,?5,"Start Time: ",$$CDATASC^UTDT(INPAR("START"),1,1)
W ?40," Number of Iterations: ",INITER
W !,?5," Run Time: ",INRUNASC,?40,"Avg Time per Iteration: ",INRUNAVG
Q
;
FTR ;Display footer
I INTASKED W !!!,"End of Report." Q
W !!,"Press any key to exit: "
Q
;
OVF() ;Handle overflow
Q:$Y<(IOSL-4) 0
W !,"More..." F X=1:1:INPAR("REPAINT") Q:INTASKED R *%:1 Q:$T
D HD
Q 1
INHOA1 ; JMB; 6 Jul 99 15:30; Background Process Monitor cont.
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 QUIT
+4 ;
+5 ; PART 1: VERIFY STATUS
+6 ;
DISV ;Display Verify Status
+1 NEW INQ,INK
+2 ;
+3 ;Display Main header, verify status header
+4 DO HD
DO HDV
+5 ;
+6 SET INQ=""
FOR
SET INQ=$ORDER(INDAT(INQ))
IF 'INQ
QUIT
SET INK=""
FOR
SET INK=$ORDER(INDAT(INQ,INK))
IF '$LENGTH(INK)
QUIT
Begin DoDot:1
+7 IF $$OVF
DO HDV
+8 WRITE !
+9 IF '$LENGTH(INDAT(INQ,INK,"RUN"))
WRITE " Y"
+10 IF '$TEST
WRITE ?1,INDAT(INQ,INK,"RUN")
+11 IF 'INK
WRITE ?TAB(1),"MAIN"
+12 IF INK>0
WRITE ?TAB(1),"SERVER ",INK
+13 ;Display Last Run Update Stats
+14 DO DISV1(0)
+15 IF $LENGTH($GET(INDAT(INQ,INK,"MES")))
WRITE !,?TAB(1)+2,$EXTRACT(INDAT(INQ,INK,"MES"),1,28)
+16 ;Display Last Event Stats
+17 IF $LENGTH($GET(INDAT(INQ,INK,1,"ELS")))
DO DISV1(1)
End DoDot:1
+18 DO MSG
+19 QUIT
+20 ;
DISV1(DA) ;Display Stats
+1 ;INPUT: DA = 0 - Last Run Update Stats
+2 ; 1 - Last Event Stats
+3 ;
+4 IF DA=1
IF '$LENGTH($GET(INDAT(INQ,INK,"MES")))
WRITE !
+5 WRITE ?TAB(2),$JUSTIFY($$FT0^INHUTS($GET(INDAT(INQ,INK,DA,"LRU"))),10)
+6 WRITE ?TAB(3),$JUSTIFY($$FT1^INHUTS($GET(INDAT(INQ,INK,DA,"ELS")),1),7)
+7 WRITE ?TAB(4),$JUSTIFY($$FT1^INHUTS($GET(INDAT(INQ,INK,DA,"MIN")),2),6)
+8 WRITE ?TAB(5),$JUSTIFY($$FT1^INHUTS($GET(INDAT(INQ,INK,DA,"MAX")),2),6)
+9 WRITE ?TAB(6),$JUSTIFY($$FT1^INHUTS($GET(INDAT(INQ,INK,DA,"AET")),2),6)
+10 QUIT
+11 ;
HDV ;Verify Status Header
+1 WRITE !!,"**RUN STATUS** $JOB: ",$PIECE(^INTHPC(BPC,0),U,4)
+2 DO HD1
+3 SET SEL=$SELECT(INPAR("DETAIL"):"DET",1:"BRF")
DO @SEL
+4 WRITE !,"---"
+5 WRITE ?TAB(1),"------------------------------",?TAB(2),"----------"
+6 WRITE ?TAB(3),"-------"
+7 FOR X=TAB(4),TAB(5),TAB(6)
WRITE ?X,"------"
+8 QUIT
DET ;Verify Status, Detail Report Header
+1 WRITE !,"Run",?TAB(1),"Server/",?TAB(2),"Last Run/"
+2 WRITE ?TAB(3)+6,"(defaults in seconds)"
+3 WRITE !,?TAB(1)+2,"Message",?TAB(2)," Last Msg",?TAB(3),"Elapsed"
+4 WRITE ?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
+5 QUIT
BRF ;Verify Status, Brief Report Header
+1 WRITE !,?TAB(3)+6,"(defaults in seconds)",!
+2 WRITE "Run",?TAB(1),"Server",?TAB(2),"Last Run"
+3 WRITE ?TAB(3),"Elapsed"
+4 WRITE ?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
+5 QUIT
+6 ;
MSG ;Verify Status, special message
+1 ; Diplay legend if at least one process has RUN status equal to "Q".
+2 IF INSIG
WRITE !!,"NOTE: RUN=Q Stands for ""Background Process Signaled to Quit"""
+3 QUIT
+4 ;
HD1 ;Verify Status, Display warning message
+1 IF 'INWARN
QUIT
+2 WRITE !," WARNING: Report being run elsewhere. Results may not be accurate."
+3 QUIT
+4 ;
+5 ; PART 2: QUEUE SIZE
+6 ;
DISQ ;Display Queue Size
+1 NEW INQ,IN0,P,T
+2 IF $$OVF
+3 DO HDQ
+4 ;Work through INDAT array
+5 ; IN0 - Flag
+6 SET INQ=0
FOR
SET INQ=$ORDER(INDAT(INQ))
IF 'INQ
QUIT
SET IN0=0
Begin DoDot:1
+7 SET P=""
FOR
SET P=$ORDER(INDAT(INQ,P))
IF (+P'=P)!('INPAR("DETAIL"))
QUIT
SET T=""
FOR
SET T=$ORDER(INDAT(INQ,P,T))
IF '$LENGTH(T)
QUIT
DO DPRI(INQ,P,T,.IN0)
+8 ;Display queues with 0 totals
+9 ;If there is only one priority level for queue INQ, do not
+10 ; display total by priority, since data is repeated
+11 ;Display overall totals
+12 ;Display Brief report
+13 IF ('INDAT(INQ,"COUNT"))&(IN0=0)!(IN0>1)!(INQ>300)!('INPAR("DETAIL"))
DO DTOT(INQ,IN0)
End DoDot:1
+14 ;
+15 DO FTR
+16 QUIT
+17 ;
DPRI(INQ,P,T,IN0) ;Display queue size by priority level
+1 WRITE !
+2 SET IN0=IN0+1
+3 WRITE ?TAB(2)+5,P
IF T="ST"
WRITE " STAT"
+4 WRITE ?TAB(3)+1,$JUSTIFY(INDAT(INQ,P,T,"COUNT"),6)
+5 WRITE ?TAB(4),$JUSTIFY(INDAT(INQ,P,T,"MIN"),6)
+6 WRITE ?TAB(5),$JUSTIFY(INDAT(INQ,P,T,"MAX"),6)
+7 WRITE ?TAB(6),$JUSTIFY(INDAT(INQ,P,T,"AVG"),6)
+8 IF $$OVF
DO HDQ
+9 QUIT
+10 ;
DTOT(INQ,IN0) ;Display queue totals
+1 ;
+2 ; New line before displaying "Total" string, "Transactions
+3 ; identified per hour"
+4 IF INQ'=700
WRITE !
+5 ; multiple priority totals
+6 IF IN0>1
WRITE ?TAB(2)," Total:"
+7 ; One blank line before "Messages created per hour"
+8 IF INQ=700
WRITE !!
+9 ; If there is overflow display Messages created per hour and
+10 ; Transactions identified per hour in the same page.
+11 IF INQ=700
IF $$OVF
DO HDQ
WRITE !
+12 IF INQ>200
WRITE $JUSTIFY(INDAT(INQ,"NAME"),45)_":"
+13 WRITE ?TAB(3)+1,$JUSTIFY(INDAT(INQ,"COUNT"),6),?TAB(4),$JUSTIFY(INDAT(INQ,"MIN"),6)
+14 WRITE ?TAB(5),$JUSTIFY(INDAT(INQ,"MAX"),6),?TAB(6),$JUSTIFY(INDAT(INQ,"AVG"),6)
+15 QUIT
+16 ;
HDQ ;Queue Size Header
+1 NEW T
+2 WRITE !!,"**QUEUE SIZE (#entries)**"
+3 IF INPAR("DETAIL")
WRITE ?TAB(2)+2,"Priority"
+4 WRITE ?TAB(3)," Curr",?TAB(4)," Min",?TAB(5)," Max",?TAB(6)," Avg"
+5 WRITE !
+6 IF INPAR("DETAIL")
WRITE ?TAB(2)+2,"--------"
+7 WRITE ?TAB(3)+1,"------"
+8 FOR T=4:1:6
WRITE ?TAB(T),"------"
+9 QUIT
+10 ;
+11 ; PART 3: TOP ENTRIES
+12 ;
DIST ;Display TOP Entries
+1 NEW INQ,IN1,P,T,TAB
+2 SET TAB(1)=7
SET TAB(2)=19
SET TAB(3)=28
SET TAB(4)=40
SET TAB(5)=51
+3 IF $$OVF
+4 ;Paint header
+5 DO HDT(.TAB)
+6 ;Display data
+7 ;Work through INDAT array
+8 ; IN1 - Flag to display queue name only once
+9 SET INQ=0
FOR
SET INQ=$ORDER(INDAT(INQ))
IF 'INQ
QUIT
SET P=""
FOR
SET P=$ORDER(INDAT(INQ,P))
IF +P'=P
QUIT
Begin DoDot:1
+10 SET T=""
FOR
SET T=$ORDER(INDAT(INQ,P,T))
IF '$LENGTH(T)
QUIT
Begin DoDot:2
+11 WRITE !,$JUSTIFY(P,3),?TAB(1),$JUSTIFY(INDAT(INQ,P,T),10)
+12 WRITE ?TAB(2),$JUSTIFY(INDAT(INQ,P,T,"DIFF"),7)
+13 WRITE ?TAB(3),$JUSTIFY($EXTRACT(INDAT(INQ,P,T,"MSGID"),1,10),10)
+14 WRITE ?TAB(4),$JUSTIFY(INDAT(INQ,P,T,"DA"),9)
+15 WRITE ?TAB(5),$EXTRACT(INDAT(INQ,P,T,"TT"),1,29)
End DoDot:2
End DoDot:1
+16 IF $$OVF
DO HDT(.TAB)
+17 QUIT
+18 ;
HDT(TAB) ;TOP entries header
+1 WRITE !!,"**TOP ENTRIES**"
+2 WRITE !,"Prio",?TAB(1),"Scheduled",?TAB(2)," Age",?TAB(3),"Message Id"
+3 WRITE ?TAB(4)," Record",?TAB(5),"Transaction Type"
+4 WRITE !,"-----",?TAB(1),"----------",?TAB(2),"-------",?TAB(3),"----------",?TAB(4),"---------",?TAB(5),"-----------------------------"
+5 QUIT
+6 ;
+7 ; COMMON SUBROUTINES:
+8 ;
HD ;Display main header
+1 ;
+2 ;Calculate run time = now-start
+3 SET INRUN=$$TDIF^INHUTS(INPAR("START"),$HOROLOG)
SET INRUNASC=$$FORMAT^INHUTS(INRUN)
+4 ;Calculate average run time per iteration
+5 SET INRUNAVG=$$FORMAT^INHUTS(INRUN\INITER,2)
+6 WRITE @IOF
+7 WRITE $PIECE(INPAR("PROCESS"),U,2),?55,$$CDATASC^UTDT($$NOW^UTDT,1,1)
+8 WRITE !,?5,"Start Time: ",$$CDATASC^UTDT(INPAR("START"),1,1)
+9 WRITE ?40," Number of Iterations: ",INITER
+10 WRITE !,?5," Run Time: ",INRUNASC,?40,"Avg Time per Iteration: ",INRUNAVG
+11 QUIT
+12 ;
FTR ;Display footer
+1 IF INTASKED
WRITE !!!,"End of Report."
QUIT
+2 WRITE !!,"Press any key to exit: "
+3 QUIT
+4 ;
OVF() ;Handle overflow
+1 IF $Y<(IOSL-4)
QUIT 0
+2 WRITE !,"More..."
FOR X=1:1:INPAR("REPAINT")
IF INTASKED
QUIT
READ *%:1
IF $TEST
QUIT
+3 DO HD
+4 QUIT 1