From 49f537f96f14531eba63dd7436e6843b1e5ca768 Mon Sep 17 00:00:00 2001 From: Mark Wilkinson - m82labs Date: Thu, 13 Dec 2018 14:42:35 -0500 Subject: [PATCH] Remove storage calculation for non Azure managed instances and add server version (#5135) - Removed the storage calculation for SQL Server instances that are NOT Azure Managed Instances, this reduces the time it takes to get this data on an instance with a lot of databases and/or database files. - Added the SQL Server version back to the server properties query. --- plugins/inputs/sqlserver/sqlserver.go | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/plugins/inputs/sqlserver/sqlserver.go b/plugins/inputs/sqlserver/sqlserver.go index bf1fb9af74e49..d6aa231f12da8 100644 --- a/plugins/inputs/sqlserver/sqlserver.go +++ b/plugins/inputs/sqlserver/sqlserver.go @@ -401,7 +401,6 @@ const sqlServerPropertiesV2 = `DECLARE @sys_info TABLE ( IF OBJECT_ID('master.sys.dm_os_sys_info') IS NOT NULL BEGIN - IF SERVERPROPERTY('EngineEdition') = 8 -- Managed Instance INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime ) SELECT TOP(1) @@ -418,19 +417,6 @@ BEGIN ELSE BEGIN - DECLARE @total_disk_size_mb BIGINT, - @available_space_mb BIGINT - - SELECT @total_disk_size_mb = sum(total_disk_size_mb), - @available_space_mb = sum(free_disk_space_mb) - FROM ( - SELECT distinct logical_volume_name AS LogicalName, - total_bytes/(1024*1024)as total_disk_size_mb, - available_bytes /(1024*1024) free_disk_space_mb - FROM sys.master_files AS f - CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id) - ) as osVolumes - INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime ) SELECT cpu_count, (SELECT total_physical_memory_kb FROM sys.dm_os_sys_memory) AS server_memory, @@ -440,13 +426,12 @@ BEGIN WHEN 'NONE' THEN 'PHYSICAL Machine' ELSE virtual_machine_type_desc END AS hardware_type, - @total_disk_size_mb, - @available_space_mb, + NULL, + NULL, DATEDIFF(MINUTE,sqlserver_start_time,GETDATE()) FROM sys.dm_os_sys_info END END - SELECT 'sqlserver_server_properties' AS [measurement], REPLACE(@@SERVERNAME,'\',':') AS [sql_instance], s.cpu_count, @@ -457,6 +442,7 @@ SELECT 'sqlserver_server_properties' AS [measurement], s.total_storage_mb, s.available_storage_mb, s.uptime, + SERVERPROPERTY('ProductVersion') AS sql_version, db_online, db_restoring, db_recovering,