source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_RUM-KMPR/KMPRBD02.m@ 1150

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

initial load of WorldVistAEHR

File size: 5.0 KB
RevLine 
[613]1KMPRBD02 ;OAK/RAK - RUM Data Compression ;5/28/03 08:36
2 ;;2.0;CAPACITY MANAGEMENT - RUM;;May 28, 2003
3 ;
4 ; Background Driver (cont.)
5 ;
6DAILY(KMPRTDAY) ;-- daily data compression and storage
7 ;----------------------------------------------------------------------
8 ; KMPRTDAY.. Day in $H format (+$H). This represents the
9 ; ending point for compression. Only dates LESS than
10 ; KMPRTDAY will be compressed.
11 ;
12 ; At midnight compress hourly info into daily stats. Daily stats are
13 ; stored in file #8971.1. Hourly data is killed.
14 ;----------------------------------------------------------------------
15 ;
16 Q:'$G(KMPRTDAY)
17 ;
18 N COUNT,CNT,CNT1,CNT2,DATA,FMHDATE,HDATE,HTIME,I,JOB,MESSAGE
19 N NODE,NW,OKAY,OPTION,NP,PT,PTM,X,VAR,USERS,USRDATA,WD,WORKDAY,YSTRDAY
20 ;
21 K ^TMP($J)
22 ;
23 ; make sure DT is defined.
24 S:'$G(DT) DT=$$DT^XLFDT
25 ;
26 ; yesterday - this will be the data that is compiled and stored
27 S YSTRDAY=$$HADD^XLFDT(KMPRTDAY,-1)
28 ;
29 S NODE=""
30 F S NODE=$O(^KMPTMP("KMPR","DLY",NODE)) Q:NODE="" D
31 .S HDATE=""
32 .F S HDATE=$O(^KMPTMP("KMPR","DLY",NODE,HDATE)) Q:HDATE=""!(HDATE'<KMPRTDAY) D
33 ..; if less than 'yesterday' kill - old data
34 ..I HDATE<YSTRDAY K ^KMPTMP("KMPR","DLY",NODE,HDATE) Q
35 ..;
36 ..S FMHDATE=+$$HTFM^XLFDT(HDATE,1)
37 ..;
38 ..; WORKDAY = 0 : weekend or holiday (non-workday)
39 ..; = 1 : workday
40 ..;
41 ..S WORKDAY=$$WORKDAY^XUWORKDY(FMHDATE)
42 ..;
43 ..S OPTION=""
44 ..F S OPTION=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,OPTION)) Q:OPTION="" D
45 ...K NP,PT
46 ...S JOB=0,COUNT=""
47 ...F S JOB=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,OPTION,JOB)) Q:'JOB D
48 ....S PTM=""
49 ....F S PTM=$O(^KMPTMP("KMPR","DLY",NODE,HDATE,OPTION,JOB,PTM)) Q:PTM="" D
50 .....; PTM: non-prime time = 0 prime time = 1
51 .....S DATA=^KMPTMP("KMPR","DLY",NODE,HDATE,OPTION,JOB,PTM)
52 .....;
53 .....; prime time or non-prime time
54 .....S VAR=$S((WORKDAY&PTM):"PT",1:"NP") Q:VAR=""
55 .....;
56 .....; if current data is negative
57 .....I $P($G(@VAR@(0)),U,5)<0 D
58 ......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"C"),U,5)=$P(@VAR,U,5)
59 .....;
60 .....; if new data is negative
61 .....I ($P(DATA,U,5)<0) D
62 ......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"N"),U,5)=$P(DATA,U,5)
63 .....;
64 .....; if sum of pieces are negative
65 .....I ($P($G(@VAR@(0)),U,5)+$P(DATA,U,5))<0 D
66 ......S $P(^KMPTMP("KMPR","NEG","DLY",OPTION,"T"),U,5)=($P(@VAR,U,5))_"+"_($P(DATA,U,5))_"="_($P(@VAR,U,5)+$P(DATA,U,5))
67 .....;
68 .....; accumulate totals
69 .....; data elements - pieces 1 - 8
70 .....F I=1:1:8 S $P(@VAR@(1),U,I)=$P($G(@VAR@(1)),U,I)+$P(DATA,U,I)
71 .....;
72 .....S USERS=$G(^TMP($J,HDATE,NODE,JOB)),USRDATA=0
73 .....;
74 .....; hour counts - pieces 10 - 33 - offset by -9
75 .....; hour 0 = piece 10
76 .....; hour 1 = piece 11
77 .....; hour 2 = piece 12 ...
78 .....F I=10:1:33 S CNT=$P(DATA,U,I) I +CNT D
79 ......S CNT1=$P(CNT,"~"),CNT2=$P(CNT,"~",2)
80 ......;
81 ......; set for every hour that this particular $job ran
82 ......I +CNT2 S $P(USERS,U,(I-9))=$P(USERS,U,(I-9))+1,USRDATA=1
83 ......;
84 ......; if workday capture workday counts
85 ......I WORKDAY D
86 .......; number of occurrences per hour
87 .......S $P(PT(1.1),U,(I-9))=$P($G(PT(1.1)),U,(I-9))+CNT1
88 .......; number of users for this particular option/protocol/rpc
89 .......S $P(PT(1.2),U,(I-9))=$P($G(PT(1.2)),U,(I-9))+1
90 ......;
91 ......; else capture non-workday (weekend/holiday) counts
92 ......E D
93 .......; number of occurrences per hour
94 .......S $P(NP(1.1),U,(I-9))=$P($G(NP(1.1)),U,(I-9))+CNT1
95 .......; number of users for this particular option/protocol/rpc
96 .......S $P(NP(1.2),U,(I-9))=$P($G(NP(1.2)),U,(I-9))+1
97 .....;
98 .....; will have every hour that this particular $job ran
99 .....I USRDATA S ^TMP($J,HDATE,NODE,JOB)=USERS
100 .....;
101 .....; piece 1 non-prime time - piece 2 prime time
102 .....S $P(COUNT,U,(PTM+1))=$P(COUNT,U,(PTM+1))+1
103 .....;
104 .....; remove data from array
105 .....K ^KMPTMP("KMPR","DLY",NODE,HDATE,OPTION,JOB,PTM)
106 ...;
107 ...; back to OPTION level
108 ...; file data into file #8971.1
109 ...D FILE^KMPRBD03(HDATE,NODE,OPTION,.PT,.NP,$P(COUNT,U,2),$P(COUNT,U),.OKAY,.MESSAGE)
110 ...;
111 ...; if not filed successfully set into 'ERR' node.
112 ...I 'OKAY D
113 ....S ^KMPTMP("KMPR","ERR",HDATE,NODE,OPTION,0)=NP_$P(COUNT,U)
114 ....S ^KMPTMP("KMPR","ERR",HDATE,NODE,OPTION,1)=PT_$P(COUNT,U,2)
115 ....F I=0:0 S I=$O(MESSAGE(I)) Q:'I D
116 .....S ^KMPTMP("KMPR","ERR",HDATE,NODE,OPTION,"MSG",I)=MESSAGE(I)
117 ;
118 ; find the total number of jobs that ran first minute of every hour
119 S HDATE=""
120 F S HDATE=$O(^TMP($J,HDATE)) Q:HDATE=""!(HDATE'<KMPRTDAY) D
121 .;
122 .S FMHDATE=+$$HTFM^XLFDT(HDATE,1)
123 .S WORKDAY=$$WORKDAY^XUWORKDY(FMHDATE)
124 .;
125 .; WD: workday NW: non-workday
126 .S VAR=$S(WORKDAY:"WD",1:"NW")
127 .S NODE=""
128 .F S NODE=$O(^TMP($J,HDATE,NODE)) Q:NODE="" D
129 ..K NW,WD
130 ..S JOB=""
131 ..F S JOB=$O(^TMP($J,HDATE,NODE,JOB)) Q:'JOB D
132 ...S DATA=^TMP($J,HDATE,NODE,JOB)
133 ...F I=1:1:24 S CNT=$P(DATA,U,I) I +CNT D
134 ....S $P(@VAR@(1.1),U,I)=$P($G(@VAR@(1.1)),U,I)+CNT
135 ....S $P(@VAR@(1.2),U,I)=$P($G(@VAR@(1.2)),U,I)+1
136 ..;
137 ..; file number of users information
138 ..D FILE^KMPRBD03(HDATE,NODE,"#USERS#",.WD,.NW)
139 ;
140 K ^TMP($J)
141 ;
142 Q
Note: See TracBrowser for help on using the repository browser.