Skip to content

Commit 52bedd7

Browse files
m82labsMax Eshleman
authored andcommitted
Remove storage calculation for non Azure managed instances and add server version (influxdata#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.
1 parent a829e3c commit 52bedd7

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

plugins/inputs/sqlserver/sqlserver.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ const sqlServerPropertiesV2 = `DECLARE @sys_info TABLE (
401401
402402
IF OBJECT_ID('master.sys.dm_os_sys_info') IS NOT NULL
403403
BEGIN
404-
405404
IF SERVERPROPERTY('EngineEdition') = 8 -- Managed Instance
406405
INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime )
407406
SELECT TOP(1)
@@ -418,19 +417,6 @@ BEGIN
418417
419418
ELSE
420419
BEGIN
421-
DECLARE @total_disk_size_mb BIGINT,
422-
@available_space_mb BIGINT
423-
424-
SELECT @total_disk_size_mb = sum(total_disk_size_mb),
425-
@available_space_mb = sum(free_disk_space_mb)
426-
FROM (
427-
SELECT distinct logical_volume_name AS LogicalName,
428-
total_bytes/(1024*1024)as total_disk_size_mb,
429-
available_bytes /(1024*1024) free_disk_space_mb
430-
FROM sys.master_files AS f
431-
CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id)
432-
) as osVolumes
433-
434420
INSERT INTO @sys_info ( cpu_count, server_memory, sku, engine_edition, hardware_type, total_storage_mb, available_storage_mb, uptime )
435421
SELECT cpu_count,
436422
(SELECT total_physical_memory_kb FROM sys.dm_os_sys_memory) AS server_memory,
@@ -440,13 +426,12 @@ BEGIN
440426
WHEN 'NONE' THEN 'PHYSICAL Machine'
441427
ELSE virtual_machine_type_desc
442428
END AS hardware_type,
443-
@total_disk_size_mb,
444-
@available_space_mb,
429+
NULL,
430+
NULL,
445431
DATEDIFF(MINUTE,sqlserver_start_time,GETDATE())
446432
FROM sys.dm_os_sys_info
447433
END
448434
END
449-
450435
SELECT 'sqlserver_server_properties' AS [measurement],
451436
REPLACE(@@SERVERNAME,'\',':') AS [sql_instance],
452437
s.cpu_count,
@@ -457,6 +442,7 @@ SELECT 'sqlserver_server_properties' AS [measurement],
457442
s.total_storage_mb,
458443
s.available_storage_mb,
459444
s.uptime,
445+
SERVERPROPERTY('ProductVersion') AS sql_version,
460446
db_online,
461447
db_restoring,
462448
db_recovering,

0 commit comments

Comments
 (0)