cQGSIZE(t) ;Data-M Global Size Utility ;cQGSIZE; ; S t=+$G(t) I ($P($P($ZV,")",2),"(",1)[" 2008")!($P($P($ZV,")",2),"(",1)[" 2010") D ^cQGSIZE8(t) Q BEGIN S cs=$ZU(5),$ZT="ERR^"_$T(+0) ; START D GDB^cQAUTOBU(.V) I '$D(V($ZU(5))) Q S B=X($ZU(5),"globals"),B=$P(B,"\",1,$L(B,"\")-2)_"\" ZN "%SYS" J BldInfo^%Wsdba("",0) ZN cs H 2 L +^%SYS("database") ;try to lock this global L -^%SYS("database") ;if succeeded, %Wsdba has finished S EX="\CacheTemp\ERRORS\HULP\ROUTINE\TEMP\TMP\UTILITY\ZZLOG\cIPRINT\cJOB\cLOG\cPRINT\cQSYS\cTABEL\mtemp\mtemp0\mtemp1\rOBJ\" S home=$ZU(5),LOG="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""calc"")" K @LOG D INT^%D,INT^%T S ^|home|ZZLOG("%GSIZE",$ZCVT($ZU(110),"U"),0,0,1)="Start\"_%DAT_" "_%TIM F I=0:1:99 S DIR=B_I_"\" I $L($zu(12,DIR,3)) D GET zn cs SUM S G="",LOGN="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""sum"")",LOGS="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""sorted"")" K @LOGN,@LOGS F S G=$O(@LOG@(G)) Q:G="" S H="",S=0 D S @LOGN@(G)=S I G'=0 S @LOGS@(S,G)="" . F S H=$O(@LOG@(G,H)) Q:H="" S S=$P(^(H),"\")*blksiz+S I G=0 S @LOGN@(G,H)=$P(@LOG@(G,H),"\")*blksiz D COLL S PG=$T(+0),PN=$P($T(+1),";",2) D D1016^cANEM0(PG,PN,.R) D INT^%D,INT^%T S ^|home|ZZLOG("%GSIZE",$ZCVT($ZU(110),"U"),0,0,2)="End \"_%DAT_" "_%TIM zn cs Q ; DISP(t) S t=+$G(t) D COLL F I=1:1:R W !,R(I) Q ; COLL ; Collect data S t=+$G(t),home=$ZU(5),LOG="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""calc"")" S LOGN="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""sum"")",LOGS="^|home|ZZLOG(""%GSIZE"","""_$ZCVT($ZU(110),"U")_""",""sorted"")" K ADRES,R,S,VAR S (DB,R,S,T,V,W,Y)=0,P1=35,P2=47,P3=57,P4=69,P5=79 S R=$G(R)+1,R(R)="X Database",$E(R(R),P1)=$J("Cur Size",12),$E(R(R),P2)=$J("Cur %Full",10) S $E(R(R),P3)=$J("Max Size",12),$E(R(R),P4)=$J("Max %Full",10),$E(R(R),P5)=$J("Cur In Use",12) S R=$G(R)+1,R(R)="- --------",$E(R(R),P1)=$J("----------",12),$E(R(R),P2)=$J("---------",10) S $E(R(R),P3)=$J("----------",12),$E(R(R),P4)=$J("---------",10),$E(R(R),P5)=$J("----------",12) F S DB=$O(^%SYS("database",DB)) Q:DB="" D . S K=^(DB),CUR=+$P(K,$C(1),1),CURP=+$P(K,$C(1),2)*100,MAX=+$P(K,$C(1),3),MAXP=+$P(K,$C(1),4)*100,USE=CUR*CURP/100 . I ($P($P($ZV,")",2),"(",1)[" 5.") S MAX=MAX/128 . S R=$G(R)+1,R(R)=" "_DB,$E(R(R),P1)=$$NMBR(CUR),$E(R(R),P2)=$$PROC(CURP),$E(R(R),P3)=$$NMBR(MAX),$E(R(R),P4)=$$PROC(MAXP),$E(R(R),P5)=$$NMBR(USE) . S T=T+CUR,V=V+MAX,Y=Y+USE . ;If Maximum percentage full > 97% => alarm *** in elk geval opzetten . I MAXP>98 S $E(R(R))="A" S W=2,RS=R Q . ;If Maximum percentage full > 95% => warning *** alleen indien nog geen Alarm . I MAXP>96 S $E(R(R))="W" S:'W W=1,RS=R Q S R=R+1,$E(R(R),P1)="-------------",$E(R(R),P3)="-------------",$E(R(R),P5)="-------------" S R=R+1,$E(R(R),P1)=$$NMBR(T),$E(R(R),P3)=$$NMBR(V),$E(R(R),P5)=$$NMBR(Y) S R=$G(R)+1,R(R)="",S="" F I=1:1:t S S=$O(@LOGS@(S),-1) Q:S="" S H="" D . F S H=$O(@LOGS@(S,H)) Q:H="" S R=$G(R)+1,R(R)=$J(I,2)_". ^"_H,$E(R(R),15)=$$NMBR(S/1024/1024) S I="" F S I=$O(R(I)) Q:I="" S R(I)=$TR(R(I),"\","/") Q ; NMBR(X) S X=+$G(X) I X>999999 Q $J($FN(X/1024,".",0),9)_" GB" Q $J($FN(X,".",0),9)_" MB" ; PROC(X) Q $J(X,9,0)_"%" ; ; GET I '($P($P($ZV,")",2),"(",1)[" 5.") Set blksiz=2048 G GET1 If $zbitget($zversion(0),21) { Set dirinfo=$zu(49,DIR) If (+dirinfo)<0 Write !,*7,DIR," is not available" Quit Set bigdb=$Piece(dirinfo,",",21) Set blksiz=$Piece(dirinfo,",",2) } else { Set bigdb=0 Set blksiz=2048 } GET1 s ONSP=$ZU(5) zn "^^"_DIR ;save current namespace D PHYSICAL^%GLO(1) K ^%utility($j) S X=$$Fetch^%GD("*",1,0) K ^UTILITY($J) S g="" F S g=$O(^%utility($J,g)) q:g="" S ^UTILITY($J,$e(g,2,$L(g)))="" F J=1:1:$L(EX,"\") S g=$P(EX,"\",J) I $L(g) K ^UTILITY($J,g) g exit:$o(^UTILITY($j,""))="" s G="",P=1,(tbytes,tblks,tcont,DX)=0 d showless exit zn ONSP k %ST q ; showless ;inherit all variables from caller, call brief(), and display S H=$ZU(5) f s G=$o(^UTILITY($j,G)) q:G="" d . I EX[("\"_G_"\") Q . i '$p(^UTILITY("GLO",G),"^",3) q . I ($P($P($ZV,")",2),"(",1)[" 4.") s x=$$brief4("^"_G) . I ($P($P($ZV,")",2),"(",1)[" 5.") s x=$$brief5("^"_G) . s blks=+x,tblks=tblks+blks . i x'["?" S @LOG@(G,H)=blks . e S @LOG@(G,H)=$p(x,"?",2) S @LOG@(0,H)=tblks_"\"_$TR($ZD(+$H,4),"/",".")_"\"_$ZT($P($H,",",2),1) q ; brief4(G) ;brief version (quicker) n (G,%ST) s k=0 ;k:blocks o 63 d:'$d(%ST("GVEC")) ^%ST i $d(@G) s b=$v($v(%ST("GVEC"),-1,"4P")+%ST("gpnt")+%ST("indian"),-3,3) ;1st pointer block i 'b s err="?GLOBAL" g exitbrf f q:'b v b s t=$V(2043,0,1) q:t=6 s b=$v(2,-5) i 'b s err="?BOTPNT" g exitbrf f k big s lastbig=-1,big=0 q:'b v b d s k=k+i-1 . f i=1:1 s x=$v(i*2-1,-6) q:x="" s p=$v(i*2,-6) d:p\8388608#2 . . i lastbig=(i-1) s $p(big(big),",",2)=p#8388608 . . e s big=big+1,big(big)=p#8388608 . . s lastbig=i . s b=$V(2040,0,"3O") ;get next linked block before doing big blocks . s j="" f s j=$o(big(j)) q:j="" s k=k+$$bigblk4(big(j)) g exitbrf bigblk4(b) ; n (b) s beg=+$p(b,","),end=+$p(b,",",2) s:'end end=beg q:'beg 0 s b=beg,k=0 f v b q:$V(2043,0,1)'=12 d q:b=end s b=$V(2040,0,"3O") q:'b . f i=1:1 s x=$v(i*2-1,-6) q:x="" d . . s v=$v(i*2,-6) q:$a(v)'=3 . . s k=k+$a(v,2)+''($a(v,3)!$a(v,4)) q k brief5(G) ;brief version (quicker) n (bigdb,blksiz,datasize,dirinfo,G,DIR,IO) s k=0 ;k:blocks Set rc=$$GetGlobalPointers^%DM(DIR,G,.b) If ('rc) Set err="?" Goto exitbrf o 63 i 'b s err="?GLOBAL" g exitbrf f q:'b v b s t=$$GetBlockTypeFromViewBuffer^%DMREPAIR(bigdb) q:(t=6!(t=70)) s b=$v(2,-5) i 'b s err="?BOTPNT" g exitbrf f k big s lastbig=-1,big=0 q:'b v b d s k=k+i-1 . f i=1:1 s x=$v(i*2-1,-6) q:x="" s p=$v(i*2,-6) d:$Piece(p,",") . . Set p=$Piece(p,",",2) ;block number with big string . . i lastbig=(i-1) s $p(big(big),",",2)=p . . e s big=big+1,big(big)=p . . s lastbig=i . s b=$$GetLinkBlockFromViewBuffer^%DMREPAIR(bigdb) ;get next linked block before doing big blocks . s j="" f s j=$o(big(j)) q:j="" s k=k+$$bigblk5(big(j)) g exitbrf bigblk5(b) ; n (b,bigdb) s beg=+$p(b,","),end=+$p(b,",",2) s:'end end=beg q:'beg 0 s b=beg,k=0 f v b s t=$$GetBlockTypeFromViewBuffer^%DMREPAIR(bigdb) q:(t=6!(t=70)) d q:b=end s b=$$GetLinkBlockFromViewBuffer^%DMREPAIR(bigdb) q:'b . f i=1:1 s x=$v(i*2-1,-6) q:x="" d . . ;Next line covers all the long string types for both 2k and bigdb . . s v=$v(i*2,-6) If $a(v)'=5,($a(v)'=$Case(bigdb,0:9,:7)),($a(v)'=3) Quit . . s k=k+$p(v,",",2) ;+''($p(v,",",3)) q k exitbrf c 63 q k_$g(err) YN(P,D,t) N R,X S P=$G(P),D=$E($G(D)_"?"),t=$G(t) ;ask Yes/No w/ Prompt,Default S D=$S("Yy"[D:"Yes => ","Nn"[D:"No => ",1:"") ;Yes, No or no default F W !,P_"? "_D Read:t R:t Read:'t R DO I "^YN"[R Q ;timed or non-timed read . S X=R,R=$TR($E(R_D_"?"),"yn","YN") I "^YN"'[R W " enter Yes or No, please" S POP=(R="^") W $E($S(R="N":"No",R="Y":"Yes",1:""),$L(X)+1,3) Q R GetDir(p,d,exists) ;ask for a directory, allow defaults i '$D(exists) s exists=1 ; default is to check if exists n neednew s neednew=1 ;expect to new dirlist i $g(dirlist) i $g(@dirlist) s neednew=0 ; callers dirlist seems ok i neednew n dirlist d . S dirlist="mtemp1(""dir"")" ;as good a place as any... . I $G(@dirlist)<$H K @dirlist S @dirlist=$H_","_$J_","_$I N R,Z,Lock Lock +@dirlist:1 S Lock=$T DO Lock:Lock -@dirlist Q R . N N,OLD,MAX,TWO S (N,MAX)=$G(@dirlist@(0))+1,TWO=0 Get . S OLD=$G(@dirlist@(N)),$ZT="GetErr" I OLD="",N=MAX S OLD=$G(d) . W:'TWO ! I TWO W $C(13),$J("",70),$C(13) ;start on new line . W p_": "_$S(OLD]"":OLD_" => ",1:"") R R S Z=$ZB,TWO=0 S:R="" R=OLD . i $ZM'["R" I $A(Z)=27 S R="" DO G Get:R="" ;handle special function keys!! . . I Z=$C(27,91,65) DO Q ;handle ANSI up-arrow . . . S TWO=1,N=N-1 I 'N S N=$G(@dirlist@(0))+1 Q . . I Z=$C(27,91,66) DO Q ;handle ANSI down-arrow . . . S N=N+1,TWO=1 I N>MAX S N=1 . . I Z=$C(27,91,67) S R="@" Q ;handle ANSI right-arrow --> edit . . I Z=$C(27,91,68) S R="@" Q ;handle ANSI left-arrow --> edit . ; . I R="@",OLD]"" S R=$$ED(OLD) ;use good-old replace/with editor . I $E(R)="?" S Z=R Q ;pass-on request for elaboration . i $$STOP(R) Q . S Z=$S(exists:$$CDOS(R),1:$$CDVL(R)) . I Z="" W *7," could not interpret '"_R_"'",! G:exists Get d g:Z="N" Get . . s Z=$$YN("Use this directory anyway") . Q ;needed to not enter 'GetErr' GetErr . S $ZT="",D="",TWO=0,N=$G(MAX) ; clear default . I $P($ZE,">")=" "_%L Q %L CDVL(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,1) Q N CDE(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,2) Q N CDOS(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,3) Q N CD(R) N N S $ZE="",$ZT="ChkBad",N=$ZU(12,R,2) Q N ChkBad S $ZT="" W !,"<"_$P($P($ZE,"<",2),">")_"> error -- invalid directory" Q "" STOP(x) S x=$$UC($E(x,1,4)) Q (x["EXIT")!(x["STOP")!(x["QUIT")!(x["HALT")!($E(x)="^") ; ERR zn cs Q ; ZZ ; 17.01.2012 - 15:58 * Cache-r6.4.9