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