SQL Server - sqlServerRingBufferCPU - removed whitespaces (#9130)

### Required for all PRs:

- [ ] Updated associated README.md.
- [ ] Wrote appropriate unit tests.

Removed a pair of whitespace chars from the **sqlServerRingBufferCPU** SQL statement and added some formatting.
This query exists only for the on-prem version of SQL Server (`database_type = "SQLServer"`)

If you were unlucky enough to have some SQL 2008 the query wouldn't work as the whitespace char is not allowed inside the statement.
This commit is contained in:
Giovanni Luisotto 2021-05-11 23:08:25 +02:00 committed by GitHub
parent b56ffdc498
commit 8b9883e2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 13 deletions

View File

@ -1141,7 +1141,7 @@ END;
WITH utilization_cte AS WITH utilization_cte AS
( (
SELECT SELECT
[SQLProcessUtilization] AS [sqlserver_process_cpu] [SQLProcessUtilization] AS [sqlserver_process_cpu]
,[SystemIdle] AS [system_idle_cpu] ,[SystemIdle] AS [system_idle_cpu]
,100 - [SystemIdle] - [SQLProcessUtilization] AS [other_process_cpu] ,100 - [SystemIdle] - [SQLProcessUtilization] AS [other_process_cpu]
FROM ( FROM (
@ -1170,8 +1170,8 @@ WITH utilization_cte AS
), ),
processor_Info_cte AS processor_Info_cte AS
( (
SELECT (cpu_count / hyperthread_ratio) as number_of_physical_cpus SELECT ([cpu_count] / [hyperthread_ratio]) as [number_of_physical_cpus]
 FROM sys.dm_os_sys_info FROM sys.dm_os_sys_info
) )
SELECT SELECT
'sqlserver_cpu' AS [measurement] 'sqlserver_cpu' AS [measurement]
@ -1179,16 +1179,15 @@ SELECT
,[sqlserver_process_cpu] ,[sqlserver_process_cpu]
,[system_idle_cpu] ,[system_idle_cpu]
,100 - [system_idle_cpu] - [sqlserver_process_cpu] AS [other_process_cpu] ,100 - [system_idle_cpu] - [sqlserver_process_cpu] AS [other_process_cpu]
FROM FROM (
( SELECT
SELECT (CASE
(case WHEN u.[other_process_cpu] < 0 THEN u.[sqlserver_process_cpu] / p.[number_of_physical_cpus]
when [other_process_cpu] < 0 then [sqlserver_process_cpu] / a.number_of_physical_cpus ELSE u.[sqlserver_process_cpu]
else [sqlserver_process_cpu] END) AS [sqlserver_process_cpu]
 end) as [sqlserver_process_cpu] ,u.[system_idle_cpu]
,[system_idle_cpu] FROM utilization_cte AS u
FROM utilization_cte CROSS APPLY processor_Info_cte AS p
CROSS APPLY processor_Info_cte a
) AS b ) AS b
` `