%ZOSV2 ; SFISC/JC - Capacity Mgmt - Performance Data ;06/27/96  10:17
 ;;8.0;KERNEL;**35**;JUL 03, 1995
DB ;Collect volume set information for this environment
START D VSET^%VOLDEF I '%SMSTART G DONE
S0 S ALL=1,ANS="Y"
 S A=$ZC(%VIEWBUFFER,1)
 S VSNUM="",VOLNUM="",GRTOT=0
S1 S VSNUM=$O(%VOL(VSNUM)),BLK0=0 G:VSNUM="" S3
S2 S VOLNUM=$O(%VOL(VSNUM,VOLNUM)) G:VOLNUM="" S1
 I VOLNUM="BIJ" G S2
 S DDU=$P(%VOL(VSNUM,VOLNUM),"^"),MPS=$P(%VOL(VSNUM,VOLNUM),"^",2),STRNO="S"_VSNUM
 D DISK S BLK0=BLK0+(MPS*400) G S2
 ;
S3 ;
DONE K QUES,DTAB,D,TYY,UU,DDU,YES,ALL,Y,BLK0,GRTOT
 K PREV,MPS,M0,MP0,CT,MBLK,AVAIL,TYP,USE,OLDAVAIL,OLDUSE
 K %ISAV,%NULL,TAV,TYPES
EXIT Q
 ;
DISK ; Set up XUCM ARRAY
 S TAV=0,CNT=1+$G(CNT)
 S XUCM(CNT)=VOLNUM_"^"_DDU_"^"
 D GETSTAT^%VOLTAB I '%RDACC Q
 S PREV=100 F M0=0:1:MPS S MBLK=M0*400+399+BLK0 D MAPGET
 S XUCM(CNT)=XUCM(CNT)_TAV_"^"_(MPS*400)
 ;
MAPGET ;
 I M0=MPS Q
 S AVAIL=0,$ZE="ERR" V MBLK:STRNO S $ZE="" G NOERR
ERR S $ZE="",TYP=100 G TYPCHK
NOERR I $V(1006,0,2)=65535&($V(1012,0,2)=32769) G OK
NOTOK S TYP=100 G TYPCHK
OK I $V(1008,0,2)=56173 S USE="* SPOOL *",TYP=4 G TYPCHK
 I $V(1008,0,2)+$V(1010,0,2)'=65535 G NOTOK
 S AVAIL=$V(1022,0,2) G SPECL:$V(1008,0,2)'=21845
 I AVAIL=399 S TYP=1 G TYPCHK
 I AVAIL=398,M0=0 S TYP=100 G TYPCHK
 S TYP=100 S:AVAIL=0 TYP=5 G TYPCHK
SPECL I AVAIL S AVAIL=0,TYP=100 G TYPCHK
 I $V(1008,0,2)=13107 S TYP=3 G TYPCHK
 I $V(1008,0,2)=43690 S TYP=2 G TYPCHK
 G NOTOK
 ;
TYPCHK S TAV=TAV+AVAIL I TYP=100 G NEWTYP
 I TYP=PREV S CT=CT+1 Q
 S MP0=M0,CT=0,OLDAVAIL=AVAIL
NEWTYP S PREV=TYP
 Q
RTHSTOP ;(TASKMAN-RUN IN MGR@0001) STOP RTHIST/MOVE OUT DATA/PURGE RTH
 Q:$$OS<6.1
 N I,J,K,L,M,N,O,P,Q,R,X,C,S D INIT^%VOLDEF,GETGRP^%SYSROU
 ;I '$D(^["MGR"]RTH(SCSNODE)),$V(%SMSTART)\32#2'=1 G RTH
 S RTNODE="" F  S RTNODE=$O(^["MGR"]RTH(RTNODE)) Q:RTNODE=""  D
 .S ^["MGR"]RTH(RTNODE)=0
 .S ^%ZRTL("RTH",RTNODE)=0,C=0
 .S SUB=0,U="^" F  S SUB=$O(^["MGR"]RTH(RTNODE,SUB)) Q:SUB<1  D
 ..Q:$G(^["MGR"]RTH(RTNODE,SUB,"LABEL"))'["VPM"
 ..Q:'$D(^["MGR"]RTH(RTNODE,SUB,"STIME"))  S %H=^("STIME") D YX^%DTC S S=$P(^["MGR"]RTH(RTNODE,SUB,"ETIME"),",",1)-$P(^("STIME"),",",1)*86400+$P(^("ETIME"),",",2)-$P(^("STIME"),",",2)
 ..S I=$G(^["MGR"]RTH(RTNODE,SUB,"ROUREF")) I I S I=I*10/S+.5\1/10
 ..S J=$G(^["MGR"]RTH(RTNODE,SUB,"MAPROU")) I J S J=J*10/S+.5\1/10
 ..S K=$G(^["MGR"]RTH(RTNODE,SUB,"Global Gets")) I K S K=K*10/S+.5\1/10
 ..S L=$G(^["MGR"]RTH(RTNODE,SUB,"Global Sets")) I L S L=L*10/S+.5\1/10
 ..S M=$G(^["MGR"]RTH(RTNODE,SUB,"Global Kills")) I M S M=M*10/S+.5\1/10
 ..S N=$G(^["MGR"]RTH(RTNODE,SUB,"Logical Reads")) I N S N=N*10/S+.5\1/10
 ..S O=$G(^["MGR"]RTH(RTNODE,SUB,"Logical Writes")) I O S O=O*10/S+.5\1/10
 ..S P=$G(^["MGR"]RTH(RTNODE,SUB,"Physical Reads")) I P S P=P*10/S+.5\1/10
 ..S Q=$G(^["MGR"]RTH(RTNODE,SUB,"Physical Writes")) I Q S Q=Q*10/S+.5\1/10
 ..S Z="",R=0 F  S Z=$O(^["MGR"]RTH(RTNODE,SUB,"DDP",Z)) Q:Z=""  S R=R+$G(^(Z,"XMTS"))
 ..I R S R=R*10/S+.5\1/10
 ..S C=1+C,^%ZRTL("RTH",RTNODE,C)=RTNODE_U_SUB_U_$TR(Y,":")_U_S_U_I_U_J_U_K_U_L_U_M_U_N_U_O_U_P_U_Q_U_R
 ..I $D(^["MGR"]RTH(RTNODE,SUB,"PMF-R","TTYGLOREF")) D
 ...S ^%ZRTL("RTH",RTNODE,"RT",SUB,0)=^["MGR"]RTH(RTNODE,SUB,"STIME")
 ...S X=0 F  S X=$O(^["MGR"]RTH(RTNODE,SUB,"PMF-R","TTYGLOREF",X)) Q:X<1  S Y=^(X),^%ZRTL("RTH",RTNODE,"RT",SUB,X)=Y
 .S ^%ZRTL("RTH",RTNODE)=1
 Q
