I am writing a powershell script to figure out the CPU Utilization each stored procedure or SQL Query is taking. For that purpose I'm figuring out the SQL Server threads whose CPU Percent is greater than threshold (80%) and then finding those queries.
What I figured out that some of the SQL Utilization for Queries are beyond 100%. I know that this is because of multi cores and multi threading nature of the system, but I want this value to be exact, i.e., below 100% and show the actual value it is using for all the cores.
This is what I'm using
$ComputerName = $env:COMPUTERNAME
$PerfCounter = "Thread(sqlservr*)\% Processor Time"
$MaxSamples = 5
$ThreadData = Get-Counter -Counter $PerfCounter -ComputerName $ComputerName -MaxSamples $MaxSamples -ErrorAction SilentlyContinue
Can anyone help me out in getting this value to be absolute - that is below 100%
question from:
https://stackoverflow.com/questions/65880903/threadsqlservr-processer-time-exceeds-100 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…