source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDTM.m@ 1005

Last change on this file since 1005 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 4.2 KB
RevLine 
[613]1KMPDTM ;OAK/RAK - CM Tools Timing Monitor ;6/21/05 10:14
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**1,4**;Mar 22, 2002
3 ;
4EN ;-- entry point
5 ;
6 N DIR,X,Y
7 ;
8 D HDR^KMPDUTL4(" Timing Data Monitor ")
9 ;
10 ; if no data
11 I $O(^KMPTMP("KMPDT","ORWCV",""))="" D Q
12 .W !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"",""ORWCV"") ***"
13 ;
14 W !
15 W !?7,"This option displays CPRS Coversheet time-to-load data, as a"
16 W !?7,"bar graph, for the current day. This option can be left"
17 W !?7,"running on a terminal (if desired). The monitor is updated"
18 W !?7,"every 10 minutes (site configurable through the [KMPD PARAM"
19 W !?7,"EDIT] Edit CP Parameters File option), and displays current"
20 W !?7,"average time-to-load data starting at midnight. An alarm"
21 W !?7,"message is displayed if the average time-to-load exceeds 30"
22 W !?7,"seconds (site configurable through the [KMPD PARAM EDIT] Edit"
23 W !?7,"CP Parameters File option)."
24 W !
25 S DIR(0)="YO",DIR("A")="Continue",DIR("B")="YES"
26 W ! D ^DIR Q:Y'=1
27 ;
28 ;
29 W !!,"Compiling timing stats..."
30 D EN1
31 ;
32 Q
33 ;
34EN1 ;-- main loop
35 ;
36 N KMPUALRT,KMPUTIME,KMPUTMP,OUT
37 ;
38 S KMPUALRT=0,KMPUTIME=$$NOW^XLFDT
39 S OUT=0
40 F D Q:OUT
41 .D DATA
42 .D GRAPH
43 .S OUT=$$FTR Q:OUT
44 .D EXIT
45 Q
46 ;
47DATA ;-- compile data
48 ;
49 N DATA,DATA1,DATE,DELTA,DOT,HOURS,HR,I
50 ;
51 K KMPUTMP
52 S DOT=1,DATE=$$DT^XLFDT
53 ; array with hours
54 S HOURS=$$RLTMHR^KMPDTU11(1,0) Q:HOURS=""
55 F HR=1:1 Q:$P(HOURS,",",HR)="" S KMPUTMP(HR,0)=""
56 S I=""
57 F S I=$O(^KMPTMP("KMPDT","ORWCV",I)) Q:I="" S DATA=^(I) I DATA]"" D
58 .S DOT=DOT+1 W:('(DOT#1000)) "."
59 .; start/end date/time in fileman format
60 .S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
61 .Q:'DATE(1)!('DATE(2))
62 .; quit if not today (DATE)
63 .Q:$P(DATE(1),".")'=DATE
64 .S DELTA=$$FMDIFF^XLFDT(DATE(2),DATE(1),2)
65 .S:DELTA<0 DELTA=""
66 .; determine hour
67 .S HR=+$E($P(DATE(1),".",2),1,2) Q:HR="" ;HR="0"
68 .;Q:'HR
69 .; quit if not in HOUR() array
70 .;Q:'$D(HOUR(HR))
71 .S DATA1="^^^"_DELTA_"^"_$P(DATA,U,3)_"^"_$P(DATA,U,4)_"^^^"_$P($P(I," ",2),"-")
72 .;
73 .; quit if no delta
74 .Q:$P(DATA1,U,4)=""
75 .; hour
76 .S $P(KMPUTMP(HR,0),U)=HR
77 .; total delta
78 .S $P(KMPUTMP(HR,0),U,2)=$P(KMPUTMP(HR,0),U,2)+$P(DATA1,U,4)
79 .; count
80 .S $P(KMPUTMP(HR,0),U,3)=$P(KMPUTMP(HR,0),U,3)+1
81 ;
82 ; average
83 F HR=1:1 S I=$P(HOURS,",",HR) Q:I="" I $P($G(KMPUTMP(I,0)),U,2) D
84 .S $P(KMPUTMP(I,0),U,2)=$FN($P(KMPUTMP(I,0),U,2)/$P(KMPUTMP(I,0),U,3),"",1)
85 ;
86 Q
87 ;
88FTR() ;-- extrinsic function - footer
89 N OUT,PROMPT,UTIME,X
90 ; update time - how often graph will refress itself
91 S UTIME=$P($G(^KMPD(8973,1,19)),U)
92 ; value is in minutes and is converted to seconds for timed read
93 S UTIME=$S(UTIME:UTIME,1:10)*60
94 S PROMPT="[Q]uit, [U]pdate: "
95 S OUT=0
96 F D Q:OUT
97 .S DX=(IOM-$L(PROMPT)\2),DY=(IOSL-1) X IOXY
98 .W PROMPT R X:UTIME
99 .S X=$$UP^XLFSTR(X)
100 .I X="Q"!(X="^")!(X="U")!('$T) S OUT=1
101 .E W $C(7) S DY=(IOSL-1) F DX=1:1:IOM W " " X IOXY
102 W $S(X="Q":"uit",X="^":"Quit",X="U":"pdate",1:"Update")
103 Q $S(X="Q"!(X="^"):1,1:0)
104 ;
105GRAPH ;-- display graph
106 Q:'$D(KMPUTMP)
107 N ALERT,DATA,LOADTM,NOW,TITLE,TXT,UPDATE
108 ; alert time in seconds - if average time-to-load is not less than this
109 ; value an alert will appear on screen
110 S NOW=$$NOW^XLFDT
111 S DATA=$G(^KMPD(8973,1,19))
112 ; if no ALERT set default to 30 seconds
113 S ALERT=$S($P(DATA,U,2):$P(DATA,U,2),1:30)
114 ; if not UPDATE default to 10 minutes
115 S UPDATE=$S($P(DATA,U):$P(DATA,U),1:10)
116 ; current hour
117 S HR=+$E($P(NOW,".",2),1,2)
118 ; current time-to-load value
119 S:HR&($D(KMPUTMP(HR))) LOADTM=$P(KMPUTMP(HR,0),U,2)
120 ; determine if is now an alert condition
121 S KMPUALRT=$S(LOADTM>ALERT:1,1:0)
122 ;
123 ; if load time is greater than alert time
124 I KMPUALRT S TXT(1,0)=$C(7)_"ALERT!!! - Current Average Time-To-Load exceeds '"_ALERT_" seconds'"
125 ; else
126 E S TXT(1,0)=""
127 ;
128 S TXT(2,0)=""
129 S TXT(3,0)="Last Updated: "_$P($$FMTE^XLFDT(NOW),"@",2)_" > "
130 S TXT(3,0)=TXT(3,0)_"Monitor will be updated every "_UPDATE_" min."
131 I $G(KMPUTIME) D
132 .S TXT(4,0)="Running Time: "_$$FMDIFF^XLFDT(NOW,KMPUTIME,3)_" > "
133 .S TXT(4,0)=TXT(4,0)_"ALERT will display if Load Time exceeds "_ALERT_" sec."
134 S TITLE="Timing Data Monitor^CPRS Coversheet^Load Time (Sec)^Hour"
135 ;
136 D EN^KMPDUG("KMPUTMP",TITLE,"DV","","TXT",1,40)
137 ;
138 Q
139 ;
140EXIT ;-- cleanup on exit
141 D ^%ZISC
142 Q
Note: See TracBrowser for help on using the repository browser.