RTH ;(TASKMAN) INITIATE NEW RTHIST DATA COLLECTIONS FOR THE DAY
 Q:$$OS<6.1
 D INIT^%VOLDEF,GETGRP^%SYSROU
 S LOOP=0
LOOP ;WAIT UNTIL LAST SESSION COMPLETES
 I LOOP>90 S $ZE="Timed Out Starting RTHIST" D ^%ZTER Q
 I $V(%SMSTART)\32#2=1 S LOOP=LOOP+1 H 60 G LOOP
 K ^["MGR"]RTH(SCSNODE) S ^["MGR"]RTH(SCSNODE)=0
 S TIMS=24,TIM=10,TIMI=50
 S X="NOW",%DT="T" D ^%DT D DD^%DT S NOW=Y
 S SUB=0 F I=1:1 Q:$O(^["MGR"]RTH(SCSNODE,SUB))=""  S SUB=$O(^(SUB))
 S WHEN=$P($ZH,",",3),LAB="VPM SESSION-"_NOW
 I $$OS>6.1 S CONF=$ZC(%VERSION,"INTERNAL")
 E  S CONF=$ZV
 S CONF=CONF_","_^[LIB]SYS(-1,SCSNODE,"RUNNING")
 S SZ=^[LIB]SYS(^("RUNNING"),"RTHIST","BUFFERS")*512
 S RTHOPT="/MANAGER/UCI=MGR/NORMS_ROU/NORMS_LIB/SYM=50000/SOU=20000"
 S X=$$CVDAT^RTHIST(WHEN),$ZT="TRAP^%ZOSV2"
 J START^RTHIST1(SZ,TIM,TIMS,TIMI,X,SUB,CONF,LAB,SCSNODE):(ERROR="VPM$RTHIST.LOG":OPTIONS=RTHOPT:NAME="VPM_RTHIST_"_GRP)
 I $D(ZTQUEUED) S ZTREQ="@"
 Q
TRAP ;Give process time to die off
 I $ZE["SYSTEM-F-DUPLNAM" S RETRY=$G(RETRY)+1
 I RETRY'>90 H 60 G RTH
 K RETRY
 Q
RT ;
 N NODE,RUN,ET,CNT,ZCT,STIM,X
 Q:^%ZOSF("OS")'["DSM"
 W " Node",?7,"Run",?24,"Label",?48,"Start",?57,"ET",?61,"Count",?70,"RT",!
 S (NODE,RUN)=0 F  S NODE=$O(^["MGR"]RTH(NODE)) Q:NODE=""  D
 . F  S RUN=$O(^["MGR"]RTH(NODE,RUN)) Q:RUN=""  D
 . . S (ET,CNT,ZCT)=0
 . . F I=1:1:34 S X=^["MGR"]RTH(NODE,RUN,"PMF-R","TTYGLOREF",I) D
 . . . S ET=ET+$P(X,";",2),Y=$P(X,";",3),ZCT=ZCT+Y
 . . . F J=1:1:12 S CNT=CNT+$P(Y,",",J)
 . . I $$OS<6.5 S ET=ET+(.3*ZCT)+(.5*(CNT-ZCT))
 . . I $$OS'<6.5 S ET=ET/100+(.005*CNT)
 . . S X=$P(^["MGR"]RTH(NODE,RUN,"STIME"),",",2)
 . . S H=X\3600,M=X#3600\60,S=X#3600#60
 . . S STIM=$J(H,2)_":"_$S($L(M)<2:0_M,1:M)_":"_$S($L(S)<2:0_S,1:S)
 . . W NODE,?7,$J(RUN,3),?13,$E(^["MGR"]RTH(NODE,RUN,"LABEL"),1,30),?45,STIM,?55,$J($P(^("ETIME"),",",2)-$P(^("STIME"),",",2),4),?60,$J(CNT,6),?69 W:CNT $J(ET/CNT,4,2)
 . . W !
 Q
TRNLNM(%) ;TRANSLATE A VAX LOGICAL
 I ^%ZOSF("OS")'["VAX" Q ""
 I $$OS>6.1 Q $ZC(%TRNLNM,%)
 E  Q $ZC(%TRNLOG,%)
OS() ;
 Q $P($ZV," V",2)
PRV() ;current privs
 Q $&ZLIB.%GETJPI("","CURPRIV")
