Skip to content

SQLServer: SQLServerCpu - sqlserver_process_cpu calculation may retrieve wrong value when hyperthreading exists #8548

@ClaudioESSilva

Description

@ClaudioESSilva

Relevant telegraf.conf:

database_type = "SQLServer"

System info:

SQL Server 2016 running on Windows Server 2016
Telegraf v1.13.3

Steps to reproduce:

Collect SQL Server CPU metrics on a system with hyperthreading (and lots of cores)

The case I saw

From sys.dm_os_sys_info
cpu_count -> 80
hyperthread_ratio -> 20

  1. Collect CPU metrics
  2. Output example (notice the negative value of blue line):

image

When running the Telegraf SQL query:
image

Expected behavior:

Sum of all 3 CPU metrics should be equal to 100%

Actual behavior:

The calculation of sqlserver_process_cpu is incorrect.
The sum of sqlserver_process_cpu and system_idle_cpu gives more than 100% and thus the other_process_cpu gives negative value.

Additional info:

This problem is on the following T-SQL queries
sqlCPUHistory
sqlServerCpuV2
sqlServerRingBufferCpu

I have a fix for this, will open a PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions