File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ Author: Benjamin Nevarez
3+ Original link: http://sqlblog.com/blogs/ben_nevarez/archive/2009/07/26/getting-cpu-utilization-data-from-sql-server.aspx
4+ */
5+
6+
7+ DECLARE @ts_now BIGINT ;
8+
9+ SELECT @ts_now = cpu_ticks / CONVERT (FLOAT , cpu_ticks)
10+ FROM sys .dm_os_sys_info ;
11+
12+ SELECT record_id
13+ , Dateadd (ms, - 1 * ( @ts_now - [timestamp])
14+ , Getdate ()) AS EventTime
15+ , sqlprocessutilization
16+ , systemidle
17+ , 100 - systemidle - sqlprocessutilization AS OtherProcessUtilization
18+ FROM (SELECT record .value (' (./Record/@id)[1]' , ' int' ) AS record_id
19+ , record .value (' (./Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]' , ' int' ) AS SystemIdle
20+ , record .value (' (./Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]' , ' int' ) AS SQLProcessUtilization
21+ , timestamp
22+ FROM (SELECT timestamp
23+ , CONVERT (XML , record) AS record
24+ FROM sys .dm_os_ring_buffers
25+ WHERE ring_buffer_type = N ' RING_BUFFER_SCHEDULER_MONITOR'
26+ AND record LIKE ' %<SystemHealth>%' ) AS x) AS y
27+ ORDER BY record_id DESC ;
Original file line number Diff line number Diff line change @@ -46,7 +46,13 @@ Tested on SQL Server version: 2008/2012/2014/2016
4646## [ CPU Utilization Graphical form] ( CPU_Utilization_Graphical_form.sql )
4747Author: Slava Murygin<br />
4848Original link: http://slavasql.blogspot.ru/2016/03/sql-server-cpu-utilization-in-graphical.html <br />
49- Tested on SQL Server version: 2008/2012/2014/2016
49+ Tested on SQL Server version: 2012/2014
50+
51+
52+ ## [ CPU Utilization] ( CPU_Utilization.sql )
53+ Author: Benjamin Nevarez<br />
54+ Original link: http://sqlblog.com/blogs/ben_nevarez/archive/2009/07/26/getting-cpu-utilization-data-from-sql-server.aspx <br />
55+ Tested on SQL Server version: 2014
5056
5157
5258## [ Table count alternative] (Table Count alternative.sql)
You can’t perform that action at this time.
0 commit comments