Find CPU from within SSMS
-
Posted on January 13, 2014 by Derek Dieter
-
2
This is a great DMV if you don’t want to leave SSMS to see the CPU usage or if you don’t have access. What’s good about this method is it also shows you the history of the cpu usage.
[cc lang=”sql”]
declare @ts_now bigint
select @ts_now = cpu_ticks / (cpu_ticks/ms_ticks) from sys.dm_os_sys_info;
select record_id,
dateadd(ms, -1 * (@ts_now – [timestamp]), GetDate()) as EventTime,
SQLProcessUtilization,
SystemIdle,
100 – SystemIdle – SQLProcessUtilization as OtherProcessUtilization
from (
select
record.value(‘(./Record/@id)[1]’, ‘int’) as record_id,
record.value(‘(./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]’, ‘int’) as SystemIdle,
record.value(‘(./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]’, ‘int’) as SQLProcessUtilization,
timestamp
from (
select timestamp, convert(xml, record) as record
from sys.dm_os_ring_buffers
where ring_buffer_type = N’RING_BUFFER_SCHEDULER_MONITOR’
and record like ‘%
) as y
order by record_id desc
[/cc]
- Comments (RSS)
- Trackback
- Permalink
Hi,
I am running this SQL on a machine with 4 NUMA nodes and 96 logical cores.
This seems to return incorrect results for SQLProcessUtilization with values > 100.
Is there any work-around for this to determine the SQLProcessUtilization accurately?
Thanks.
Dieter, it gives error at record.VALUE function.
“VALUE” is not a valid function, property, or field.
Hi Derek,
Your scripts are simple and very handy.Keep Going.
Above script is not working in SQL 2008
getting below error
Msg 227, Level 15, State 1, Line 5
“VALUE” is not a valid function, property, or field.
I am a DBA and no idea on what should I do to get this off from my page. Please help