Monitoring Database Mirroring Latency

DECLARE @MirroredDBToTest sysname
SET @MirroredDBToTest = DB_NAME()
DECLARE @MirroringResults TABLE
(database_name sysname,
role int,
mirroring_state int,
witness_status int,
log_generation_rate int,
unsent_log int,
send_rate int,
unrestored_log int,
recovery_rate int,
transaction_delay int,
transactions_per_sec int,
average_delay int,
time_recorded datetime,
time_behind datetime,
local_time datetime)
 
INSERT INTO @MirroringResults
EXEC msdb..sp_dbmmonitorresults @database_name = @MirroredDBToTest
 
SELECT DATEDIFF(S,time_behind, time_recorded) AS Latency FROM @MirroringResults

Leave a Reply

Your email address will not be published. Required fields are marked *