Created
August 20, 2020 08:53
-
-
Save EitanBlumin/5ad388aed80f6eb8774677bc685969c4 to your computer and use it in GitHub Desktop.
Query to run in the SentryOne database to check your inventory of AlwaysOn Availability Groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT SiteName, ReplicaName | |
, NumberOfAvailabilityGroups = COUNT(DISTINCT AGName) | |
, NumberOfPrimaries = COUNT(DISTINCT PrimaryReplica) | |
FROM | |
( | |
SELECT DISTINCT | |
ES.ObjectName AS ReplicaName, S.Name AS SiteName | |
, AG.Name AS AGName | |
, AG.PrimaryReplica | |
FROM [SentryOne].[AlwaysOn].[AvailabilityGroup] AS AG | |
INNER JOIN [SentryOne].[AlwaysOn].[AvailabilityGroupReference] AS AGR ON AGR.GroupID = AG.GroupID | |
INNER JOIN [SentryOne].[dbo].[EventSourceConnection] AS ES ON AGR.EventSourceConnectionID = ES.ID | |
LEFT JOIN [SentryOne].[dbo].[Device] AS D ON ES.DeviceID = D.ID | |
LEFT JOIN [SentryOne].[dbo].[Site] AS S ON D.SiteID = S.ID | |
) AS q | |
GROUP BY | |
SiteName, ReplicaName | |
ORDER BY | |
SiteName ASC, ReplicaName ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment