From e2983383e4657ede489337fc1a38cf393020feee Mon Sep 17 00:00:00 2001 From: ceseuron Date: Thu, 4 May 2017 10:47:03 -0700 Subject: [PATCH] Fixed sqlserver input to work with case sensitive server collation. (#2749) Fixed a problem with sqlserver input where database properties are not returned by Telegraf when SQL Server has been set up with a case sensitive server-level collation. * Added bugfix entry to CHANGELOG.md for sqlserver collation input fix. --- CHANGELOG.md | 2 ++ plugins/inputs/sqlserver/sqlserver.go | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f8bddb379..abfd968b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features ### Bugfixes +- [#2749](https://github.com/influxdata/telegraf/pull/2749): Fixed sqlserver input to work with case sensitive server collation. + ## v1.3 [unreleased] ### Release Notes diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index 1e7f92dff..ed3216258 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -843,7 +843,7 @@ FROM (SELECT DISTINCT DatabaseName FROM #Databases) AS bl SET @DynamicPivotQuery = N' SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -856,7 +856,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -869,7 +869,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -883,7 +883,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -896,7 +896,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -909,7 +909,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -922,7 +922,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -935,7 +935,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -948,7 +948,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement) @@ -961,7 +961,7 @@ UNION ALL SELECT measurement = Measurement, servername = REPLACE(@@SERVERNAME, ''\'', '':'') , type = ''Database properties'' -, ' + @ColumnName + ', total FROM +, ' + @ColumnName + ', Total FROM ( SELECT Measurement, DatabaseName, Value , Total = (SELECT SUM(Value) FROM #Databases WHERE Measurement = d.Measurement)