This blog is based on the monitoring the availability groups, replicas and associated databases by using T-SQL. There are multiple catalogs and dynamic management views (DMV) concerned with Always On availability groups.
Using T-SQL to monitor:
To monitor Always On availability groups feature on a server instance
Function Used: Serverproperty
Property: IsHadrEnabled, IsClustered
T-SQL
Select serverproperty (‘IsHadrEnabled’)
The result will be either 1 or 0
1 = enabled
0= disabled
T-SQL
Select * from sys.availability_groups
Select * from sys.availability_groups_cluster
Select * from sys.dm_hadr_availability_group_states
sys.availability_replicas
Returns a row for every availability replica in each availability group for which the local instance of SQL Server hosts an availability replica.
T-SQL
Select * from sys.availability_replicas
Monitoring Availability Databases
T-SQL
Select * from sys.availability_databases_cluster
Monitoring Availability Group Listeners
5. To monitor the availability group listeners on subnets of the WSFC cluster, use the following views:
T-SQL
Select * from sys.availability_group_listeners
Select * from sys.availability_group_listener_ip_addresses
Note: Friends, it is highly recommended to try all these T-SQL statements and check the result.