Sys.dm_os_ring_buffers内幕
发表于:2025-01-22 作者:千家信息网编辑
千家信息网最后更新 2025年01月22日,Sys.dm_os_ring_buffers内幕翻译自:https://mssqlwiki.com/2013/03/29/inside-sys-dm_os_ring_buffers/Sys.dm_os
千家信息网最后更新 2025年01月22日Sys.dm_os_ring_buffers内幕
Sys.dm_os_ring_buffers内幕
翻译自:https://mssqlwiki.com/2013/03/29/inside-sys-dm_os_ring_buffers/
Sys.dm_os_ring_buffers DMV可以用于连接错误故障排除,跟踪异常,监控系统健康,内存压力,Non-yielding/Deadlocked schedulers和更多。
你可以使用以下脚本在故障排除期间从sys.dm_os_ring_buffers查询数据。
USE mastergoSET NOCOUNT ONSET QUOTED_IDENTIFIER ONGOPRINT 'Start Time: ' + CONVERT(varchar(30), GETDATE(), 121)GOPRINT ''PRINT '==== SELECT GETDATE()'SELECT GETDATE()PRINT ''PRINT ''PRINT '==== SELECT @@version'SELECT @@VERSIONGOPRINT ''PRINT '==== SQL Server name'SELECT @@SERVERNAMEGOPRINT ''PRINT ''PRINT '==== RING_BUFFER_CONNECTIVITY -LOGIN TIMERS' SELECT a.* FROM(SELECTx.value('(//Record/ConnectivityTraceRecord/RecordType)[1]', 'varchar(30)') AS [RecordType], x.value('(//Record/ConnectivityTraceRecord/RecordSource)[1]', 'varchar(30)') AS [RecordSource], x.value('(//Record/ConnectivityTraceRecord/Spid)[1]', 'int') AS [Spid], x.value('(//Record/ConnectivityTraceRecord/OSError)[1]', 'int') AS [OSError], x.value('(//Record/ConnectivityTraceRecord/SniConsumerError)[1]', 'int') AS[SniConsumerError], x.value('(//Record/ConnectivityTraceRecord/State)[1]', 'int') AS [State], x.value('(//Record/ConnectivityTraceRecord/RecordTime)[1]', 'nvarchar(30)') AS [RecordTime],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsInputBufferError)[1]', 'int') AS[TdsInputBufferError],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsOutputBufferError)[1]', 'int') AS[TdsOutputBufferError],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsInputBufferBytes)[1]', 'int') AS[TdsInputBufferBytes],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/TotalLoginTimeInMilliseconds)[1]', 'int') AS[TotalLoginTimeInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/LoginTaskEnqueuedInMilliseconds)[1]', 'int') AS[LoginTaskEnqueuedInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/NetworkWritesInMilliseconds)[1]', 'int') AS[NetworkWritesInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/NetworkReadsInMilliseconds)[1]', 'int') AS[NetworkReadsInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/SslProcessingInMilliseconds)[1]', 'int') AS[SslProcessingInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/SspiProcessingInMilliseconds)[1]', 'int') AS[SspiProcessingInMilliseconds],x.value('(//Record/ConnectivityTraceRecord/LoginTimers/LoginTriggerAndResourceGovernorProcessingInMilliseconds)[1]', 'int') AS[LoginTriggerAndResourceGovernorProcessingInMilliseconds]FROM (SELECT CAST(record as xml) FROM sys.dm_os_ring_buffers WHERE ring_buffer_type = 'RING_BUFFER_CONNECTIVITY')AS R(x)) awhere a.RecordType = 'LoginTimers'order by a.recordtime PRINT ''PRINT ''PRINT '==== RING_BUFFER_CONNECTIVITY -TDS Data' SELECT a.* FROM(SELECTx.value('(//Record/ConnectivityTraceRecord/RecordType)[1]', 'varchar(30)') AS [RecordType], x.value('(//Record/ConnectivityTraceRecord/RecordSource)[1]', 'varchar(30)') AS [RecordSource], x.value('(//Record/ConnectivityTraceRecord/Spid)[1]', 'int') AS [Spid], x.value('(//Record/ConnectivityTraceRecord/OSError)[1]', 'int') AS [OSError], x.value('(//Record/ConnectivityTraceRecord/SniConsumerError)[1]', 'int') AS[SniConsumerError], x.value('(//Record/ConnectivityTraceRecord/State)[1]', 'int') AS [State], x.value('(//Record/ConnectivityTraceRecord/RecordTime)[1]', 'nvarchar(30)') AS [RecordTime],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsInputBufferError)[1]', 'int') AS[TdsInputBufferError],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsOutputBufferError)[1]', 'int') AS[TdsOutputBufferError],x.value('(//Record/ConnectivityTraceRecord/TdsBuffersInformation/TdsInputBufferBytes)[1]', 'int') AS[TdsInputBufferBytes],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/PhysicalConnectionIsKilled)[1]', 'int') AS[PhysicalConnectionIsKilled],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/DisconnectDueToReadError)[1]', 'int') AS[DisconnectDueToReadError],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/NetworkErrorFoundInInputStream)[1]', 'int') AS[NetworkErrorFoundInInputStream],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/ErrorFoundBeforeLogin)[1]', 'int') AS [ErrorFoundBeforeLogin],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/SessionIsKilled)[1]', 'int') AS[SessionIsKilled],x.value('(//Record/ConnectivityTraceRecord/TdsDisconnectFlags/NormalDisconnect)[1]', 'int') AS[NormalDisconnect]FROM (SELECT CAST(record as xml) FROM sys.dm_os_ring_buffers WHERE ring_buffer_type = 'RING_BUFFER_CONNECTIVITY')AS R(x)) awhere a.RecordType = 'Error'order by a.recordtime PRINT ''PRINT ''PRINT '====RING_BUFFER_SECURITY_EORROR' SELECT CONVERT(varchar(30), GETDATE(), 121) as [RunTime],dateadd(ms, rbf.[timestamp] - tme.ms_ticks, GETDATE()) as[Notification_Time],cast(record as xml).value('(//SPID)[1]', 'bigint') as SPID,cast(record as xml).value('(//ErrorCode)[1]', 'varchar(255)') as Error_Code,cast(record as xml).value('(//CallingAPIName)[1]', 'varchar(255)') as [CallingAPIName],cast(record as xml).value('(//APIName)[1]', 'varchar(255)') as [APIName],cast(record as xml).value('(//Record/@id)[1]', 'bigint') AS [Record Id],cast(record as xml).value('(//Record/@type)[1]', 'varchar(30)') AS [Type],cast(record as xml).value('(//Record/@time)[1]', 'bigint') AS [Record Time],tme.ms_ticks as [Current Time]from sys.dm_os_ring_buffersrbfcross join sys.dm_os_sys_info tmewhere rbf.ring_buffer_type = 'RING_BUFFER_SECURITY_ERROR'ORDER BY rbf.timestamp ASC PRINT ''PRINT ''PRINT '==== RING_BUFFER_EXCEPTION' SELECT CONVERT(varchar(30), GETDATE(), 121) as [RunTime],dateadd(ms,(rbf.[timestamp] - tme.ms_ticks), GETDATE()) as Time_Stamp,cast(record as xml).value('(//Exception//Error)[1]', 'varchar(255)') as [Error],cast(record as xml).value('(//Exception/Severity)[1]', 'varchar(255)') as [Severity],cast(record as xml).value('(//Exception/State)[1]', 'varchar(255)') as [State],msg.description,cast(record as xml).value('(//Exception/UserDefined)[1]', 'int') AS[isUserDefinedError],cast(record as xml).value('(//Record/@id)[1]', 'bigint') AS [Record Id],cast(record as xml).value('(//Record/@type)[1]', 'varchar(30)') AS [Type], cast(record as xml).value('(//Record/@time)[1]', 'bigint') AS [Record Time],tme.ms_ticks as [Current Time]from sys.dm_os_ring_buffersrbfcross join sys.dm_os_sys_info tmecross join sys.sysmessages msgwhere rbf.ring_buffer_type = 'RING_BUFFER_EXCEPTION'and msg.error = cast(record as xml).value('(//Exception//Error)[1]', 'varchar(500)') and msg.msglangid = 1033 ORDER BY rbf.timestamp ASC PRINT ''PRINT ''PRINT '====RING_BUFFER_RESOURCE_MONITOR to capture external and internal memory pressure' SELECT CONVERT(varchar(30), GETDATE(), 121) as [RunTime], dateadd(ms,(rbf.[timestamp] - tme.ms_ticks), GETDATE()) as[Notification_Time], cast(record as xml).value('(//Record/ResourceMonitor/Notification)[1]', 'varchar(30)') AS[Notification_type], cast(record as xml).value('(//Record/MemoryRecord/MemoryUtilization)[1]', 'bigint') AS[MemoryUtilization %], cast(record as xml).value('(//Record/MemoryNode/@id)[1]', 'bigint') AS [Node Id], cast(record as xml).value('(//Record/ResourceMonitor/IndicatorsProcess)[1]', 'int') AS[Process_Indicator], cast(record as xml).value('(//Record/ResourceMonitor/IndicatorsSystem)[1]', 'int') AS[System_Indicator], cast(record as xml).value('(//Record/ResourceMonitor/Effect/@type)[1]', 'varchar(30)') AS [type], cast(record as xml).value('(//Record/ResourceMonitor/Effect/@state)[1]', 'varchar(30)') AS [state], cast(record as xml).value('(//Record/ResourceMonitor/Effect/@reversed)[1]', 'int') AS [reserved], cast(record as xml).value('(//Record/ResourceMonitor/Effect)[1]', 'bigint') AS [Effect], cast(record as xml).value('(//Record/ResourceMonitor/Effect[2]/@type)[1]', 'varchar(30)') AS [type], cast(record as xml).value('(//Record/ResourceMonitor/Effect[2]/@state)[1]', 'varchar(30)') AS [state], cast(record as xml).value('(//Record/ResourceMonitor/Effect[2]/@reversed)[1]', 'int') AS [reserved], cast(record as xml).value('(//Record/ResourceMonitor/Effect)[2]', 'bigint') AS [Effect], cast(record as xml).value('(//Record/ResourceMonitor/Effect[3]/@type)[1]', 'varchar(30)') AS [type], cast(record as xml).value('(//Record/ResourceMonitor/Effect[3]/@state)[1]', 'varchar(30)') AS [state], cast(record as xml).value('(//Record/ResourceMonitor/Effect[3]/@reversed)[1]', 'int') AS [reserved], cast(record as xml).value('(//Record/ResourceMonitor/Effect)[3]', 'bigint') AS [Effect], cast(record as xml).value('(//Record/MemoryNode/ReservedMemory)[1]', 'bigint') AS[SQL_ReservedMemory_KB], cast(record as xml).value('(//Record/MemoryNode/CommittedMemory)[1]', 'bigint') AS[SQL_CommittedMemory_KB], cast(record as xml).value('(//Record/MemoryNode/AWEMemory)[1]', 'bigint') AS [SQL_AWEMemory], cast(record as xml).value('(//Record/MemoryNode/SinglePagesMemory)[1]', 'bigint') AS[SinglePagesMemory], cast(record as xml).value('(//Record/MemoryNode/MultiplePagesMemory)[1]', 'bigint') AS[MultiplePagesMemory], cast(record as xml).value('(//Record/MemoryRecord/TotalPhysicalMemory)[1]', 'bigint') AS[TotalPhysicalMemory_KB], cast(record as xml).value('(//Record/MemoryRecord/AvailablePhysicalMemory)[1]', 'bigint') AS[AvailablePhysicalMemory_KB], cast(record as xml).value('(//Record/MemoryRecord/TotalPageFile)[1]', 'bigint') AS[TotalPageFile_KB], cast(record as xml).value('(//Record/MemoryRecord/AvailablePageFile)[1]', 'bigint') AS[AvailablePageFile_KB], cast(record as xml).value('(//Record/MemoryRecord/TotalVirtualAddressSpace)[1]', 'bigint') AS[TotalVirtualAddressSpace_KB], cast(record as xml).value('(//Record/MemoryRecord/AvailableVirtualAddressSpace)[1]', 'bigint') AS[AvailableVirtualAddressSpace_KB], cast(record as xml).value('(//Record/@id)[1]', 'bigint') AS [Record Id], cast(record as xml).value('(//Record/@type)[1]', 'varchar(30)') AS [Type], cast(record as xml).value('(//Record/@time)[1]', 'bigint') AS [Record Time], tme.ms_ticks as [Current Time] FROM sys.dm_os_ring_buffersrbf cross join sys.dm_os_sys_info tme where rbf.ring_buffer_type = 'RING_BUFFER_RESOURCE_MONITOR'--and cast(record asxml).value('(//Record/ResourceMonitor/Notification)[1]', 'varchar(30)') ='RESOURCE_MEMPHYSICAL_LOW' ORDER BY rbf.timestamp ASC PRINT ''PRINT ''PRINT '==== RING_BUFFER_SCHEDULER_MONITORto Monitor system health' SELECT CONVERT(varchar(30), GETDATE(), 121) as runtime, DATEADD(ms, a.[Record Time] - sys.ms_ticks, GETDATE()) AS Notification_time, a.* , sys.ms_ticks AS [CurrentTime] FROM (SELECT x.value('(//Record/SchedulerMonitorEvent/SystemHealth/ProcessUtilization)[1]', 'int') AS[ProcessUtilization], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/SystemIdle)[1]', 'int') AS [SystemIdle %], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/UserModeTime)[1]', 'bigint') AS [UserModeTime], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/KernelModeTime)[1]', 'bigint') AS [KernelModeTime], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/PageFaults)[1]', 'bigint') AS [PageFaults], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/WorkingSetDelta)[1]', 'bigint')/1024 AS[WorkingSetDelta], x.value('(//Record/SchedulerMonitorEvent/SystemHealth/MemoryUtilization)[1]', 'bigint') AS[MemoryUtilization (%workingset)], x.value('(//Record/@time)[1]', 'bigint') AS [RecordTime] FROM (SELECT CAST(record as xml) FROM sys.dm_os_ring_buffers WHERE ring_buffer_type = 'RING_BUFFER_SCHEDULER_MONITOR') AS R(x)) a CROSS JOIN sys.dm_os_sys_info sys ORDER BY DATEADD(ms, a.[Record Time] - sys.ms_ticks, GETDATE())
故障
a.
内幕
健康
内存
压力
可以使
数据
更多
用以
监控系统
系统
错误
查询
监控
跟踪
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
福建熊掌柜网络技术有限公司
国外 网络安全 研究
阿里云服务器软件下载
sql筛选不同表里的数据库
crt如何登录mysql数据库
国家网络安全教育宣传活动
软件开发可行性分哪些
湛江开发区斗虎网络技术工作室
无锡信息化网络技术哪家便宜
网络安全小故事(案例)
kettle是否支持达梦数据库
注册用户信息一般在数据库哪里
录播服务器管理口是哪个
交接数据库需要什么
虚拟机连接vpn服务器
嘉兴构建智慧医院软件开发
如何重装服务器系统教程
会员信息数据库表设计
学游戏软件开发可以去小米吗
阿里云服务器宽度
数据库投影定义视图
公安局安装网络安全系统
广州物联网软件开发费用
金砖通讯视频服务器
國家网络安全人才基地
黄陂靠谱的软件开发中心
茌平软件开发项目管理在线咨询
查询前5000条数据库
怎么写软件开发公司优势
做好网络安全的简报