博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
convert Timestamp to Real time
阅读量:6680 次
发布时间:2019-06-25

本文共 1623 字,大约阅读时间需要 5 分钟。

select r.ring_buffer_address,

r.ring_buffer_type,

dateadd (ms, r.[timestamp] - sysinfo.sqlserver_start_time_ms_ticks, sysinfo.sqlserver_start_time) as record_time,

cast(r.record as xml) record

from sys.dm_os_ring_buffers r

cross join sys.dm_os_sys_info sysinfo

where ring_buffer_type='RING_BUFFER_RESOURCE_MONITOR' 

order by 3 desc

 

select r.ring_buffer_address,

r.ring_buffer_type,

dateadd (ms, r.[timestamp] - sysinfo.ms_ticks, getdate()) as record_time,

cast(r.record as xml) record

from sys.dm_os_ring_buffers r

cross join sys.dm_os_sys_info sysinfo

where ring_buffer_type='RING_BUFFER_RESOURCE_MONITOR' 

order by 3 desc

 

DATEADD (ms, -1 * ((sys.cpu_ticks / sys.cpu_ticks_in_ms) - r.timestamp), GETDATE()) as record_time -- sys.cpu_ticks_in_ms 在2008R2中才有

 

DECLARE @ts_now bigint = (SELECT cpu_ticks/(cpu_ticks/ms_ticks) FROM sys.dm_os_sys_info);

SELECT TOP(2)

SQLProcessUtilization AS [SQL Server Process CPU Utilization],

SystemIdle AS [System Idle Process],

100 - SystemIdle - SQLProcessUtilization AS [Other Process CPU Utilization],

DATEADD(ms, -1 * (@ts_now - [timestamp]), GETDATE()) 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 '%<SystemHealth>%') AS x ) AS y ORDER BY record_id DESC;

 

转载地址:http://mwiao.baihongyu.com/

你可能感兴趣的文章
xfs 文件系统损坏修复 fscheck
查看>>
Hibernate之一级缓存
查看>>
Python基础之定义有默认参数的函数
查看>>
443. String Compression - Easy
查看>>
Unity中那些事半功倍的好插件
查看>>
最全的Markdown语法
查看>>
npm i 的几种方式区别
查看>>
Eclipse界面简介
查看>>
iOS5中的UUID
查看>>
(转载)XML Tutorial for iOS: How To Read and Write XML Documents with GDataXML
查看>>
指定的网络文件夹目前是以其他用户名和密码进行映射的。要用其他用户名和密码进行连接,首先请断开所有现有的连接到网络共享的映射...
查看>>
poj 3259 Wormholes
查看>>
Apache CXFjar包目录(转)
查看>>
NewCoder_13_E 通知小弟[缩点]
查看>>
Elasticsearch 空值过滤
查看>>
spring、springboot、springcloud的区别
查看>>
ActiveMQ入门实例
查看>>
POJ1797 Heavy Transportation
查看>>
MySQL查看和修改表的存储引擎
查看>>
py学习之道
查看>>