XUSTAT1 ;SF/RWF - User/CPU stats part 2 ;9/9/91 09:19 ;
;;8.0;KERNEL;;Jul 10, 1995
U IO S (XUTREC,XUNODT,XUNOSER,XUNOTM)=0,XUDT=XUST-.000001,(XU1,XU2)=1,XUSTSK(1)="BT"[XUSTSK,XUSTSK(2)="BU"[XUSTSK
F I=1:1 S XUDT=$O(^XUSEC(0,XUDT)) Q:(XUDT'>0)!(XUDT>XUEN) S XUVAL=^XUSEC(0,XUDT,0) D SELCT
G ^XUSTAT2
;
SELCT S XUTREC=XUTREC+1,XUDATE=$P(XUVAL,U,4),XUCPU=$P(XUVAL,U,5),XUNAME(XUCPU)="",XUDUZ=+XUVAL S:'$L(XUCPU) XUCPU="UNKNOWN" S:'$L(XUDATE) XUNODT=XUNODT+1 S:$P(XUVAL,U,6) XUNOTM=XUNOTM+1
S XUTIME=0 I XUDATE S X=XUDT D H^%DTC S XUI(1)=%H,XUI(2)=%T,X=XUDATE D H^%DTC S XUTIME=(%H-XUI(1)*86400)+(%T-XUI(2))
S X=$P(XUVAL,U,6)
I (XUSTSK(1)&X)!(XUSTSK(2)&'X) D PROC:XUSORT="V",USER:XUSORT="U",SERV:XUSORT="S",DEV:XUSORT="D"
Q
PROC ;By processer
I XUSS Q:'$D(XUSS(XUCPU))
I XUDUZ S ^(XUDUZ)=$G(^TMP($J,"DUZ",XUCPU,XUDUZ))+1
S:'$D(XUNAME(XUCPU))#2 XUNAME(XUCPU)=0
Q:'XUDATE S XU1=XUCPU D CALC Q
CALC ;
S ^TMP($J,"TIME",XU1,XU2)=$G(^TMP($J,"TIME",XU1,XU2))+XUTIME
Q
USER ;By user
I XUSS Q:'$D(XUSS(XUDUZ))
S:'$D(XUNAME(XUCPU))#2 XUNAME(XUCPU)=0 G:'XUDUZ UX
I 'XUSS S ^TMP($J,0,$P(^VA(200,XUDUZ,0),U,1))=XUDUZ
S ^(XUCPU)=$G(^TMP($J,"CPU",XUDUZ,XUCPU))+1
S:'XUDATE ^(XUCPU)=$G(^TMP($J,"NODAT",XUDUZ,XUCPU))+1
UX Q:'XUDATE S XU1=XUDUZ,XU2=XUCPU D CALC
Q
DEV ;By device
S XUDEV=$S($P(XUVAL,"^",9)]"":$P(XUVAL,"^",9),1:$P(XUVAL,"^",7)) Q:XUDEV']""
I XUSS Q:'$D(XUSS(XUDEV))
S ^(XUCPU)=$G(^TMP($J,"DEV",XUDEV,XUCPU))+1
S:'XUDATE ^(XUCPU)=$G(^TMP($J,"NODAT",XUDEV,XUCPU))+1
Q:'XUDATE S XU1=XUDEV,XU2=XUCPU D CALC
Q
SERV ;By service
S X=+$G(^VA(200,XUDUZ,5)),XUSER=$S($D(^DIC(49,X,0)):$P(^(0),U,1),1:"UNKNOWN")
I XUSS Q:'$D(XUSS(X))&(XUSER'="UNKNOWN")
S:'$D(^TMP($J,"SER",XUSER))#2 ^TMP($J,"SER",XUSER)=0
S ^(XUSER)=$G(^TMP($J,"SER",XUSER))+1
Q:'XUDATE S XU1=XUSER D CALC Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXUSTAT1 1839 printed Dec 13, 2024@02:13:01 Page 2
XUSTAT1 ;SF/RWF - User/CPU stats part 2 ;9/9/91 09:19 ;
+1 ;;8.0;KERNEL;;Jul 10, 1995
+2 USE IO
SET (XUTREC,XUNODT,XUNOSER,XUNOTM)=0
SET XUDT=XUST-.000001
SET (XU1,XU2)=1
SET XUSTSK(1)="BT"[XUSTSK
SET XUSTSK(2)="BU"[XUSTSK
+3 FOR I=1:1
SET XUDT=$ORDER(^XUSEC(0,XUDT))
if (XUDT'>0)!(XUDT>XUEN)
QUIT
SET XUVAL=^XUSEC(0,XUDT,0)
DO SELCT
+4 GOTO ^XUSTAT2
+5 ;
SELCT SET XUTREC=XUTREC+1
SET XUDATE=$PIECE(XUVAL,U,4)
SET XUCPU=$PIECE(XUVAL,U,5)
SET XUNAME(XUCPU)=""
SET XUDUZ=+XUVAL
if '$LENGTH(XUCPU)
SET XUCPU="UNKNOWN"
if '$LENGTH(XUDATE)
SET XUNODT=XUNODT+1
if $PIECE(XUVAL,U,6)
SET XUNOTM=XUNOTM+1
+1 SET XUTIME=0
IF XUDATE
SET X=XUDT
DO H^%DTC
SET XUI(1)=%H
SET XUI(2)=%T
SET X=XUDATE
DO H^%DTC
SET XUTIME=(%H-XUI(1)*86400)+(%T-XUI(2))
+2 SET X=$PIECE(XUVAL,U,6)
+3 IF (XUSTSK(1)&X)!(XUSTSK(2)&'X)
if XUSORT="V"
DO PROC
if XUSORT="U"
DO USER
if XUSORT="S"
DO SERV
if XUSORT="D"
DO DEV
+4 QUIT
PROC ;By processer
+1 IF XUSS
if '$DATA(XUSS(XUCPU))
QUIT
+2 IF XUDUZ
SET ^(XUDUZ)=$GET(^TMP($JOB,"DUZ",XUCPU,XUDUZ))+1
+3 if '$DATA(XUNAME(XUCPU))#2
SET XUNAME(XUCPU)=0
+4 if 'XUDATE
QUIT
SET XU1=XUCPU
DO CALC
QUIT
CALC ;
+1 SET ^TMP($JOB,"TIME",XU1,XU2)=$GET(^TMP($JOB,"TIME",XU1,XU2))+XUTIME
+2 QUIT
USER ;By user
+1 IF XUSS
if '$DATA(XUSS(XUDUZ))
QUIT
+2 if '$DATA(XUNAME(XUCPU))#2
SET XUNAME(XUCPU)=0
if 'XUDUZ
GOTO UX
+3 IF 'XUSS
SET ^TMP($JOB,0,$PIECE(^VA(200,XUDUZ,0),U,1))=XUDUZ
+4 SET ^(XUCPU)=$GET(^TMP($JOB,"CPU",XUDUZ,XUCPU))+1
+5 if 'XUDATE
SET ^(XUCPU)=$GET(^TMP($JOB,"NODAT",XUDUZ,XUCPU))+1
UX if 'XUDATE
QUIT
SET XU1=XUDUZ
SET XU2=XUCPU
DO CALC
+1 QUIT
DEV ;By device
+1 SET XUDEV=$SELECT($PIECE(XUVAL,"^",9)]"":$PIECE(XUVAL,"^",9),1:$PIECE(XUVAL,"^",7))
if XUDEV']""
QUIT
+2 IF XUSS
if '$DATA(XUSS(XUDEV))
QUIT
+3 SET ^(XUCPU)=$GET(^TMP($JOB,"DEV",XUDEV,XUCPU))+1
+4 if 'XUDATE
SET ^(XUCPU)=$GET(^TMP($JOB,"NODAT",XUDEV,XUCPU))+1
+5 if 'XUDATE
QUIT
SET XU1=XUDEV
SET XU2=XUCPU
DO CALC
+6 QUIT
SERV ;By service
+1 SET X=+$GET(^VA(200,XUDUZ,5))
SET XUSER=$SELECT($DATA(^DIC(49,X,0)):$PIECE(^(0),U,1),1:"UNKNOWN")
+2 IF XUSS
if '$DATA(XUSS(X))&(XUSER'="UNKNOWN")
QUIT
+3 if '$DATA(^TMP($JOB,"SER",XUSER))#2
SET ^TMP($JOB,"SER",XUSER)=0
+4 SET ^(XUSER)=$GET(^TMP($JOB,"SER",XUSER))+1
+5 if 'XUDATE
QUIT
SET XU1=XUSER
DO CALC
QUIT
+6 QUIT