CPU usage in percentage

  • Is there any query to know CPU utlisation of server?

  • Sure, there are plenty out there on Google, but this is the one I use, you may find a better one in the searches depending what you actually want to see

    SELECT

    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,

    EventTime

    FROM (

    SELECT

    DATEADD (ms, r.[timestamp] - s.ms_ticks, GETDATE()) AS EventTime,

    CAST(r.record AS XML) record

    FROM

    sys.dm_os_ring_buffers r

    CROSS JOIN

    sys.dm_os_sys_info s

    WHERE

    ring_buffer_type='RING_BUFFER_SCHEDULER_MONITOR'

    AND

    record LIKE '%<SystemHealth>%'

    ) AS x

    ) AS y

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

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