From f232dcbfca3c42ce021f3273b8ea1cb9cb06793d Mon Sep 17 00:00:00 2001 From: Giovanni Luisotto Date: Fri, 21 Feb 2020 20:11:50 +0100 Subject: [PATCH] Fix perf counters collection on named instances in sqlserver input (#7060) --- plugins/inputs/sqlserver/sqlserver.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index 511bb5b49a82e..d09a9743d0642 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -632,7 +632,7 @@ WHERE ( object_name LIKE '%User Settable%' OR object_name LIKE '%SQL Errors%' ) OR ( - object_name LIKE 'SQLServer:Batch Resp Statistics%' + object_name LIKE '%Batch Resp Statistics%' ) OR ( instance_name IN ('_Total') AND counter_name IN ( @@ -2302,7 +2302,7 @@ SELECT DISTINCT RTrim(spi.object_name) object_name , spi.cntr_value , spi.cntr_type FROM sys.dm_os_performance_counters spi -WHERE spi.object_name NOT LIKE 'SQLServer:Backup Device%' +WHERE spi.object_name NOT LIKE '%Backup Device%' AND NOT EXISTS (SELECT 1 FROM sys.databases WHERE Name = spi.instance_name); WAITFOR DELAY '00:00:01'; @@ -2324,7 +2324,7 @@ SELECT DISTINCT RTrim(spi.object_name) object_name , spi.cntr_value , spi.cntr_type FROM sys.dm_os_performance_counters spi -WHERE spi.object_name NOT LIKE 'SQLServer:Backup Device%' +WHERE spi.object_name NOT LIKE '%Backup Device%' AND NOT EXISTS (SELECT 1 FROM sys.databases WHERE Name = spi.instance_name); SELECT @@ -2360,7 +2360,7 @@ INNER JOIN #PCounters pc On cc.object_name = pc.object_name And cc.cntr_type = pc.cntr_type LEFT JOIN #CCounters cbc On cc.object_name = cbc.object_name And (Case When cc.counter_name Like '%(ms)' Then Replace(cc.counter_name, ' (ms)',' Base') - When cc.object_name = 'SQLServer:FileTable' Then Replace(cc.counter_name, 'Avg ','') + ' base' + When cc.object_name like '%FileTable' Then Replace(cc.counter_name, 'Avg ','') + ' base' When cc.counter_name = 'Worktables From Cache Ratio' Then 'Worktables From Cache Base' When cc.counter_name = 'Avg. Length of Batched Writes' Then 'Avg. Length of Batched Writes BS' Else cc.counter_name + ' base' @@ -2371,7 +2371,7 @@ LEFT JOIN #CCounters cbc On cc.object_name = cbc.object_name LEFT JOIN #PCounters pbc On pc.object_name = pbc.object_name And pc.instance_name = pbc.instance_name And (Case When pc.counter_name Like '%(ms)' Then Replace(pc.counter_name, ' (ms)',' Base') - When pc.object_name = 'SQLServer:FileTable' Then Replace(pc.counter_name, 'Avg ','') + ' base' + When pc.object_name like '%FileTable' Then Replace(pc.counter_name, 'Avg ','') + ' base' When pc.counter_name = 'Worktables From Cache Ratio' Then 'Worktables From Cache Base' When pc.counter_name = 'Avg. Length of Batched Writes' Then 'Avg. Length of Batched Writes BS' Else pc.counter_name + ' base'