cQLIC ;Check LU' usage ;cQLIC; [ 08/07/98 12:02 PM ] ; 1 B 1 W ! D ldumpall^%LICENSE ;current_database_dir\all.dmp W ! D ldumpinuse^%LICENSE ;current_database_dir\inuse.dmp W ! D ldumppid^%LICENSE ;current_database_dir\piduse.dmp W ! D dumpserver^%LICENSE ;...\mgr\dumpserver.txt W ! D dumpkeys^%LICENSE ;...\mgr\dumpkeys.txt" ; YZ Q ; all D ^%D W " " D ^%T W ! I ($P($P($ZV,")",2),"(",1)[" 2008")!($P($P($ZV,")",2),"(",1)[" 2010") D DOIT("UserListAll"),SHOW Q E D . D ldumpall^%LICENSE W !! . D NS^cQ21(.A),DB^cQ21(.B) S FILE=B(A($ZU(5),"globals"))_"all.dmp" K A,B . S T=1,S=0 D OPEN^cQFLIST allz Q ; inuse D ^%D W " " D ^%T W ! I ($P($P($ZV,")",2),"(",1)[" 2008")!($P($P($ZV,")",2),"(",1)[" 2010") D DOIT("UserList"),SHOW Q E D . D ldumpinuse^%LICENSE W !! . D NS^cQ21(.A),DB^cQ21(.B) S FILE=B(A($ZU(5),"globals"))_"inuse.dmp" K A,B . S T=1,S=0 D OPEN^cQFLIST inusez Q ; piduse D ^%D W " " D ^%T W ! D ldumppid^%LICENSE W !! D NS^cQ21(.A),DB^cQ21(.B) S FILE=B(A($ZU(5),"globals"))_"piduse.dmp" K A,B S T=1,S=0 D OPEN^cQFLIST pidusez Q ; d D ^%D W " " D ^%T W ! D dumpservers^%LICENSE W !! S FILE=$P($ZU(86),"\",1,(($P($P($ZV,")",2),"(",1)[" 2008")!($P($P($ZV,")",2),"(",1)[" 2010"))+3)_"\mgr\dumpservers.txt" S T=1,S=0 D OPEN^cQFLIST dz Q ; k D ^%D W " " D ^%T W ! D dumpkeys^%LICENSE W !! S FILE=$P($ZU(86),"\",1,(($P($P($ZV,")",2),"(",1)[" 2008")!($P($P($ZV,")",2),"(",1)[" 2010"))+3)_"\mgr\dumpkeys.txt" S T=1,S=0 D OPEN^cQFLIST kz Q ; pl W !,"Process list" D PROC ZW L plz Q ; sum ;summary D ^%D W " " D ^%T W !,"License Summary" D DOIT("Summary") sumz Q ; PROC ;Get info in L K JOB,L D JOBS^cQSYS S I="" F S I=$O(JOB(0,I)) Q:I="" S J=JOB(0,I),ID=$system.License.GetUserId(J) I $L(ID) S L(ID,$O(L(ID,""),-1)+1)=J PROCZ Q ; ALERT(debug) ;Send alert if license usage exceeds treshold N MAX,LUA,LUC,LUS,R S MAX=+$G(^cLOG($ZCVT($ZU(110),"U"),"LICENSE","ALERT")) I 'MAX S MAX=95 S LUS=$system.License.KeyLicenseUnits() S LUC=$system.License.LUConsumed() I LUC>(LUS*MAX/100) D . S R($O(R(""),-1)+1)="Current License Usage exceeds "_MAX_"% of Available LU's" . S R($O(R(""),-1)+1)=LUC_" LU's used of "_LUS_" Max. License LU's" . D M^cQ14("License Usage Problem",.R) I $G(debug) ZW R ALERTZ Q ; LU(debug) ;Send message if more than 1 LU used N %ROWCOUNT,D,I,ID,J,JOB,K,L,P,Q,Q1,R,Rset,SW,Y,data,headings,i,ncol,nrec,r,status D DOIT("UserList") S I="",SW=0 F S I=$O(data(I)) Q:I="" I $G(data(I,6))=1 K data(I) I $O(data("")) D . S R($O(R(""),-1)+1)="UserId's with more than 1 LU" . D PROC S I="" . F S I=$O(data(I)) Q:I="" D .. S J="",R($O(R(""),-1)+1)=data(I,1)_" consumes "_data(I,6)_" LU's" .. F J=1:1 Q:'$D(L(data(I,1),J)) S K=L(data(I,1),J) D ... S P=##class(%SYS.ProcessQuery).%OpenId(K,0) I P S K=K_","_P.NameSpace_","_P.State_","_P.Routine_","_P.ClientExecutableName ... S R($O(R(""),-1)+1)=$C(9)_"Job "_$J(J,2)_": "_K I $O(R("")) D M^cQ14(R(1),.R) I $G(debug) ZW R LUZ Q ; DOIT(X) ;run query S X=$G(X) I '$L(X) S X="UserList" S Y=$S(X="Summary":X,X="UserList":"In Use",1:"All")_" Licenses" S X="%SYSTEM.License."_X S Rset=##class(%Library.ResultSet).%New(X) I 'Rset S status="Could not form query "_X Q S r=Rset.Execute() I r { S ncol=Rset.GetColumnCount() F i=1:1:ncol S headings(i)=Rset.GetColumnName(i) S nrec=0 While (Rset.Next()) { S nrec=nrec+1 S ncol=Rset.GetColumnCount() F i=1:1:ncol S data(nrec,i)=Rset.GetData(i) } D Rset.Close() S status=nrec_" "_"entries added to array" } I 'r S status="Could not execute query "_X Q DOITZ Q ; SHOW ;Show results W !,Y,! W !?4,headings(1),?16 f j=2:1:ncol w $J(headings(j),9) F i=1:1:nrec W !,$J(i,3)," ",data(i,1),?16 f j=2:1:ncol w $J(data(i,j),9) SHOWZ Q ; ZZ ; 17.01.2012 - 15:58 * Cache-r6.4.9