Dmv sys.dm_os_performance_counters

Good day.

I need to generate an alarm when the buffer cache hit ratio is below 98 over 30 minutes.

I am using the dmv sys.dm_os_performance_counters, but it does not bring the hour field.

How do I add a column that calculates each time the select runs and shows the total time between the first run and the last to arrive in 15 minutes?

thanks
Support_38Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
sys.dm_os_performance_counters returns the current performance counter names and values so you'll need to find a way to store them in a table recording the date and time of the call:
CREATE TABLE [dbo].[MyPerfTable](
	[object_name] nchar(128) NOT NULL,
	[counter_name] nchar(128) NOT NULL,
	[instance_name] nchar(128) NULL,
	[cntr_value] bigint NOT NULL,
	[cntr_type] int NOT NULL,
	[date_time] datetime DEFAULT GETDATE()
) ON [PRIMARY]
GO

INSERT INTO MyPerfTable ([object_name],[counter_name],[instance_name],[cntr_value],[cntr_type])
SELECT [object_name]
      ,[counter_name]
      ,[instance_name]
      ,[cntr_value]
      ,[cntr_type]
FROM sys.dm_os_performance_counters

SELECT *
FROM MyPerfTable

Open in new window

Vitor MontalvãoMSSQL Senior EngineerCommented:
You can then put the INSERT command in a job that runs every 15 minutes.
Be aware that the table will only grow so a purge process should be build for this.
Also set a filter to only get the desired performance counters so it will reduce the table size.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
Why grade C?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.