標籤:ringbuffer 緩衝區 環形緩衝區 cpu
SQL Server 環形緩衝區(Ring Buffer) -- RING_BUFFER_SCHEDULER_MONITOR 擷取SQL進程的CPU利用率
環形緩衝區儲存了有關CPU利用率的資訊。這些資訊每分鐘更新一次。所以你可以跟蹤到4小時15分鐘內給定時間點的CPU利用率。下面的輸出顯示了SQL執行個體的CPU利用率和其他活動進程的CPU利用率。這將協助我們分析是否SQL Server進程佔用大量CPU。
650) this.width=650;" title="clip_image001" style="border-top:0px;border-right:0px;border-bottom:0px;border-left:0px;" alt="clip_image001" src="http://s3.51cto.com/wyfs02/M00/54/1A/wKiom1R4ES2wosplAAGfFYYma6Y106.jpg" height="226" border="0" />
對於SQL Server 2005:
declare @ts_now bigintselect @ts_now = cpu_ticks / convert(float, cpu_ticks_in_ms) from sys.dm_os_sys_infoselect record_id,dateadd(ms, -1 * (@ts_now - [timestamp]), GetDate()) as EventTime,SQLProcessUtilization,SystemIdle,100 - SystemIdle - SQLProcessUtilization as OtherProcessUtilizationfrom (selectrecord.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,timestampfrom (select timestamp, convert(xml, record) as recordfrom sys.dm_os_ring_bufferswhere ring_buffer_type = N‘RING_BUFFER_SCHEDULER_MONITOR‘and record like ‘%<SystemHealth>%‘) as x) as yorder by record_id desc
對於SQL Server 2008:
declare @ts_now bigintselect @ts_now = ms_ticks fromsys.dm_os_sys_infoselect record_id, dateadd (ms, (y.[timestamp] [email protected]_now), GETDATE()) as EventTime,SQLProcessUtilization,SystemIdle,100 - SystemIdle - SQLProcessUtilization as OtherProcessUtilizationfrom (selectrecord.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,timestampfrom (select timestamp, convert(xml, record) as recordfrom sys.dm_os_ring_bufferswhere ring_buffer_type = N‘RING_BUFFER_SCHEDULER_MONITOR‘and record like ‘%<SystemHealth>%‘) as x) as yorder by record_id desc
常用SQL指令碼:
select record ,CAST(record AS XML) ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/MemoryUtilization[1]‘,‘int‘) as MemUtil ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/PageFaults[1]‘,‘int‘) as PageFaults ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/WorkingSetDelta[1]‘,‘int‘) as workingSetDelta ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/KernelModeTime[1]‘,‘int‘) as KernelModeTime ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/UserModeTime[1]‘,‘bigint‘) as UserModeTime ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/ProcessUtilization[1]‘,‘int‘) as ProcessUtilization ,CAST(record as XML).value(‘/Record[1]/SchedulerMonitorEvent[1]/SystemHealth[1]/SystemIdle[1]‘,‘int‘) as SystemIdle from sys.dm_os_ring_buffers where ring_buffer_type = ‘RING_BUFFER_SCHEDULER_MONITOR‘
本文出自 “滴水石穿” 部落格,請務必保留此出處http://ultrasql.blog.51cto.com/9591438/1583973
SQL Server 環形緩衝區(Ring Buffer) -- RING_BUFFER_SCHEDULER_MONITOR 擷取SQL