Skip to content

Commit 04c60f8

Browse files
committed
#3635 sp_Blitz AG latency warning
Closes #3635.
1 parent 2c9fb78 commit 04c60f8

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

Documentation/sp_Blitz_Checks_by_Priority.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ Before adding a new check, make sure to add a Github issue for it first, and hav
66

77
If you want to change anything about a check - the priority, finding, URL, or ID - open a Github issue first. The relevant scripts have to be updated too.
88

9-
CURRENT HIGH CHECKID: 267.
10-
If you want to add a new one, start at 268.
9+
CURRENT HIGH CHECKID: 268.
10+
If you want to add a new one, start at 269.
1111

1212
| Priority | FindingsGroup | Finding | URL | CheckID |
1313
|----------|-----------------------------|---------------------------------------------------------|------------------------------------------------------------------------|----------|
@@ -32,6 +32,7 @@ If you want to add a new one, start at 268.
3232
| 1 | Security | Dangerous Service Account | https://vladdba.com/SQLServerSvcAccount | 259 |
3333
| 1 | Security | Dangerous Service Account | https://vladdba.com/SQLServerSvcAccount | 260 |
3434
| 1 | Security | Dangerous Service Account | https://vladdba.com/SQLServerSvcAccount | 261 |
35+
| 5 | Availability | AG Replica Falling Behind | https://www.BrentOzar.com/go/ag | 268 |
3536
| 5 | Monitoring | Disabled Internal Monitoring Features | https://msdn.microsoft.com/en-us/library/ms190737.aspx | 177 |
3637
| 5 | Reliability | Dangerous Third Party Modules | https://support.microsoft.com/en-us/kb/2033238 | 179 |
3738
| 5 | Reliability | Priority Boost Enabled | https://www.BrentOzar.com/go/priorityboost | 126 |

sp_Blitz.sql

+39
Original file line numberDiff line numberDiff line change
@@ -6706,6 +6706,45 @@ IF @ProductVersionMajor >= 10
67066706

67076707

67086708

6709+
IF NOT EXISTS ( SELECT 1
6710+
FROM #SkipChecks
6711+
WHERE DatabaseName IS NULL AND CheckID = 268 )
6712+
BEGIN
6713+
6714+
IF @Debug IN (1, 2) RAISERROR('Running CheckId [%d].', 0, 1, 268) WITH NOWAIT;
6715+
6716+
INSERT INTO #BlitzResults
6717+
( CheckID ,
6718+
Priority ,
6719+
DatabaseName ,
6720+
FindingsGroup ,
6721+
Finding ,
6722+
URL ,
6723+
Details
6724+
)
6725+
SELECT 268 AS CheckID,
6726+
5 AS Priority,
6727+
DB_NAME(ps.database_id),
6728+
'Availability' AS FindingsGroup,
6729+
'AG Replica Falling Behind' AS Finding,
6730+
'https://www.BrentOzar.com/go/ag' AS URL,
6731+
ag.name + N' AG replica server ' +
6732+
ar.replica_server_name + N' is ' +
6733+
CASE WHEN DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) < 200 THEN (CAST(DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) AS NVARCHAR(10)) + N' seconds ')
6734+
ELSE (CAST(DATEDIFF(MINUTE, drs.last_commit_time, ps.last_commit_time) AS NVARCHAR(10)) + N' minutes ') END
6735+
+ N' behind the primary.'
6736+
AS details
6737+
FROM sys.dm_hadr_database_replica_states AS drs
6738+
JOIN sys.availability_replicas AS ar ON drs.replica_id = ar.replica_id
6739+
JOIN sys.availability_groups AS ag ON ar.group_id = ag.group_id
6740+
JOIN sys.dm_hadr_database_replica_states AS ps
6741+
ON drs.group_id = ps.group_id
6742+
AND drs.database_id = ps.database_id
6743+
AND ps.is_local = 1 /* Primary */
6744+
WHERE drs.is_local = 0 /* Secondary */
6745+
AND DATEDIFF(SECOND, drs.last_commit_time, ps.last_commit_time) > 60;
6746+
END;
6747+
67096748

67106749
IF @CheckUserDatabaseObjects = 1
67116750
BEGIN

0 commit comments

Comments
 (0)