[counter_name],
[cntr_value] AS PLE -- in seconds
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Manager%'
AND [counter_name] = 'Page life expectancy'
-- with formatings:
; with PLE AS
(
SELECT [object_name],
[counter_name],
[cntr_value] AS PLE,
[cntr_value] / 86400 AS PLEDays,
[cntr_value] - (([cntr_value] / 86400) * 86400) AS PLESecondsInLastDay
FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Manager%'
AND [counter_name] = 'Page life expectancy'
)
SELECT [object_name], [counter_name],
PLE AS PLESec,
PLEDays,
PLESecondsInLastDay, PLESecondsInLastDay / 60,
( RIGHT('0' + CAST(PLESecondsInLastDay / 3600 AS VARCHAR),2) + ':' +
RIGHT('0' + CAST((PLESecondsInLastDay / 60) % 60 AS VARCHAR),2) + ':' +
RIGHT('0' + CAST(PLESecondsInLastDay % 60 AS VARCHAR),2)
) AS PLEInLastDay,
CAST(PLEDays AS VARCHAR) + 'd ' +
( RIGHT('0' + CAST(PLESecondsInLastDay / 3600 AS VARCHAR),2) + ':' +
RIGHT('0' + CAST((PLESecondsInLastDay / 60) % 60 AS VARCHAR),2) + ':' +
RIGHT('0' + CAST(PLESecondsInLastDay % 60 AS VARCHAR),2)
) PLENiceFormat
FROM PLE;
No comments:
Post a Comment