source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDTP6.m@ 767

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

initial load of WorldVistAEHR

File size: 4.8 KB
Line 
1KMPDTP6 ;OAK/RAK - CP Timing Real-Time Threshold Alert ;6/21/05 10:15
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**4**;Mar 22, 2002
3 ;
4EN ;-- entry point
5 ;
6 N I,KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL,POP,X,Y
7 N ZTDESC,ZTRTN,ZTRSAVE,ZTSK,%ZIS
8 ;
9 S KMPDTTL=" Coversheet Time-to-Load Alert Report > Real-Time "
10 D HDR^KMPDUTL4(KMPDTTL)
11 W !
12 W !?7,"This alerting report shows the particular coversheet loads"
13 W !?7,"that have excessive time-to-load values for TODAY (Real-Time)."
14 W !?7,"This report will search for a particular person, a particular"
15 W !?7,"client name or IP address."
16 W !
17 ;
18 ; if no data
19 I $O(^KMPTMP("KMPDT","ORWCV",""))="" D Q
20 .W !!?7,"*** There is currently no data in global ^KMPTMP(""KMPDT"",""ORWCV"") ***"
21 ;
22 ; hours
23 S KMPDHOUR=$$RLTMHR^KMPDTU11(0,1,1)
24 Q:KMPDHOUR=""
25 ;
26 ; time-to-load threshold seconds
27 S KMPDTSEC=$$TTLSEC^KMPDTU10
28 Q:'KMPDTSEC
29 ;
30 ; search by
31 D SRCHBY^KMPDTU10(.KMPDSRCH,"ORWCV",1)
32 Q:'KMPDSRCH
33 ;
34 ; select output device.
35 S %ZIS="Q",%ZIS("A")="Device: ",%ZIS("B")="HOME"
36 W ! D ^%ZIS I POP W !,"No action taken." Q
37 ; if queued.
38 I $D(IO("Q")) K IO("Q") D Q
39 .S ZTDESC=KMPDTTL
40 .S ZTRTN="EN1^KMPDTP6"
41 .F I="KMPDHOUR","KMPDSRCH","KMPDTSEC","KMPDTTL" S ZTSAVE(I)=""
42 .D ^%ZTLOAD W:$G(ZTSK) !,"Task #",ZTSK
43 .D EXIT
44 ;
45 ; if output to terminal display message.
46 W:$E(IOST,1,2)="C-" !,"Compiling timing stats..."
47 D EN1
48 ;
49 Q
50 ;
51EN1 ;-- entry point from taskman
52 Q:'$D(KMPDHOUR)
53 Q:'$D(KMPDSRCH)
54 Q:'$G(KMPDTSEC)
55 Q:$G(KMPDTTL)=""
56 ;
57 K ^TMP($J)
58 D DATA,PRINT,EXIT
59 K ^TMP($J)
60 Q
61 ;
62DATA ;-- compile data
63 ;
64 Q:'$D(KMPDHOUR)
65 Q:'$G(KMPDSRCH)
66 Q:'$G(KMPDTSEC)
67 ;
68 N DATA,DATA1,DATE,DATE1,DELTA,DOT,HOUR,HR,I,QUEUED,TIME
69 ;
70 S DOT=1,QUEUED=$D(ZTQUEUED)
71 ; set up HOUR() array
72 F I=1:1:24 S:$P(KMPDHOUR,",",I)'="" HOUR(+$P(KMPDHOUR,",",I))=""
73 Q:'$D(HOUR)
74 S I=""
75 F S I=$O(^KMPTMP("KMPDT","ORWCV",I)) Q:I="" S DATA=^(I) I DATA]"" D
76 .S DOT=DOT+1 W:'QUEUED&('(DOT#1000)) "."
77 .; start/end date/time in fileman format
78 .S DATE(1)=$$HTFM^XLFDT($P(DATA,U)),DATE(2)=$$HTFM^XLFDT($P(DATA,U,2))
79 .S DELTA=$$HDIFF^XLFDT($P(DATA,U,2),$P(DATA,U),2)
80 .Q:DELTA<KMPDTSEC
81 .Q:'DATE(1)!('DATE(2))
82 .; determine hour
83 .S HR=+$E($P(DATE(1),".",2),1,2)
84 .S HR=$S(HR="":0,HR=24:0,1:HR)
85 .; quit if not in HOUR() array
86 .Q:'$D(HOUR(HR))
87 .; hour & second
88 .S TIME=$E($P(DATE(1),".",2),1,4) Q:'TIME
89 .; insert colon (:) between hour & second
90 .S TIME=$E(TIME,1,2)_":"_$E(TIME,3,4)
91 .S:$P(TIME,":",2)="" $P(TIME,":",2)="00"
92 .; date without time
93 .S DATE1=$P(DATE(1),".") Q:'DATE1
94 .S DATA1="^^^"_DELTA_"^"_$P(DATA,U,3)_"^"_$P(DATA,U,4)_"^^^"_$P($P(I," ",2),"-")
95 .; quit if no match
96 .Q:'$$MATCH
97 .S ^TMP($J,DATE1,TIME)=DATA1
98 .; new person - external format
99 .S $P(^TMP($J,DATE1,TIME),U,5)=$P($G(^VA(200,+$P(DATA,U,3),0)),U)
100 ;
101 Q
102 ;
103PRINT ;-- print data
104 ;
105 U IO
106 D HDR
107 Q:'$D(^TMP($J))
108 N CONT,DATE,I,TOTAL
109 S DATE="",CONT=1,TOTAL=0
110 F S DATE=$O(^TMP($J,DATE)) Q:'DATE D Q:'CONT
111 .W !,$$FMTE^XLFDT(DATE,2) S HR=""
112 .F S HR=$O(^TMP($J,DATE,HR)) Q:HR="" D Q:'CONT
113 ..I $Y>(IOSL-4) D Q:'CONT
114 ...D CONTINUE^KMPDUTL4("",1,.CONT) Q:'CONT
115 ...D HDR W !,$$FMTE^XLFDT(DATE,2)
116 ..W ?10,HR
117 ..S DATA=^TMP($J,DATE,HR),TOTAL=TOTAL+1
118 ..; user name
119 ..W ?16,$S($P(DATA,U,5)]"":$E($P(DATA,U,5),1,15),1:"N/A")
120 ..; client name
121 ..W ?33,$S($P(DATA,U,6)]"":$E($P(DATA,U,6),1,15),1:"N/A")
122 ..; ip address
123 ..W ?50,$S($P(DATA,U,9)]"":$P(DATA,U,9),1:"N/A")
124 ..; server delta
125 ..W ?67,$J($P(DATA,U,4),8)
126 ..W ! W:$E($O(^TMP($J,DATE,HR)),1,2)'=$E(HR,1,2) !
127 ;
128 I CONT&(TOTAL) W !!?3,"Total Count: ",$J($FN(TOTAL,",",0),$L(TOTAL)+1)
129 ;
130 ; pause if output to terminal
131 I CONT D CONTINUE^KMPDUTL4("Press RETURN to continue",1)
132 ;
133 Q
134 ;
135HDR ;-- print header
136 W @IOF
137 S X=$G(KMPDTTL)
138 W !?(80-$L(X)\2),X
139 S X="Hour(s): "_$G(KMPDHOUR)
140 W !?(80-$L(X)\2),X,?61,"Printed: ",$$FMTE^XLFDT(DT,2)
141 S X=$P($G(KMPDSRCH),U,2)_": "
142 S X=X_$P($G(KMPDSRCH(1)),U,$S((+$G(KMPDSRCH))=1:2,1:1))
143 W !?(80-$L(X)\2),X
144 S X="Threshold: "_$G(KMPDTSEC)_" seconds"
145 W !?(80-$L(X)\2),X
146 W !
147 W !,"Date",?10,"Time",?16,"User Name",?33,"Client Name",?50,"IP Address",?67,"Time-to-Load"
148 W !,$$REPEAT^XLFSTR("-",IOM)
149 ;
150 Q
151 ;
152EXIT ;-- cleanup on exit
153 S:$D(ZTQUEUED) ZTREQ="@"
154 D ^%ZISC
155 K KMPDHOUR,KMPDSRCH,KMPDTSEC,KMPDTTL
156 Q
157 ;
158MATCH() ;-- extrinsic function - check for matches
159 ;-----------------------------------------------------------------------
160 ; Return: 1 - match found
161 ; 0 - no match found
162 ;-----------------------------------------------------------------------
163 Q:'$G(KMPDSRCH) 0
164 ; any occurrence
165 Q:(+KMPDSRCH)=4 1
166 ; if not 'any occurrence' then must have kmpdsrch(1) node
167 Q:'$D(KMPDSRCH(1)) 0
168 ; if not 'any occurrence' must have DATA1 to determine match
169 Q:$G(DATA1)=""
170 ; user name
171 Q:(+KMPDSRCH)=1&($P(DATA1,U,5)'=$P(KMPDSRCH(1),U)) 0
172 ; client name
173 Q:(+KMPDSRCH)=2&($P(DATA1,U,6)'=$P(KMPDSRCH(1),U)) 0
174 ; ip address
175 Q:(+KMPDSRCH)=3&($P(DATA1,U,9)'=$P(KMPDSRCH(1),U)) 0
176 Q 1
Note: See TracBrowser for help on using the repository browser.