KMPDTM ;OAK/RAK/JML - CM Tools Timing Monitor ;9/1/2015
;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
;
EN ;-- entry point
;
N DIR,X,Y,KMPDLTYP
;
D HDR^KMPDUTL4(" Timing Data Monitor ")
;
; if no data
S KMPDLTYP=0
I $D(^KMPTMP("KMPDT","ORWCV")) S KMPDLTYP=KMPDLTYP+1
I $D(^KMPTMP("KMPDT","ORWCV-FT")) S KMPDLTYP=KMPDLTYP+2
I KMPDLTYP=0 D Q
.W !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"") ***"
;
W !
W !?7,"This option displays CPRS Coversheet time-to-load data, as a"
W !?7,"bar graph, for the current day. This option can be left"
W !?7,"running on a terminal (if desired). The monitor is updated"
W !?7,"every 10 minutes (site configurable through the [KMPD PARAM"
W !?7,"EDIT] Edit CP Parameters File option), and displays current"
W !?7,"average time-to-load data starting at midnight. An alarm"
W !?7,"message is displayed if the average time-to-load exceeds 30"
W !?7,"seconds (site configurable through the [KMPD PARAM EDIT] Edit"
W !?7,"CP Parameters File option)."
W !
S DIR(0)="YO",DIR("A")="Continue",DIR("B")="YES"
W ! D ^DIR Q:Y'=1
;
;
W !!,"Compiling timing stats..."
D EN1
;
Q
;
EN1 ;-- main loop
;
N KMPUALRT,KMPUTIME,KMPUTMP,OUT
;
S KMPUALRT=0,KMPUTIME=$$NOW^XLFDT
S OUT=0
F D Q:OUT
.D DATA
.D GRAPH
.S OUT=$$FTR Q:OUT
.D EXIT
Q
;
DATA ;-- compile data
;
N DATA,DATA1,DATE,DELTA,DOT,HOURS,HR,I
N KMPDI,KMPDSUB,TDELT
;
K KMPUTMP
S DOT=1,DATE=$$DT^XLFDT
; array with hours
S HOURS=$$RLTMHR^KMPDTU11(1,0) Q:HOURS=""
F HR=1:1 Q:$P(HOURS,",",HR)="" S KMPUTMP(HR,0)=""
;
; collate BG and FG data
F KMPDSUB="ORWCV","ORWCV-FT" D
.S KMPDI=""
.F S KMPDI=$O(^KMPTMP("KMPDT",KMPDSUB,KMPDI)) Q:KMPDI="" S DATA=^(KMPDI) I DATA]"" D
..Q:$P($$HTFM^XLFDT($P(DATA,U)),".")'=DATE
..S DOT=DOT+1 W:('(DOT#1000)) "."
..S ^TMP($J,"DATA",KMPDI,KMPDSUB)=DATA
; Add BG and FG data
S I=""
F S I=$O(^TMP($J,"DATA",I)) Q:I="" D
.S DELTA=0
.S KMPDSUB=""
.F S KMPDSUB=$O(^TMP($J,"DATA",I,KMPDSUB)) Q:KMPDSUB="" D
..S DATA=$G(^TMP($J,"DATA",I,KMPDSUB)) Q:DATA=""
..S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
..Q:'DATE(1)!('DATE(2))
..S TDELT=$$FMDIFF^XLFDT(DATE(2),DATE(1),2)
..S:TDELT<0 TDELT=0
..S DELTA=DELTA+TDELT
.; determine hour
.S HR=+$E($P(DATE(1),".",2),1,2) Q:HR="" ;HR="0"
.S DATA1="^^^"_DELTA_"^"_$P(DATA,U,3)_"^"_$P(DATA,U,4)_"^^^"_$P($P(I," ",2),"-")
.;
.; quit if no delta
.Q:$P(DATA1,U,4)=""
.; hour
.S $P(KMPUTMP(HR,0),U)=HR
.; total delta
.S $P(KMPUTMP(HR,0),U,2)=$P(KMPUTMP(HR,0),U,2)+$P(DATA1,U,4)
.; count
.S $P(KMPUTMP(HR,0),U,3)=$P(KMPUTMP(HR,0),U,3)+1
;
; average
F HR=1:1 S I=$P(HOURS,",",HR) Q:I="" I $P($G(KMPUTMP(I,0)),U,2) D
.S $P(KMPUTMP(I,0),U,2)=$FN($P(KMPUTMP(I,0),U,2)/$P(KMPUTMP(I,0),U,3),"",1)
;
Q
;
FTR() ;-- extrinsic function - footer
N OUT,PROMPT,UTIME,X
; update time - how often graph will refress itself
S UTIME=$P($G(^KMPD(8973,1,19)),U)
; value is in minutes and is converted to seconds for timed read
S UTIME=$S(UTIME:UTIME,1:10)*60
S PROMPT="[Q]uit, [U]pdate: "
S OUT=0
F D Q:OUT
.S DX=(IOM-$L(PROMPT)\2),DY=(IOSL-1) X IOXY
.W PROMPT R X:UTIME
.S X=$$UP^XLFSTR(X)
.I X="Q"!(X="^")!(X="U")!('$T) S OUT=1
.E W $C(7) S DY=(IOSL-1) F DX=1:1:IOM W " " X IOXY
W $S(X="Q":"uit",X="^":"Quit",X="U":"pdate",1:"Update")
Q $S(X="Q"!(X="^"):1,1:0)
;
GRAPH ;-- display graph
Q:'$D(KMPUTMP)
N ALERT,DATA,LOADTM,NOW,TITLE,TXT,UPDATE,KMPDMESS
; alert time in seconds - if average time-to-load is not less than this
; value an alert will appear on screen
S NOW=$$NOW^XLFDT
S KMPDMESS=$S(KMPDLTYP=1:"Foreground",KMPDLTYP=2:"Background",KMPDLTYP=3:"Foreground and Background",1:"")
S DATA=$G(^KMPD(8973,1,19))
; if no ALERT set default to 30 seconds
S ALERT=$S($P(DATA,U,2):$P(DATA,U,2),1:30)
; if not UPDATE default to 10 minutes
S UPDATE=$S($P(DATA,U):$P(DATA,U),1:10)
; current hour
S HR=+$E($P(NOW,".",2),1,2)
; current time-to-load value
S LOADTM=0
S:HR&($D(KMPUTMP(HR))) LOADTM=$P(KMPUTMP(HR,0),U,2)
; determine if is now an alert condition
S KMPUALRT=$S(LOADTM>ALERT:1,1:0)
;
; if load time is greater than alert time
I KMPUALRT S TXT(1,0)=$C(7)_"ALERT!!! - Current Average Time-To-Load exceeds '"_ALERT_" seconds'"
; else
E S TXT(1,0)=""
;
;S TXT(2,0)=""
S TXT(2,0)="Coversheet loads executed in the "_KMPDMESS
S TXT(3,0)="Last Updated: "_$P($$FMTE^XLFDT(NOW),"@",2)_" > "
S TXT(3,0)=TXT(3,0)_"Monitor will be updated every "_UPDATE_" min."
I $G(KMPUTIME) D
.S TXT(4,0)="Running Time: "_$$FMDIFF^XLFDT(NOW,KMPUTIME,3)_" > "
.S TXT(4,0)=TXT(4,0)_"ALERT will display if Load Time exceeds "_ALERT_" sec."
S TITLE="Timing Data Monitor^CPRS Coversheet^Load Time (Sec)^Hour"
;
D EN^KMPDUG("KMPUTMP",TITLE,"DV","","TXT",1,40)
;
Q
;
EXIT ;-- cleanup on exit
D ^%ZISC
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HKMPDTM 4997 printed Dec 13, 2024@01:40:44 Page 2
KMPDTM ;OAK/RAK/JML - CM Tools Timing Monitor ;9/1/2015
+1 ;;3.0;Capacity Management Tools;**3**;Jan 15, 2013;Build 42
+2 ;
EN ;-- entry point
+1 ;
+2 NEW DIR,X,Y,KMPDLTYP
+3 ;
+4 DO HDR^KMPDUTL4(" Timing Data Monitor ")
+5 ;
+6 ; if no data
+7 SET KMPDLTYP=0
+8 IF $DATA(^KMPTMP("KMPDT","ORWCV"))
SET KMPDLTYP=KMPDLTYP+1
+9 IF $DATA(^KMPTMP("KMPDT","ORWCV-FT"))
SET KMPDLTYP=KMPDLTYP+2
+10 IF KMPDLTYP=0
Begin DoDot:1
+11 WRITE !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"") ***"
End DoDot:1
QUIT
+12 ;
+13 WRITE !
+14 WRITE !?7,"This option displays CPRS Coversheet time-to-load data, as a"
+15 WRITE !?7,"bar graph, for the current day. This option can be left"
+16 WRITE !?7,"running on a terminal (if desired). The monitor is updated"
+17 WRITE !?7,"every 10 minutes (site configurable through the [KMPD PARAM"
+18 WRITE !?7,"EDIT] Edit CP Parameters File option), and displays current"
+19 WRITE !?7,"average time-to-load data starting at midnight. An alarm"
+20 WRITE !?7,"message is displayed if the average time-to-load exceeds 30"
+21 WRITE !?7,"seconds (site configurable through the [KMPD PARAM EDIT] Edit"
+22 WRITE !?7,"CP Parameters File option)."
+23 WRITE !
+24 SET DIR(0)="YO"
SET DIR("A")="Continue"
SET DIR("B")="YES"
+25 WRITE !
DO ^DIR
if Y'=1
QUIT
+26 ;
+27 ;
+28 WRITE !!,"Compiling timing stats..."
+29 DO EN1
+30 ;
+31 QUIT
+32 ;
EN1 ;-- main loop
+1 ;
+2 NEW KMPUALRT,KMPUTIME,KMPUTMP,OUT
+3 ;
+4 SET KMPUALRT=0
SET KMPUTIME=$$NOW^XLFDT
+5 SET OUT=0
+6 FOR
Begin DoDot:1
+7 DO DATA
+8 DO GRAPH
+9 SET OUT=$$FTR
if OUT
QUIT
+10 DO EXIT
End DoDot:1
if OUT
QUIT
+11 QUIT
+12 ;
DATA ;-- compile data
+1 ;
+2 NEW DATA,DATA1,DATE,DELTA,DOT,HOURS,HR,I
+3 NEW KMPDI,KMPDSUB,TDELT
+4 ;
+5 KILL KMPUTMP
+6 SET DOT=1
SET DATE=$$DT^XLFDT
+7 ; array with hours
+8 SET HOURS=$$RLTMHR^KMPDTU11(1,0)
if HOURS=""
QUIT
+9 FOR HR=1:1
if $PIECE(HOURS,",",HR)=""
QUIT
SET KMPUTMP(HR,0)=""
+10 ;
+11 ; collate BG and FG data
+12 FOR KMPDSUB="ORWCV","ORWCV-FT"
Begin DoDot:1
+13 SET KMPDI=""
+14 FOR
SET KMPDI=$ORDER(^KMPTMP("KMPDT",KMPDSUB,KMPDI))
if KMPDI=""
QUIT
SET DATA=^(KMPDI)
IF DATA]""
Begin DoDot:2
+15 if $PIECE($$HTFM^XLFDT($PIECE(DATA,U)),".")'=DATE
QUIT
+16 SET DOT=DOT+1
if ('(DOT#1000))
WRITE "."
+17 SET ^TMP($JOB,"DATA",KMPDI,KMPDSUB)=DATA
End DoDot:2
End DoDot:1
+18 ; Add BG and FG data
+19 SET I=""
+20 FOR
SET I=$ORDER(^TMP($JOB,"DATA",I))
if I=""
QUIT
Begin DoDot:1
+21 SET DELTA=0
+22 SET KMPDSUB=""
+23 FOR
SET KMPDSUB=$ORDER(^TMP($JOB,"DATA",I,KMPDSUB))
if KMPDSUB=""
QUIT
Begin DoDot:2
+24 SET DATA=$GET(^TMP($JOB,"DATA",I,KMPDSUB))
if DATA=""
QUIT
+25 SET DATE(1)=$$HTFM^XLFDT($PIECE(DATA,U))
SET DATE(2)=$$HTFM^XLFDT($PIECE(DATA,U,2))
+26 if 'DATE(1)!('DATE(2))
QUIT
+27 SET TDELT=$$FMDIFF^XLFDT(DATE(2),DATE(1),2)
+28 if TDELT<0
SET TDELT=0
+29 SET DELTA=DELTA+TDELT
End DoDot:2
+30 ; determine hour
+31 ;HR="0"
SET HR=+$EXTRACT($PIECE(DATE(1),".",2),1,2)
if HR=""
QUIT
+32 SET DATA1="^^^"_DELTA_"^"_$PIECE(DATA,U,3)_"^"_$PIECE(DATA,U,4)_"^^^"_$PIECE($PIECE(I," ",2),"-")
+33 ;
+34 ; quit if no delta
+35 if $PIECE(DATA1,U,4)=""
QUIT
+36 ; hour
+37 SET $PIECE(KMPUTMP(HR,0),U)=HR
+38 ; total delta
+39 SET $PIECE(KMPUTMP(HR,0),U,2)=$PIECE(KMPUTMP(HR,0),U,2)+$PIECE(DATA1,U,4)
+40 ; count
+41 SET $PIECE(KMPUTMP(HR,0),U,3)=$PIECE(KMPUTMP(HR,0),U,3)+1
End DoDot:1
+42 ;
+43 ; average
+44 FOR HR=1:1
SET I=$PIECE(HOURS,",",HR)
if I=""
QUIT
IF $PIECE($GET(KMPUTMP(I,0)),U,2)
Begin DoDot:1
+45 SET $PIECE(KMPUTMP(I,0),U,2)=$FNUMBER($PIECE(KMPUTMP(I,0),U,2)/$PIECE(KMPUTMP(I,0),U,3),"",1)
End DoDot:1
+46 ;
+47 QUIT
+48 ;
FTR() ;-- extrinsic function - footer
+1 NEW OUT,PROMPT,UTIME,X
+2 ; update time - how often graph will refress itself
+3 SET UTIME=$PIECE($GET(^KMPD(8973,1,19)),U)
+4 ; value is in minutes and is converted to seconds for timed read
+5 SET UTIME=$SELECT(UTIME:UTIME,1:10)*60
+6 SET PROMPT="[Q]uit, [U]pdate: "
+7 SET OUT=0
+8 FOR
Begin DoDot:1
+9 SET DX=(IOM-$LENGTH(PROMPT)\2)
SET DY=(IOSL-1)
XECUTE IOXY
+10 WRITE PROMPT
READ X:UTIME
+11 SET X=$$UP^XLFSTR(X)
+12 IF X="Q"!(X="^")!(X="U")!('$TEST)
SET OUT=1
+13 IF '$TEST
WRITE $CHAR(7)
SET DY=(IOSL-1)
FOR DX=1:1:IOM
WRITE " "
XECUTE IOXY
End DoDot:1
if OUT
QUIT
+14 WRITE $SELECT(X="Q":"uit",X="^":"Quit",X="U":"pdate",1:"Update")
+15 QUIT $SELECT(X="Q"!(X="^"):1,1:0)
+16 ;
GRAPH ;-- display graph
+1 if '$DATA(KMPUTMP)
QUIT
+2 NEW ALERT,DATA,LOADTM,NOW,TITLE,TXT,UPDATE,KMPDMESS
+3 ; alert time in seconds - if average time-to-load is not less than this
+4 ; value an alert will appear on screen
+5 SET NOW=$$NOW^XLFDT
+6 SET KMPDMESS=$SELECT(KMPDLTYP=1:"Foreground",KMPDLTYP=2:"Background",KMPDLTYP=3:"Foreground and Background",1:"")
+7 SET DATA=$GET(^KMPD(8973,1,19))
+8 ; if no ALERT set default to 30 seconds
+9 SET ALERT=$SELECT($PIECE(DATA,U,2):$PIECE(DATA,U,2),1:30)
+10 ; if not UPDATE default to 10 minutes
+11 SET UPDATE=$SELECT($PIECE(DATA,U):$PIECE(DATA,U),1:10)
+12 ; current hour
+13 SET HR=+$EXTRACT($PIECE(NOW,".",2),1,2)
+14 ; current time-to-load value
+15 SET LOADTM=0
+16 if HR&($DATA(KMPUTMP(HR)))
SET LOADTM=$PIECE(KMPUTMP(HR,0),U,2)
+17 ; determine if is now an alert condition
+18 SET KMPUALRT=$SELECT(LOADTM>ALERT:1,1:0)
+19 ;
+20 ; if load time is greater than alert time
+21 IF KMPUALRT
SET TXT(1,0)=$CHAR(7)_"ALERT!!! - Current Average Time-To-Load exceeds '"_ALERT_" seconds'"
+22 ; else
+23 IF '$TEST
SET TXT(1,0)=""
+24 ;
+25 ;S TXT(2,0)=""
+26 SET TXT(2,0)="Coversheet loads executed in the "_KMPDMESS
+27 SET TXT(3,0)="Last Updated: "_$PIECE($$FMTE^XLFDT(NOW),"@",2)_" > "
+28 SET TXT(3,0)=TXT(3,0)_"Monitor will be updated every "_UPDATE_" min."
+29 IF $GET(KMPUTIME)
Begin DoDot:1
+30 SET TXT(4,0)="Running Time: "_$$FMDIFF^XLFDT(NOW,KMPUTIME,3)_" > "
+31 SET TXT(4,0)=TXT(4,0)_"ALERT will display if Load Time exceeds "_ALERT_" sec."
End DoDot:1
+32 SET TITLE="Timing Data Monitor^CPRS Coversheet^Load Time (Sec)^Hour"
+33 ;
+34 DO EN^KMPDUG("KMPUTMP",TITLE,"DV","","TXT",1,40)
+35 ;
+36 QUIT
+37 ;
EXIT ;-- cleanup on exit
+1 DO ^%ZISC
+2 QUIT