Sql-Server

有沒有辦法自定義 SQL Server 性能儀表板?

  • September 23, 2021

SQL Server Management Studio 中的報告按一分鐘顯示系統 CPU 使用率。有沒有辦法指定間隔 - 也許是 10 秒?

在此處輸入圖像描述

不幸的是沒有。此資訊來自 sys.dm_os_ring_buffers DMV,它使用 RING_BUFFER_SCHEDULER_MONITOR 記錄類型。此資訊每分鐘生成一次,並且不可自定義。即,這不是報告的“錯誤”,而是首先缺少的資訊。

以下是此報告正在使用的查詢,由跟踪擷取:

exec sp_executesql @stmt=N'
         declare @ms_now bigint
         select @ms_now = ms_ticks from sys.dm_os_sys_info;
         select top 15 record_id,
         dateadd(ms, -1 * (@ms_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 ''%SystemHealth%'') as x
       ) as y 
   order by record_id desc',@params=N''

引用自:https://dba.stackexchange.com/questions/300062