Get SYSMON counters using a TSQL query aka DMVs.

Published 31 May 07 08:26 AM | SQL Master 

SYSMON aka PERFMON is a best tool to find out the system resources usage on a Windows server, similarly SQL Server 2005 has list of such useful DMVs to get you more information on many of the SQL Server-related objects, instances and counters by using the dm_os_performance_counters View.

The results listed using this DMV will get you object, instance and counter name, along with the value of the counter. The results are nothing a quick snapshot of resource usage on your server, in order to use this with a TSQL:

SELECT object_name
, counter_name
, instance_name
, cntr_value 
FROM sys.dm_os_performance_counters 
WHERE counter_name 
 IN(’Buffer cache hit ratio’,
 ’User Connections’ , ’Transactions’,
 ’Average Wait Time (ms)’, ’Transactions/sec’,
 ’Errors/sec’, ’Target Server Memory (KB)’,
 ’Total Server Memory (KB)’,'Pages/Sec')
ORDER BY  counter_name
GO

To get a benchmarking of resource usage it is advisable to run this query during busy times and less busy times on the server. The default interval in capturing the snapshot is15 seconds.

Firstly to understand what counters are listed using such DMV you can run:

SELECT * FROM sys.dm_os_performance_counters

This way it is easy to get a list of all counters are required or you are interested as a history of the activity on server system. There are many more objects and counters available in this DMV, depending on what you're looking for, you can tailor the first query above.

 

 

Comments

# SSQA - SqlServer-QA.net said on May 31, 2007 12:39 PM:

SYSMON aka PERFMON is a best tool to find out the system resources usage on a Windows server, similarly

Anonymous comments are disabled

About SQL Master

**__________________________________** SQL Server MVP, Sr. DBA & industry expert. - Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it. It is also a power and you will gain by sharing it.