SQL Server - PerformanceCounters - removed synthetic counters (#8325)
This commit is contained in:
parent
f14a50b511
commit
1313f2314f
|
|
@ -293,8 +293,6 @@ END
|
||||||
DECLARE
|
DECLARE
|
||||||
@SqlStatement AS nvarchar(max)
|
@SqlStatement AS nvarchar(max)
|
||||||
,@MajorMinorVersion AS int = CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),4) AS int)*100 + CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),3) AS int)
|
,@MajorMinorVersion AS int = CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),4) AS int)*100 + CAST(PARSENAME(CAST(SERVERPROPERTY('ProductVersion') AS nvarchar),3) AS int)
|
||||||
,@Columns AS nvarchar(MAX) = ''
|
|
||||||
,@PivotColumns AS nvarchar(MAX) = ''
|
|
||||||
|
|
||||||
DECLARE @PCounters TABLE
|
DECLARE @PCounters TABLE
|
||||||
(
|
(
|
||||||
|
|
@ -306,7 +304,7 @@ DECLARE @PCounters TABLE
|
||||||
PRIMARY KEY([object_name], [counter_name], [instance_name])
|
PRIMARY KEY([object_name], [counter_name], [instance_name])
|
||||||
);
|
);
|
||||||
|
|
||||||
SET @SqlStatement = N'
|
WITH PerfCounters AS (
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
RTRIM(spi.[object_name]) [object_name]
|
RTRIM(spi.[object_name]) [object_name]
|
||||||
,RTRIM(spi.[counter_name]) [counter_name]
|
,RTRIM(spi.[counter_name]) [counter_name]
|
||||||
|
|
@ -316,138 +314,103 @@ SELECT DISTINCT
|
||||||
FROM sys.dm_os_performance_counters AS spi
|
FROM sys.dm_os_performance_counters AS spi
|
||||||
WHERE
|
WHERE
|
||||||
counter_name IN (
|
counter_name IN (
|
||||||
''SQL Compilations/sec''
|
'SQL Compilations/sec'
|
||||||
,''SQL Re-Compilations/sec''
|
,'SQL Re-Compilations/sec'
|
||||||
,''User Connections''
|
,'User Connections'
|
||||||
,''Batch Requests/sec''
|
,'Batch Requests/sec'
|
||||||
,''Logouts/sec''
|
,'Logouts/sec'
|
||||||
,''Logins/sec''
|
,'Logins/sec'
|
||||||
,''Processes blocked''
|
,'Processes blocked'
|
||||||
,''Latch Waits/sec''
|
,'Latch Waits/sec'
|
||||||
,''Full Scans/sec''
|
,'Full Scans/sec'
|
||||||
,''Index Searches/sec''
|
,'Index Searches/sec'
|
||||||
,''Page Splits/sec''
|
,'Page Splits/sec'
|
||||||
,''Page lookups/sec''
|
,'Page lookups/sec'
|
||||||
,''Page reads/sec''
|
,'Page reads/sec'
|
||||||
,''Page writes/sec''
|
,'Page writes/sec'
|
||||||
,''Readahead pages/sec''
|
,'Readahead pages/sec'
|
||||||
,''Lazy writes/sec''
|
,'Lazy writes/sec'
|
||||||
,''Checkpoint pages/sec''
|
,'Checkpoint pages/sec'
|
||||||
,''Page life expectancy''
|
,'Page life expectancy'
|
||||||
,''Log File(s) Size (KB)''
|
,'Log File(s) Size (KB)'
|
||||||
,''Log File(s) Used Size (KB)''
|
,'Log File(s) Used Size (KB)'
|
||||||
,''Data File(s) Size (KB)''
|
,'Data File(s) Size (KB)'
|
||||||
,''Transactions/sec''
|
,'Transactions/sec'
|
||||||
,''Write Transactions/sec''
|
,'Write Transactions/sec'
|
||||||
,''Active Temp Tables''
|
,'Active Temp Tables'
|
||||||
,''Temp Tables Creation Rate''
|
,'Temp Tables Creation Rate'
|
||||||
,''Temp Tables For Destruction''
|
,'Temp Tables For Destruction'
|
||||||
,''Free Space in tempdb (KB)''
|
,'Free Space in tempdb (KB)'
|
||||||
,''Version Store Size (KB)''
|
,'Version Store Size (KB)'
|
||||||
,''Memory Grants Pending''
|
,'Memory Grants Pending'
|
||||||
,''Memory Grants Outstanding''
|
,'Memory Grants Outstanding'
|
||||||
,''Free list stalls/sec''
|
,'Free list stalls/sec'
|
||||||
,''Buffer cache hit ratio''
|
,'Buffer cache hit ratio'
|
||||||
,''Buffer cache hit ratio base''
|
,'Buffer cache hit ratio base'
|
||||||
,''Backup/Restore Throughput/sec''
|
,'Backup/Restore Throughput/sec'
|
||||||
,''Total Server Memory (KB)''
|
,'Total Server Memory (KB)'
|
||||||
,''Target Server Memory (KB)''
|
,'Target Server Memory (KB)'
|
||||||
,''Log Flushes/sec''
|
,'Log Flushes/sec'
|
||||||
,''Log Flush Wait Time''
|
,'Log Flush Wait Time'
|
||||||
,''Memory broker clerk size''
|
,'Memory broker clerk size'
|
||||||
,''Log Bytes Flushed/sec''
|
,'Log Bytes Flushed/sec'
|
||||||
,''Bytes Sent to Replica/sec''
|
,'Bytes Sent to Replica/sec'
|
||||||
,''Log Send Queue''
|
,'Log Send Queue'
|
||||||
,''Bytes Sent to Transport/sec''
|
,'Bytes Sent to Transport/sec'
|
||||||
,''Sends to Replica/sec''
|
,'Sends to Replica/sec'
|
||||||
,''Bytes Sent to Transport/sec''
|
,'Bytes Sent to Transport/sec'
|
||||||
,''Sends to Transport/sec''
|
,'Sends to Transport/sec'
|
||||||
,''Bytes Received from Replica/sec''
|
,'Bytes Received from Replica/sec'
|
||||||
,''Receives from Replica/sec''
|
,'Receives from Replica/sec'
|
||||||
,''Flow Control Time (ms/sec)''
|
,'Flow Control Time (ms/sec)'
|
||||||
,''Flow Control/sec''
|
,'Flow Control/sec'
|
||||||
,''Resent Messages/sec''
|
,'Resent Messages/sec'
|
||||||
,''Redone Bytes/sec''
|
,'Redone Bytes/sec'
|
||||||
,''XTP Memory Used (KB)''
|
,'XTP Memory Used (KB)'
|
||||||
,''Transaction Delay''
|
,'Transaction Delay'
|
||||||
,''Log Bytes Received/sec''
|
,'Log Bytes Received/sec'
|
||||||
,''Log Apply Pending Queue''
|
,'Log Apply Pending Queue'
|
||||||
,''Redone Bytes/sec''
|
,'Redone Bytes/sec'
|
||||||
,''Recovery Queue''
|
,'Recovery Queue'
|
||||||
,''Log Apply Ready Queue''
|
,'Log Apply Ready Queue'
|
||||||
,''CPU usage %''
|
,'CPU usage %'
|
||||||
,''CPU usage % base''
|
,'CPU usage % base'
|
||||||
,''Queued requests''
|
,'Queued requests'
|
||||||
,''Requests completed/sec''
|
,'Requests completed/sec'
|
||||||
,''Blocked tasks''
|
,'Blocked tasks'
|
||||||
,''Active memory grant amount (KB)''
|
,'Active memory grant amount (KB)'
|
||||||
,''Disk Read Bytes/sec''
|
,'Disk Read Bytes/sec'
|
||||||
,''Disk Read IO Throttled/sec''
|
,'Disk Read IO Throttled/sec'
|
||||||
,''Disk Read IO/sec''
|
,'Disk Read IO/sec'
|
||||||
,''Disk Write Bytes/sec''
|
,'Disk Write Bytes/sec'
|
||||||
,''Disk Write IO Throttled/sec''
|
,'Disk Write IO Throttled/sec'
|
||||||
,''Disk Write IO/sec''
|
,'Disk Write IO/sec'
|
||||||
,''Used memory (KB)''
|
,'Used memory (KB)'
|
||||||
,''Forwarded Records/sec''
|
,'Forwarded Records/sec'
|
||||||
,''Background Writer pages/sec''
|
,'Background Writer pages/sec'
|
||||||
,''Percent Log Used''
|
,'Percent Log Used'
|
||||||
,''Log Send Queue KB''
|
,'Log Send Queue KB'
|
||||||
,''Redo Queue KB''
|
,'Redo Queue KB'
|
||||||
,''Mirrored Write Transactions/sec''
|
,'Mirrored Write Transactions/sec'
|
||||||
,''Group Commit Time''
|
,'Group Commit Time'
|
||||||
,''Group Commits/Sec''
|
,'Group Commits/Sec'
|
||||||
) OR (
|
) OR (
|
||||||
spi.[object_name] LIKE ''%User Settable%''
|
spi.[object_name] LIKE '%User Settable%'
|
||||||
OR spi.[object_name] LIKE ''%SQL Errors%''
|
OR spi.[object_name] LIKE '%SQL Errors%'
|
||||||
OR spi.[object_name] LIKE ''%Batch Resp Statistics%''
|
OR spi.[object_name] LIKE '%Batch Resp Statistics%'
|
||||||
) OR (
|
) OR (
|
||||||
spi.[instance_name] IN (''_Total'')
|
spi.[instance_name] IN ('_Total')
|
||||||
AND spi.[counter_name] IN (
|
AND spi.[counter_name] IN (
|
||||||
''Lock Timeouts/sec''
|
'Lock Timeouts/sec'
|
||||||
,''Lock Timeouts (timeout > 0)/sec''
|
,'Lock Timeouts (timeout > 0)/sec'
|
||||||
,''Number of Deadlocks/sec''
|
,'Number of Deadlocks/sec'
|
||||||
,''Lock Waits/sec''
|
,'Lock Waits/sec'
|
||||||
,''Latch Waits/sec''
|
,'Latch Waits/sec'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
'
|
)
|
||||||
|
|
||||||
INSERT INTO @PCounters EXEC(@SqlStatement)
|
INSERT INTO @PCounters SELECT * FROM PerfCounters;
|
||||||
|
|
||||||
IF @MajorMinorVersion >= 1300 BEGIN
|
|
||||||
SET @Columns += N'
|
|
||||||
,rgwg.[total_cpu_usage_preemptive_ms] AS [Preemptive CPU Usage (time)]'
|
|
||||||
SET @PivotColumns += N',[Preemptive CPU Usage (time)]'
|
|
||||||
END
|
|
||||||
|
|
||||||
SET @SqlStatement = N'
|
|
||||||
SELECT
|
|
||||||
''SQLServer:Workload Group Stats'' AS [object]
|
|
||||||
,[counter]
|
|
||||||
,[instance]
|
|
||||||
,CAST(vs.[value] AS bigint) AS [value]
|
|
||||||
,1
|
|
||||||
FROM
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
rgwg.[name] AS [instance]
|
|
||||||
,rgwg.[total_request_count] AS [Request Count]
|
|
||||||
,rgwg.[total_queued_request_count] AS [Queued Request Count]
|
|
||||||
,rgwg.[total_cpu_limit_violation_count] AS [CPU Limit Violation Count]
|
|
||||||
,rgwg.[total_cpu_usage_ms] AS [CPU Usage (time)]
|
|
||||||
,rgwg.[total_lock_wait_count] AS [Lock Wait Count]
|
|
||||||
,rgwg.[total_lock_wait_time_ms] AS [Lock Wait Time]
|
|
||||||
,rgwg.[total_reduced_memgrant_count] AS [Reduced Memory Grant Count]'
|
|
||||||
+ @Columns + N'
|
|
||||||
FROM sys.dm_resource_governor_workload_groups AS rgwg
|
|
||||||
INNER JOIN sys.dm_resource_governor_resource_pools AS rgrp /*No fields from this table. remove?*/
|
|
||||||
ON rgwg.[pool_id] = rgrp.[pool_id]
|
|
||||||
) AS rg
|
|
||||||
UNPIVOT (
|
|
||||||
[value] FOR [counter] IN ( [Request Count], [Queued Request Count], [CPU Limit Violation Count], [CPU Usage (time)], [Lock Wait Count], [Lock Wait Time], [Reduced Memory Grant Count] ' + @PivotColumns + N')
|
|
||||||
) AS vs'
|
|
||||||
|
|
||||||
INSERT INTO @PCounters EXEC(@SqlStatement)
|
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
'sqlserver_performance' AS [measurement]
|
'sqlserver_performance' AS [measurement]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue