KMPDTP6 ;OAK/RAK/JML - CP Timing Real-Time Threshold Alert ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
EN ;-- entry point
;
N I,KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
N ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
;
S KMPDTTL=" Coversheet Time-to-Load Alert Report > Real-Time "
D HDR^KMPDUTL4(KMPDTTL)
W !
W !?7,"This alerting report shows the particular coversheet loads"
W !?7,"that have excessive time-to-load values for TODAY (Real-Time)."
W !?7,"This report will search for a particular person, a particular"
W !?7,"client name or IP address."
W !?7,"Foreground and background times are combined."
W !
;
; if no data
I ($O(^KMPTMP("KMPDT","ORWCV",""))="")&($O(^KMPTMP("KMPDT","ORWCV-FT",""))="") D Q
.W !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"", ***"
;
; hours
S KMPDHOUR=$$RLTMHR^KMPDTU11(0,1,1)
Q:KMPDHOUR=""
;
; time-to-load threshold seconds
S KMPDTSEC=$$TTLSEC^KMPDTU10
Q:'KMPDTSEC
;
; search by
D SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV",1)
Q:'KMPDSRCH
;
; select output device.
S %ZIS="Q",%ZIS("A")="Device: ",%ZIS("B")="HOME"
W ! D ^%ZIS I POP W !,"No action taken." Q
; if queued.
I $D(IO("Q")) K IO("Q") D Q
.S ZTDESC=KMPDTTL
.S ZTRTN="EN1^KMPDTP6"
.F I="KMPDHOUR","KMPDSRCH","KMPDTSEC","KMPDTTL" S ZTSAVE(I)=""
.D ^%ZTLOAD W:$G(ZTSK) !,"Task #",ZTSK
.D EXIT
;
; if output to terminal display message.
W:$E(IOST,1,2)="C-" !,"Compiling timing stats..."
D EN1
;
Q
;
EN1 ;-- entry point from taskman
Q:'$D(KMPDHOUR)
Q:'$D(KMPDSRCH)
Q:'$G(KMPDTSEC)
Q:$G(KMPDTTL)=""
;
K ^TMP($J)
D DATA,PRINT,EXIT
K ^TMP($J)
Q
;
DATA ;-- compile data
;
Q:'$D(KMPDHOUR)
Q:'$G(KMPDSRCH)
Q:'$G(KMPDTSEC)
;
N DATA,DATA1,DATE,DATE1,DELTA,DOT,HOUR,HR,I,QUEUED,TIME
N KMPDSS,DELTA,TOTDELT,KMPDUZ
;
S DOT=1,QUEUED=$D(ZTQUEUED)
; set up HOUR() array
F I=1:1:24 S:$P(KMPDHOUR,",",I)'="" HOUR(+$P(KMPDHOUR,",",I))=""
Q:'$D(HOUR)
; collect raw data
F KMPDSS="ORWCV","ORWCV-FT" D
.S I=""
.F S I=$O(^KMPTMP("KMPDT",KMPDSS,I)) Q:I="" S DATA=^(I) I DATA]"" D
..S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
..; start/end date/time in fileman format
..S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
..Q:'DATE(1)!('DATE(2))
..S ^TMP($J,"DATA",I,KMPDSS)=DATA
; collate raw data - combined FG and BG
S I=""
F S I=$O(^TMP($J,"DATA",I)) Q:I="" D
.S (KMPDSS,DATA1,KMPDUZ)=""
.S (DELTA,TOTDELT)=0
.F KMPDSS="ORWCV","ORWCV-FT" D
..S DATA=$G(^TMP($J,"DATA",I,KMPDSS))
..Q:DATA=""
..S KMPDUZ=$P(DATA,U,3)
..S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
..Q:'DATE(1)!('DATE(2))
..; get delta
..S DELTA=$$HDIFF^XLFDT($P(DATA,U,2),$P(DATA,U),2)
..; determine hour
..S HR=+$E($P(DATE(1),".",2),1,2)
..S HR=$S(HR="":0,HR=24:0,1:HR)
..; quit if not in HOUR() array
..Q:'$D(HOUR(HR))
..; date without time
..S DATE1=$P(DATE(1),".") Q:'DATE1
..S TOTDELT=$G(TOTDELT)+DELTA
..S DATA1="^^^"_TOTDELT_"^"_$P(DATA,U,3)_"^"_$P(DATA,U,4)_"^^^"_$P($P(I," ",2),"-")
.Q:DATA1=""
.Q:'$$MATCH
.Q:$P(DATA1,"^",4)<KMPDTSEC
.; hour & second
.S TIME=$P(DATE(1),".",2) Q:'TIME
.; insert colon (:) between hour & second
.S TIME=$E(TIME,1,2)_":"_$E(TIME,3,4)_":"_$E(TIME,5,6)
.S:$P(TIME,":",2)="" $P(TIME,":",2)="00"
.S:$P(TIME,":",3)="" $P(TIME,":",3)="00"
.S ^TMP($J,"RPT",DATE1,TIME)=DATA1
.; new person - external format
.S $P(^TMP($J,"RPT",DATE1,TIME),U,5)=$P($G(^VA(200,KMPDUZ,0)),U)
Q
;
PRINT ;-- print data
;
U IO
D HDR
Q:'$D(^TMP($J))
N CONT,DATE,I,TOTAL
S DATE="",CONT=1,TOTAL=0
F S DATE=$O(^TMP($J,"RPT",DATE)) Q:'DATE D Q:'CONT
.W !,$$FMTE^XLFDT(DATE,2) S HR=""
.F S HR=$O(^TMP($J,"RPT",DATE,HR)) Q:HR="" D Q:'CONT
..I $Y>(IOSL-4) D Q:'CONT
...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
...D HDR W !,$$FMTE^XLFDT(DATE,2)
..W ?10,HR
..S DATA=^TMP($J,"RPT",DATE,HR),TOTAL=TOTAL+1
..; user name
..W ?20,$S($P(DATA,U,5)]"":$E($P(DATA,U,5),1,19),1:"N/A")
..; client name
..W ?39,$S($P(DATA,U,6)]"":$E($P(DATA,U,6),1,19),1:"N/A")
..; ip address
..W ?60,$S($P(DATA,U,9)]"":$P(DATA,U,9),1:"N/A")
..; server delta
..W ?75,$P(DATA,U,4)
..W ! W:$E($O(^TMP($J,"RPT",DATE,HR)),1,2)'=$E(HR,1,2) !
;
I CONT&(TOTAL) W !!?3,"Total Count: ",$J($FN(TOTAL,",",0),$L(TOTAL)+1)
;
; pause if output to terminal
I CONT D CONTINUE^KMPDUTL4("Press RETURN to continue",1)
;
Q
;
HDR ;-- print header
W @IOF
N HRS
S X=$G(KMPDTTL)
W !?(80-$L(X)\2),X
S KMPDHOUR=$G(KMPDHOUR)
S HRS=$E(KMPDHOUR,1,$L(KMPDHOUR)-1)
S X="Hour(s): "_HRS
W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
I +KMPDSRCH<4 D
.S X=$P($G(KMPDSRCH),U,2)_": "
.S X=X_$P($G(KMPDSRCH(1)),U,$S((+$G(KMPDSRCH))=1:2,1:1))
.W !?(80-$L(X)\2),X
S X="Threshold: "_$G(KMPDTSEC)_" seconds"
W !?(80-$L(X)\2),X
W !
W !,"Date",?10,"Time",?20,"User Name",?39,"Client Name",?60,"IP Address",?75,"TTL"
W !,$$REPEAT^XLFSTR("-",IOM)
;
Q
;
EXIT ;-- cleanup on exit
S:$D(ZTQUEUED) ZTREQ="@"
D ^%ZISC
K KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL
Q
;
MATCH() ;-- extrinsic function - check for matches
;-----------------------------------------------------------------------
; Return: 1 - match found
; 0 - no match found
;-----------------------------------------------------------------------
Q:'$G(KMPDSRCH) 0
; any occurrence
Q:(+KMPDSRCH)=4 1
; if not 'any occurrence' then must have kmpdsrch(1) node
Q:'$D(KMPDSRCH(1)) 0
; if not 'any occurrence' must have DATA1 to determine match
Q:$G(DATA1)=""
; user name
Q:(+KMPDSRCH)=1&($P(DATA1,U,5)'=$P(KMPDSRCH(1),U)) 0
; client name
Q:(+KMPDSRCH)=2&($P(DATA1,U,6)'=$P(KMPDSRCH(1),U)) 0
; ip address
Q:(+KMPDSRCH)=3&($P(DATA1,U,9)'=$P(KMPDSRCH(1),U)) 0
Q 1
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTP6 5848 printed Oct 16, 2024@17:41:41 Page 2
KMPDTP6 ;OAK/RAK/JML - CP Timing Real-Time Threshold Alert ;9/1/2015
+1 ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
+2 ;
EN ;-- entry point
+1 ;
+2 NEW I,KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
+3 NEW ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
+4 ;
+5 SET KMPDTTL=" Coversheet Time-to-Load Alert Report > Real-Time "
+6 DO HDR^KMPDUTL4(KMPDTTL)
+7 WRITE !
+8 WRITE !?7,"This alerting report shows the particular coversheet loads"
+9 WRITE !?7,"that have excessive time-to-load values for TODAY (Real-Time)."
+10 WRITE !?7,"This report will search for a particular person, a particular"
+11 WRITE !?7,"client name or IP address."
+12 WRITE !?7,"Foreground and background times are combined."
+13 WRITE !
+14 ;
+15 ; if no data
+16 IF ($ORDER(^KMPTMP("KMPDT","ORWCV",""))="")&($ORDER(^KMPTMP("KMPDT","ORWCV-FT",""))="")
Begin DoDot:1
+17 WRITE !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"", ***"
End DoDot:1
QUIT
+18 ;
+19 ; hours
+20 SET KMPDHOUR=$$RLTMHR^KMPDTU11(0,1,1)
+21 if KMPDHOUR=""
QUIT
+22 ;
+23 ; time-to-load threshold seconds
+24 SET KMPDTSEC=$$TTLSEC^KMPDTU10
+25 if 'KMPDTSEC
QUIT
+26 ;
+27 ; search by
+28 DO SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV",1)
+29 if 'KMPDSRCH
QUIT
+30 ;
+31 ; select output device.
+32 SET %ZIS="Q"
SET %ZIS("A")="Device: "
SET %ZIS("B")="HOME"
+33 WRITE !
DO ^%ZIS
IF POP
WRITE !,"No action taken."
QUIT
+34 ; if queued.
+35 IF $DATA(IO("Q"))
KILL IO("Q")
Begin DoDot:1
+36 SET ZTDESC=KMPDTTL
+37 SET ZTRTN="EN1^KMPDTP6"
+38 FOR I="KMPDHOUR","KMPDSRCH","KMPDTSEC","KMPDTTL"
SET ZTSAVE(I)=""
+39 DO ^%ZTLOAD
if $GET(ZTSK)
WRITE !,"Task #",ZTSK
+40 DO EXIT
End DoDot:1
QUIT
+41 ;
+42 ; if output to terminal display message.
+43 if $EXTRACT(IOST,1,2)="C-"
WRITE !,"Compiling timing stats..."
+44 DO EN1
+45 ;
+46 QUIT
+47 ;
EN1 ;-- entry point from taskman
+1 if '$DATA(KMPDHOUR)
QUIT
+2 if '$DATA(KMPDSRCH)
QUIT
+3 if '$GET(KMPDTSEC)
QUIT
+4 if $GET(KMPDTTL)=""
QUIT
+5 ;
+6 KILL ^TMP($JOB)
+7 DO DATA
DO PRINT
DO EXIT
+8 KILL ^TMP($JOB)
+9 QUIT
+10 ;
DATA ;-- compile data
+1 ;
+2 if '$DATA(KMPDHOUR)
QUIT
+3 if '$GET(KMPDSRCH)
QUIT
+4 if '$GET(KMPDTSEC)
QUIT
+5 ;
+6 NEW DATA,DATA1,DATE,DATE1,DELTA,DOT,HOUR,HR,I,QUEUED,TIME
+7 NEW KMPDSS,DELTA,TOTDELT,KMPDUZ
+8 ;
+9 SET DOT=1
SET QUEUED=$DATA(ZTQUEUED)
+10 ; set up HOUR() array
+11 FOR I=1:1:24
if $PIECE(KMPDHOUR,",",I)'=""
SET HOUR(+$PIECE(KMPDHOUR,",",I))=""
+12 if '$DATA(HOUR)
QUIT
+13 ; collect raw data
+14 FOR KMPDSS="ORWCV","ORWCV-FT"
Begin DoDot:1
+15 SET I=""
+16 FOR
SET I=$ORDER(^KMPTMP("KMPDT",KMPDSS,I))
if I=""
QUIT
SET DATA=^(I)
IF DATA]""
Begin DoDot:2
+17 SET DOT=DOT+1
if 'QUEUED&('(DOT#1000))
WRITE "."
+18 ; start/end date/time in fileman format
+19 SET DATE(1)=$$HTFM^XLFDT($PIECE(DATA,U))
SET DATE(2)=$$HTFM^XLFDT($PIECE(DATA,U,2))
+20 if 'DATE(1)!('DATE(2))
QUIT
+21 SET ^TMP($JOB,"DATA",I,KMPDSS)=DATA
End DoDot:2
End DoDot:1
+22 ; collate raw data - combined FG and BG
+23 SET I=""
+24 FOR
SET I=$ORDER(^TMP($JOB,"DATA",I))
if I=""
QUIT
Begin DoDot:1
+25 SET (KMPDSS,DATA1,KMPDUZ)=""
+26 SET (DELTA,TOTDELT)=0
+27 FOR KMPDSS="ORWCV","ORWCV-FT"
Begin DoDot:2
+28 SET DATA=$GET(^TMP($JOB,"DATA",I,KMPDSS))
+29 if DATA=""
QUIT
+30 SET KMPDUZ=$PIECE(DATA,U,3)
+31 SET DATE(1)=$$HTFM^XLFDT($PIECE(DATA,U))
SET DATE(2)=$$HTFM^XLFDT($PIECE(DATA,U,2))
+32 if 'DATE(1)!('DATE(2))
QUIT
+33 ; get delta
+34 SET DELTA=$$HDIFF^XLFDT($PIECE(DATA,U,2),$PIECE(DATA,U),2)
+35 ; determine hour
+36 SET HR=+$EXTRACT($PIECE(DATE(1),".",2),1,2)
+37 SET HR=$SELECT(HR="":0,HR=24:0,1:HR)
+38 ; quit if not in HOUR() array
+39 if '$DATA(HOUR(HR))
QUIT
+40 ; date without time
+41 SET DATE1=$PIECE(DATE(1),".")
if 'DATE1
QUIT
+42 SET TOTDELT=$GET(TOTDELT)+DELTA
+43 SET DATA1="^^^"_TOTDELT_"^"_$PIECE(DATA,U,3)_"^"_$PIECE(DATA,U,4)_"^^^"_$PIECE($PIECE(I," ",2),"-")
End DoDot:2
+44 if DATA1=""
QUIT
+45 if '$$MATCH
QUIT
+46 if $PIECE(DATA1,"^",4)<KMPDTSEC
QUIT
+47 ; hour & second
+48 SET TIME=$PIECE(DATE(1),".",2)
if 'TIME
QUIT
+49 ; insert colon (:) between hour & second
+50 SET TIME=$EXTRACT(TIME,1,2)_":"_$EXTRACT(TIME,3,4)_":"_$EXTRACT(TIME,5,6)
+51 if $PIECE(TIME,"
SET $PIECE(TIME,":",2)="00"
+52 if $PIECE(TIME,"
SET $PIECE(TIME,":",3)="00"
+53 SET ^TMP($JOB,"RPT",DATE1,TIME)=DATA1
+54 ; new person - external format
+55 SET $PIECE(^TMP($JOB,"RPT",DATE1,TIME),U,5)=$PIECE($GET(^VA(200,KMPDUZ,0)),U)
End DoDot:1
+56 QUIT
+57 ;
PRINT ;-- print data
+1 ;
+2 USE IO
+3 DO HDR
+4 if '$DATA(^TMP($JOB))
QUIT
+5 NEW CONT,DATE,I,TOTAL
+6 SET DATE=""
SET CONT=1
SET TOTAL=0
+7 FOR
SET DATE=$ORDER(^TMP($JOB,"RPT",DATE))
if 'DATE
QUIT
Begin DoDot:1
+8 WRITE !,$$FMTE^XLFDT(DATE,2)
SET HR=""
+9 FOR
SET HR=$ORDER(^TMP($JOB,"RPT",DATE,HR))
if HR=""
QUIT
Begin DoDot:2
+10 IF $Y>(IOSL-4)
Begin DoDot:3
+11 DO CONTINUE^KMPDUTL4("",1,.CONT)
if 'CONT
QUIT
+12 DO HDR
WRITE !,$$FMTE^XLFDT(DATE,2)
End DoDot:3
if 'CONT
QUIT
+13 WRITE ?10,HR
+14 SET DATA=^TMP($JOB,"RPT",DATE,HR)
SET TOTAL=TOTAL+1
+15 ; user name
+16 WRITE ?20,$SELECT($PIECE(DATA,U,5)]"":$EXTRACT($PIECE(DATA,U,5),1,19),1:"N/A")
+17 ; client name
+18 WRITE ?39,$SELECT($PIECE(DATA,U,6)]"":$EXTRACT($PIECE(DATA,U,6),1,19),1:"N/A")
+19 ; ip address
+20 WRITE ?60,$SELECT($PIECE(DATA,U,9)]"":$PIECE(DATA,U,9),1:"N/A")
+21 ; server delta
+22 WRITE ?75,$PIECE(DATA,U,4)
+23 WRITE !
if $EXTRACT($ORDER(^TMP($JOB,"RPT",DATE,HR)),1,2)'=$EXTRACT(HR,1,2)
WRITE !
End DoDot:2
if 'CONT
QUIT
End DoDot:1
if 'CONT
QUIT
+24 ;
+25 IF CONT&(TOTAL)
WRITE !!?3,"Total Count: ",$JUSTIFY($FNUMBER(TOTAL,",",0),$LENGTH(TOTAL)+1)
+26 ;
+27 ; pause if output to terminal
+28 IF CONT
DO CONTINUE^KMPDUTL4("Press RETURN to continue",1)
+29 ;
+30 QUIT
+31 ;
HDR ;-- print header
+1 WRITE @IOF
+2 NEW HRS
+3 SET X=$GET(KMPDTTL)
+4 WRITE !?(80-$LENGTH(X)\2),X
+5 SET KMPDHOUR=$GET(KMPDHOUR)
+6 SET HRS=$EXTRACT(KMPDHOUR,1,$LENGTH(KMPDHOUR)-1)
+7 SET X="Hour(s): "_HRS
+8 WRITE !?(80-$LENGTH(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
+9 IF +KMPDSRCH<4
Begin DoDot:1
+10 SET X=$PIECE($GET(KMPDSRCH),U,2)_": "
+11 SET X=X_$PIECE($GET(KMPDSRCH(1)),U,$SELECT((+$GET(KMPDSRCH))=1:2,1:1))
+12 WRITE !?(80-$LENGTH(X)\2),X
End DoDot:1
+13 SET X="Threshold: "_$GET(KMPDTSEC)_" seconds"
+14 WRITE !?(80-$LENGTH(X)\2),X
+15 WRITE !
+16 WRITE !,"Date",?10,"Time",?20,"User Name",?39,"Client Name",?60,"IP Address",?75,"TTL"
+17 WRITE !,$$REPEAT^XLFSTR("-",IOM)
+18 ;
+19 QUIT
+20 ;
EXIT ;-- cleanup on exit
+1 if $DATA(ZTQUEUED)
SET ZTREQ="@"
+2 DO ^%ZISC
+3 KILL KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL
+4 QUIT
+5 ;
MATCH() ;-- extrinsic function - check for matches
+1 ;-----------------------------------------------------------------------
+2 ; Return: 1 - match found
+3 ; 0 - no match found
+4 ;-----------------------------------------------------------------------
+5 if '$GET(KMPDSRCH)
QUIT 0
+6 ; any occurrence
+7 if (+KMPDSRCH)=4
QUIT 1
+8 ; if not 'any occurrence' then must have kmpdsrch(1) node
+9 if '$DATA(KMPDSRCH(1))
QUIT 0
+10 ; if not 'any occurrence' must have DATA1 to determine match
+11 if $GET(DATA1)=""
QUIT
+12 ; user name
+13 if (+KMPDSRCH)=1&($PIECE(DATA1,U,5)'=$PIECE(KMPDSRCH(1),U))
QUIT 0
+14 ; client name
+15 if (+KMPDSRCH)=2&($PIECE(DATA1,U,6)'=$PIECE(KMPDSRCH(1),U))
QUIT 0
+16 ; ip address
+17 if (+KMPDSRCH)=3&($PIECE(DATA1,U,9)'=$PIECE(KMPDSRCH(1),U))
QUIT 0
+18 QUIT 1