Status


List AG with status != HEALTHY

select db.name as db_name, ag.name as ag_name, hdr_st.synchronization_health_desc, hdr_st.synchronization_health,
	hdr_st.synchronization_state_desc,
	rep.replica_server_name, rep_st.role_desc, rep_st.operational_state_desc,
	hdr_st.last_hardened_time
	from sys.dm_hadr_database_replica_states hdr_st
	inner join sys.databases db on hdr_st.database_id = db.database_id
	inner join sys.availability_replicas rep on hdr_st.replica_id = rep.replica_id
	inner join sys.dm_hadr_availability_replica_states rep_st on rep.replica_id = rep_st.replica_id
	inner join sys.availability_groups ag on ag.group_id = rep.group_id
	where hdr_st.synchronization_health != 2;