Jump to content

PHC - Monitor de licenças consumidas


adamas

Recommended Posts

Boa tarde, 

Utilizo o PHC v30 Local e gostaria de fazer uma query de modo a obter um dashboard com as licenças consumidas, e assim saber rapidamente a informação sem ter de ir a Sistema>Status Geral> Proteção> Monitor de consulta de licenças consumidas. 

Alguém me sabe indicar qual é a tabela que devo consultar? 

Obrigada

Link to comment
Share on other sites

Bom dia,

Aqui vai,

	DECLARE @sql	NVARCHAR(MAX)
	SET @sql= N''

	IF OBJECT_ID('tempdb..#packlist') IS NOT NULL
		DROP TABLE #packlist

	CREATE TABLE #packlist
	(
		nomepack	VARCHAR(254)
		,cs_spid	INT
		,vfp_pid	BIGINT
		,phc_user	varchar(250)
		,phc_key    varchar(250)
	)

	SELECT
		@sql =  @sql +
			CASE WHEN t.nCount = 1 THEN '' ELSE ' union all ' END +	 ' select nomepack COLLATE Latin1_General_CI_AI as nomepack, cs_spid, vfp_pid, phc_user COLLATE Latin1_General_CI_AI as phc_user, phc_key COLLATE Latin1_General_CI_AI as phc_key from ' + t.nometab
	FROM
	(
		SELECT
			temp.name as nometab
			,ROW_NUMBER() OVER (ORDER BY temp.name) nCount
		FROM
			tempdb.sys.objects temp
		WHERE
			 temp.name like '##PHC26CS%' 

	) t

	INSERT #packlist
	EXEC sp_executesql  @sql
		SELECT
			pklist.nomepack COLLATE Latin1_General_CI_AI as nomepack
			,pklist.phc_user COLLATE Latin1_General_CI_AI as phc_user
			,t2.session_id
			,t2.host_process_id
			,t2.host_name COLLATE Latin1_General_CI_AI as host_name
			,t2.bd
			,t2.connect_time
			, 0 lics
			,pklist.phc_key COLLATE Latin1_General_CI_AI as phc_key
		FROM
			#packlist as pklist
			INNER JOIN
			(
				SELECT
					DISTINCT
					s.host_name COLLATE Latin1_General_CI_AI as host_name
					,s.host_process_id
					,c.client_net_address
					,c.session_id
				--	db_name(s.database_id) as bd,
					,db_name(p.dbid) as BD
					,c.connect_time
				FROM sys.dm_exec_connections AS c
					INNER JOIN
					sys.dm_exec_sessions AS s ON c.session_id = s.session_id
					INNER JOIN
					sys.sysprocesses as p ON s.session_id = p.spid
			) t2 ON t2.host_process_id = pklist.vfp_pid and t2.session_id = pklist.cs_spid
		ORDER BY nomepack

 

  • Vote 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.