How to find CPU usage for SQL Server 2012

  • Hi Gurus,

    I am trying to find out CPU utilization from the history using process.%processor time. I am having dual core CPU with 2 numa nodes each having 16 logical cpus bind to it. Attaching picture for your ref. Please let me know how to calculate the CPU utilization using perfmon.

    I tried to use SQL query which gives CPU history using SQL DMV, but I am unable to get the exact value. Because in between I have used the same querry to capture my CPU usage on the run day, the value on run day and the query which iam tryting to pull out is different. I am using the same query to pull the history data with providing the date. AM I using the logic incorrectly? Please help.

    -- Get CPU Utilization History (SQL Server 2008 and above)

    DECLARE @ts BIGINT

    SELECT @ts =(SELECT cpu_ticks/(cpu_ticks/ms_ticks)

    FROM sys.dm_os_sys_info);

    SELECT SQLProcessUtilization AS [SQLServer_Process_CPU_Utilization],

    SystemIdle AS [System_Idle_Process],

    100 - SystemIdle - SQLProcessUtilization AS [Other_Process_CPU_Utilization],

    DATEADD(ms,-1 *(@ts - [timestamp]),'2015-06-03 14:39:54.820')AS [Event_Time]

    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 x

    )AS y

    ORDER BY DATEADD(ms,-1 *(@ts - [timestamp]),GETDATE()) asc --record_id DESC;

    "More Green More Oxygen !! Plant a tree today"

  • Any update?

    "More Green More Oxygen !! Plant a tree today"

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply