XUCPFRMT ;SFISC/HVB/VYD/JC - Resource Usage Table or Graph ;6/20/95 08:47 [ 04/02/2003 8:47 AM ]
;;7.3;TOOLKIT;**1001**;APR 1, 2003
;;7.3;TOOLKIT;**5**;Apr 25, 1995
I $D(^XTMP("XUCP","zzz"))'=11 W !!!,"There is no data to print from.",!,"Please run SORT RAW RESOURCE USAGE DATA option first." Q
W !!!,"I will write out Resource Usage by Namespace, based on the preceding sort.",!
N XTR,FRMT,ACT,%H,SDT,EDT,NODE,FNAME,XUCPQ,TOFILE,T,X,X1,C,D,I,N
S DIR(0)="Y",DIR("A")="Subtotal by Node",DIR("B")="YES" D ^DIR K DIR Q:$D(DTOUT)!$D(DUOUT) S ACT=$S(Y:"NODE",1:"CUM")
I ACT'["CUM" S DIR(0)="Y",DIR("A")="Would you also like cumulative by option for all nodes",DIR("B")="YES" D ^DIR K DIR Q:$D(DTOUT)!$D(DUOUT) S:Y ACT=ACT_"CUM"
S DIR(0)="NA^1:8:0",DIR("A")="Namespace length: ",DIR("B")=4 D ^DIR K DIR Q:$D(DTOUT)!$D(DUOUT) S XTR=Y
S DIR(0)="SA^T:Table;G:Graph",DIR("A")="Format for report (<T>able/<G>raph): ",DIR("B")="T" D ^DIR K DIR Q:$D(DTOUT)!$D(DUOUT) S FRMT=Y
DEVICE S NODE=$O(^XTMP("XUCP",""))
S %H=$P(^XTMP("XUCP","zzz"),"^") D YX^%DTC S SDT=Y,%H=$P(^XTMP("XUCP","zzz"),"^",2) D YX^%DTC S EDT=Y
S SDT=$TR(SDT," ,@:"),EDT=$TR(EDT," ,@:")
S FNAME=$S(ACT["CUM":"CUM"_$E(NODE,1,4),1:NODE)_"_"_SDT_"_"_EDT_".XUCP"_FRMT
S DIR("A")="Write to file ("_FNAME_")",DIR(0)="Y",DIR("B")="YES"
D ^DIR K DIR S TOFILE=Y Q:$D(DTOUT)!$D(DUOUT)
S:TOFILE %ZIS("HFSNAME")=FNAME,%ZIS("HFSMODE")="W",IOP="HFS"_$S(FRMT="G":";132",1:";80")
I TOFILE S DIR("A")="Would you like to queue this job for background execution",DIR(0)="Y",DIR("B")="YES" D ^DIR K DIR S XUCPQ=Y Q:$D(DTOUT)!$D(DUOUT)
S:TOFILE&$G(XUCPQ) IOP="Q;"_IOP
S %ZIS=$S('TOFILE:"MQ",$G(XUCPQ)&TOFILE:"NQ",1:"") D ^%ZIS Q:POP
I FRMT="T",IOM<80 W !,"The TABLE format requires at least 80 column device." G DEVICE
I FRMT="G",IOM<132 W !,"The GRAPH format requires at least 132 column device." G DEVICE
I $D(IO("Q")) S ZTRTN="DQ^XUCPFRMT" D Q
.S ZTDESC="Resource Usage by Option ("_$S(FRMT="G":"Graph",1:"Table")_")"
.S (ZTSAVE("XTR"),ZTSAVE("FRMT"),ZTSAVE("ACT"))="" D ^%ZTLOAD,HOME^%ZIS
.W:$D(ZTSK) !,"Queued as task ",ZTSK,!
DQ ;PRINT REPORT (POSSIBLY BY TASKMAN)
G:$D(^XTMP("XUCP","zzz"))<11 END ;quit if no sorted data to output
N OPT,NODE,DATE,JOB,TIME,SC,SD,SN,XOPT,SDT,EDT
S X=^%ZOSF("ERRTN"),@^%ZOSF("TRAP") ;necessary because of the NEW cmnd
S %H=$P(^XTMP("XUCP","zzz"),U) D YX^%DTC S SDT=Y,%H=$P(^("zzz"),U,2) D YX^%DTC S EDT=Y
K ^TMP($J)
COLLECT ;
S (OPT,NODE,DATE,JOB,TIME)=""
F S OPT=$O(^XTMP("XUCP","zzz",OPT)) Q:OPT="" D
.F S NODE=$O(^XTMP("XUCP","zzz",OPT,NODE)) Q:NODE="" D
..F S DATE=$O(^XTMP("XUCP","zzz",OPT,NODE,DATE)) Q:DATE="" D
...F S JOB=$O(^XTMP("XUCP","zzz",OPT,NODE,DATE,JOB)) Q:JOB="" D
....F S TIME=$O(^XTMP("XUCP","zzz",OPT,NODE,DATE,JOB,TIME)) Q:TIME="" S X=^(TIME),XOPT=$E(OPT,1,XTR) D
.....I ACT["NODE" D
......S X1=$G(^TMP($J,"N",NODE,XOPT))+1,^(XOPT)=X1
......S X1=$G(^TMP($J,"C",NODE,XOPT))+$P(X,U),^(XOPT)=X1
......S X1=$G(^TMP($J,"D",NODE,XOPT))+$P(X,U,2),^(XOPT)=X1
......S X1=$G(^TMP($J,"T",NODE,XOPT))+$P(X,U,5),^(XOPT)=X1
.....I ACT["CUM" D
......S X1=$G(^TMP($J,"N","zCUM",XOPT))+1,^(XOPT)=X1
......S X1=$G(^TMP($J,"C","zCUM",XOPT))+$P(X,U),^(XOPT)=X1
......S X1=$G(^TMP($J,"D","zCUM",XOPT))+$P(X,U,2),^(XOPT)=X1
......S X1=$G(^TMP($J,"T","zCUM",XOPT))+$P(X,U,5),^(XOPT)=X1
U IO
PRINT ;PRINT DATA SUBTOTALED BY NODE (NODE zCUM IS ACTUALLY TOTALS)
S OPT="",NODE=$S(ACT["NODE":"",1:"ZZZ")
F S NODE=$O(^TMP($J,"C",NODE)) Q:NODE=""!(NODE="zCUM"&(ACT'["CUM")) D
.S (SC,SD,SN)=0
.W $S(NODE'="zCUM":"Node "_NODE,1:"Station "_$E($O(^XTMP("XUCP",0)),1,4))
.W " from ",SDT," to ",EDT,!
.W:$L($P(^XTMP("XUCP","zzz"),U,3)) ?(8+((FRMT="G")*27)),"*** Merged data may not be continuous over the date range! ***",!
.I FRMT="G" W "OPT",?10,"CPUSEC",?118,"DIO",?124,"SEC",?131,"N",!!
.E W !,?8,$J($E("OPT",1,XTR),XTR),$J("CPU",7),$J("DIO",7),$J("SEC",7) D
..W $J("N",5),$J("C/N",7),$J("D/N",7),$J("S/N",7),$J("C/S",6),$J("D/S",5),!!
NDLOOP .F S OPT=$O(^TMP($J,"C",NODE,OPT)) Q:OPT="" D
..S C=^TMP($J,"C",NODE,OPT),D=^TMP($J,"D",NODE,OPT),T=^TMP($J,"T",NODE,OPT),N=^TMP($J,"N",NODE,OPT)
..D GRPHOUT:FRMT="G",TABLOUT:FRMT="T"
..S SC=SC+^TMP($J,"C",NODE,OPT),SD=SD+^TMP($J,"D",NODE,OPT),SN=SN+^TMP($J,"N",NODE,OPT) ;accum totals
TOTALS .W ! W:FRMT="T" ?3+XTR W "TOTAL" W:FRMT="G" ?7
.W $J(SC+.5\1,7) W:FRMT="G" ?114
.W $J(SD,7),?$X+$S(FRMT="G":5,1:6),$J(SN,6)
END D ^%ZISC K ^TMP($J),XTR,FRMT,ACT,T,X,X1,Y,Y1,C,D,I,N,ZTDESC,ZTRTN,ZTSAVE,ZTSK
Q
GRPHOUT W $J(OPT,XTR),?8,$J(C,6,0) S X=C/5\1 W:X>50 "<" S:X>50 X=50 W ?(65-X) F I=1:1:X W "*"
S (Y,Y1)=D/500\1 S:Y>49 Y=49 F I=1:1:Y W "-"
W:Y1>49 ">" W ?115,$J(D,6),$J(T+.5\1,6),$J(N,5),!
Q
TABLOUT W ?8,$J(OPT,XTR),$J(C+.5\1,7),$J(D,7),$J(T+.5\1,7),$J(N,5),$J(C*100+.5/N\1/100,7,2),$J(D*10+.5/N\1/10,7,1),$J(T*10+.5/N\1/10,7,1),$J(C*1000+.5/T\1/1000,6,2),$J(D*100+.5/T\1/100,5,1),!
Q
XUCPFRMT ;SFISC/HVB/VYD/JC - Resource Usage Table or Graph ;6/20/95 08:47 [ 04/02/2003 8:47 AM ]
+1 ;;7.3;TOOLKIT;**1001**;APR 1, 2003
+2 ;;7.3;TOOLKIT;**5**;Apr 25, 1995
+3 IF $DATA(^XTMP("XUCP","zzz"))'=11
WRITE !!!,"There is no data to print from.",!,"Please run SORT RAW RESOURCE USAGE DATA option first."
QUIT
+4 WRITE !!!,"I will write out Resource Usage by Namespace, based on the preceding sort.",!
+5 NEW XTR,FRMT,ACT,%H,SDT,EDT,NODE,FNAME,XUCPQ,TOFILE,T,X,X1,C,D,I,N
+6 SET DIR(0)="Y"
SET DIR("A")="Subtotal by Node"
SET DIR("B")="YES"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET ACT=$SELECT(Y:"NODE",1:"CUM")
+7 IF ACT'["CUM"
SET DIR(0)="Y"
SET DIR("A")="Would you also like cumulative by option for all nodes"
SET DIR("B")="YES"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
IF Y
SET ACT=ACT_"CUM"
+8 SET DIR(0)="NA^1:8:0"
SET DIR("A")="Namespace length: "
SET DIR("B")=4
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET XTR=Y
+9 SET DIR(0)="SA^T:Table;G:Graph"
SET DIR("A")="Format for report (<T>able/<G>raph): "
SET DIR("B")="T"
DO ^DIR
KILL DIR
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
SET FRMT=Y
DEVICE SET NODE=$ORDER(^XTMP("XUCP",""))
+1 SET %H=$PIECE(^XTMP("XUCP","zzz"),"^")
DO YX^%DTC
SET SDT=Y
SET %H=$PIECE(^XTMP("XUCP","zzz"),"^",2)
DO YX^%DTC
SET EDT=Y
+2 SET SDT=$TRANSLATE(SDT," ,@:")
SET EDT=$TRANSLATE(EDT," ,@:")
+3 SET FNAME=$SELECT(ACT["CUM":"CUM"_$EXTRACT(NODE,1,4),1:NODE)_"_"_SDT_"_"_EDT_".XUCP"_FRMT
+4 SET DIR("A")="Write to file ("_FNAME_")"
SET DIR(0)="Y"
SET DIR("B")="YES"
+5 DO ^DIR
KILL DIR
SET TOFILE=Y
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+6 IF TOFILE
SET %ZIS("HFSNAME")=FNAME
SET %ZIS("HFSMODE")="W"
SET IOP="HFS"_$SELECT(FRMT="G":";132",1:";80")
+7 IF TOFILE
SET DIR("A")="Would you like to queue this job for background execution"
SET DIR(0)="Y"
SET DIR("B")="YES"
DO ^DIR
KILL DIR
SET XUCPQ=Y
IF $DATA(DTOUT)!$DATA(DUOUT)
QUIT
+8 IF TOFILE&$GET(XUCPQ)
SET IOP="Q;"_IOP
+9 SET %ZIS=$SELECT('TOFILE:"MQ",$GET(XUCPQ)&TOFILE:"NQ",1:"")
DO ^%ZIS
IF POP
QUIT
+10 IF FRMT="T"
IF IOM<80
WRITE !,"The TABLE format requires at least 80 column device."
GOTO DEVICE
+11 IF FRMT="G"
IF IOM<132
WRITE !,"The GRAPH format requires at least 132 column device."
GOTO DEVICE
+12 IF $DATA(IO("Q"))
SET ZTRTN="DQ^XUCPFRMT"
Begin DoDot:1
+13 SET ZTDESC="Resource Usage by Option ("_$SELECT(FRMT="G":"Graph",1:"Table")_")"
+14 SET (ZTSAVE("XTR"),ZTSAVE("FRMT"),ZTSAVE("ACT"))=""
DO ^%ZTLOAD
DO HOME^%ZIS
+15 IF $DATA(ZTSK)
WRITE !,"Queued as task ",ZTSK,!
End DoDot:1
QUIT
DQ ;PRINT REPORT (POSSIBLY BY TASKMAN)
+1 ;quit if no sorted data to output
IF $DATA(^XTMP("XUCP","zzz"))<11
GOTO END
+2 NEW OPT,NODE,DATE,JOB,TIME,SC,SD,SN,XOPT,SDT,EDT
+3 ;necessary because of the NEW cmnd
SET X=^%ZOSF("ERRTN")
SET @^%ZOSF("TRAP")
+4 SET %H=$PIECE(^XTMP("XUCP","zzz"),U)
DO YX^%DTC
SET SDT=Y
SET %H=$PIECE(^("zzz"),U,2)
DO YX^%DTC
SET EDT=Y
+5 KILL ^TMP($JOB)
COLLECT ;
+1 SET (OPT,NODE,DATE,JOB,TIME)=""
+2 FOR
SET OPT=$ORDER(^XTMP("XUCP","zzz",OPT))
IF OPT=""
QUIT
Begin DoDot:1
+3 FOR
SET NODE=$ORDER(^XTMP("XUCP","zzz",OPT,NODE))
IF NODE=""
QUIT
Begin DoDot:2
+4 FOR
SET DATE=$ORDER(^XTMP("XUCP","zzz",OPT,NODE,DATE))
IF DATE=""
QUIT
Begin DoDot:3
+5 FOR
SET JOB=$ORDER(^XTMP("XUCP","zzz",OPT,NODE,DATE,JOB))
IF JOB=""
QUIT
Begin DoDot:4
+6 FOR
SET TIME=$ORDER(^XTMP("XUCP","zzz",OPT,NODE,DATE,JOB,TIME))
IF TIME=""
QUIT
SET X=^(TIME)
SET XOPT=$EXTRACT(OPT,1,XTR)
Begin DoDot:5
+7 IF ACT["NODE"
Begin DoDot:6
+8 SET X1=$GET(^TMP($JOB,"N",NODE,XOPT))+1
SET ^(XOPT)=X1
+9 SET X1=$GET(^TMP($JOB,"C",NODE,XOPT))+$PIECE(X,U)
SET ^(XOPT)=X1
+10 SET X1=$GET(^TMP($JOB,"D",NODE,XOPT))+$PIECE(X,U,2)
SET ^(XOPT)=X1
+11 SET X1=$GET(^TMP($JOB,"T",NODE,XOPT))+$PIECE(X,U,5)
SET ^(XOPT)=X1
End DoDot:6
+12 IF ACT["CUM"
Begin DoDot:6
+13 SET X1=$GET(^TMP($JOB,"N","zCUM",XOPT))+1
SET ^(XOPT)=X1
+14 SET X1=$GET(^TMP($JOB,"C","zCUM",XOPT))+$PIECE(X,U)
SET ^(XOPT)=X1
+15 SET X1=$GET(^TMP($JOB,"D","zCUM",XOPT))+$PIECE(X,U,2)
SET ^(XOPT)=X1
+16 SET X1=$GET(^TMP($JOB,"T","zCUM",XOPT))+$PIECE(X,U,5)
SET ^(XOPT)=X1
End DoDot:6
End DoDot:5
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+17 USE IO
PRINT ;PRINT DATA SUBTOTALED BY NODE (NODE zCUM IS ACTUALLY TOTALS)
+1 SET OPT=""
SET NODE=$SELECT(ACT["NODE":"",1:"ZZZ")
+2 FOR
SET NODE=$ORDER(^TMP($JOB,"C",NODE))
IF NODE=""!(NODE="zCUM"&(ACT'["CUM"))
QUIT
Begin DoDot:1
+3 SET (SC,SD,SN)=0
WRITE @IOF
WRITE !?(9+((FRMT="G")*27))
+1 WRITE $SELECT(NODE'="zCUM":"Node "_NODE,1:"Station "_$EXTRACT($ORDER(^XTMP("XUCP",0)),1,4))
+2 WRITE " from ",SDT," to ",EDT,!
+3 IF $LENGTH($PIECE(^XTMP("XUCP","zzz"),U,3))
WRITE ?(8+((FRMT="G")*27)),"*** Merged data may not be continuous over the date range! ***",!
+4 IF FRMT="G"
WRITE "OPT",?10,"CPUSEC",?118,"DIO",?124,"SEC",?131,"N",!!
+5 IF '$TEST
WRITE !,?8,$JUSTIFY($EXTRACT("OPT",1,XTR),XTR),$JUSTIFY("CPU",7),$JUSTIFY("DIO",7),$JUSTIFY("SEC",7)
Begin DoDot:2
+6 WRITE $JUSTIFY("N",5),$JUSTIFY("C/N",7),$JUSTIFY("D/N",7),$JUSTIFY("S/N",7),$JUSTIFY("C/S",6),$JUSTIFY("D/S",5),!!
End DoDot:2
NDLOOP FOR
SET OPT=$ORDER(^TMP($JOB,"C",NODE,OPT))
IF OPT=""
QUIT
Begin DoDot:2
+1 SET C=^TMP($JOB,"C",NODE,OPT)
SET D=^TMP($JOB,"D",NODE,OPT)
SET T=^TMP($JOB,"T",NODE,OPT)
SET N=^TMP($JOB,"N",NODE,OPT)
+2 IF FRMT="G"
DO GRPHOUT
IF FRMT="T"
DO TABLOUT
+3 ;accum totals
SET SC=SC+^TMP($JOB,"C",NODE,OPT)
SET SD=SD+^TMP($JOB,"D",NODE,OPT)
SET SN=SN+^TMP($JOB,"N",NODE,OPT)
End DoDot:2
TOTALS WRITE !
IF FRMT="T"
WRITE ?3+XTR
WRITE "TOTAL"
IF FRMT="G"
WRITE ?7
+1 WRITE $JUSTIFY(SC+.5\1,7)
IF FRMT="G"
WRITE ?114
+2 WRITE $JUSTIFY(SD,7),?$X+$SELECT(FRMT="G":5,1:6),$JUSTIFY(SN,6)
End DoDot:1
END DO ^%ZISC
KILL ^TMP($JOB),XTR,FRMT,ACT,T,X,X1,Y,Y1,C,D,I,N,ZTDESC,ZTRTN,ZTSAVE,ZTSK
+1 QUIT
GRPHOUT WRITE $JUSTIFY(OPT,XTR),?8,$JUSTIFY(C,6,0)
SET X=C/5\1
IF X>50
WRITE "<"
IF X>50
SET X=50
WRITE ?(65-X)
FOR I=1:1:X
WRITE "*"
+1 SET (Y,Y1)=D/500\1
IF Y>49
SET Y=49
FOR I=1:1:Y
WRITE "-"
+2 IF Y1>49
WRITE ">"
WRITE ?115,$JUSTIFY(D,6),$JUSTIFY(T+.5\1,6),$JUSTIFY(N,5),!
+3 QUIT
TABLOUT WRITE ?8,$JUSTIFY(OPT,XTR),$JUSTIFY(C+.5\1,7),$JUSTIFY(D,7),$JUSTIFY(T+.5\1,7),$JUSTIFY(N,5),$JUSTIFY(C*100+.5/N\1/100,7,2),$JUSTIFY(D*10+.5/N\1/10,7,1),$JUSTIFY(T*10+.5/N\1/10,7,1),$JUSTIFY(C*1000+.5/T\1/1000,6,2),$JUSTIFY(D*100+.5/T\1/100,5,1
),!
+1 QUIT