PerformanceCollector.Addin_Buffers.sql 1.21 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
IF EXISTS (select 1 from sys.objects where object_id=object_id('PerformanceCollector.Addin_Buffers') and type='P')
   DROP procedure PerformanceCollector.Addin_Buffers
GO

  
CREATE Procedure PerformanceCollector.Addin_Buffers       
As    
BEGIN        
	set nocount on             
	    
	DECLARE @Now DATETIME , @nowprev DATETIME     , @dbname varchar(200) 
	SELECT @nowprev = MAX(Currtime) from PerformanceCollector.BufferStats  
	SELECT @now = GETDATE()    
	
	DECLARE @PollingInterval int
	SELECT @PollingInterval = COALESCE(ConfigValueInt,5) 
	FROM PerformanceCollector.Config
	WHERE ConfigSetting = 'Addin_Buffers'
	
	if datediff (hh,COALESCE(@nowprev,'1/1/1980'),@now) > @PollingInterval   
	BEGIN	
		--Step 1:
		--
		--DECLARE dbs CURSOR FOR 
			--SELECT name 
			--FROM sys.databases
			--WHERE state_desc = 'ONLINE' 
		 --  AND user_access_desc = 'MULTI_USER'
		 --  AND is_in_standby = 0 
		 --  ORDER BY name
		--OPEN dbs 
		--FETCH NEXT FROM dbs INTO @dbname 
		--WHILE @@FETCH_STATUS = 0 
		--BEGIN
			SELECT @dbname = db_name()
			EXEC PerformanceCollector.GatherBufferData @dbname
		--	FETCH NEXT FROM dbs INTO @dbname 
		--END
		--CLOSE dbs
		--DEALLOCATE dbs
		
	END;   

END
GO