-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collect AlwaysOn Availability Groups details when gathering health-ch…
…eck databases info (includes data loss in seconds)
- Loading branch information
Showing
8 changed files
with
4,895 additions
and
3 deletions.
There are no files selected for viewing
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
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
50 changes: 50 additions & 0 deletions
50
source/health-check/tables/health-check.statsDatabaseAlwaysOnDetails.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
-- ============================================================================ | ||
-- Copyright (c) 2004-2015 Dan Andrei STEFAN (danandrei.stefan@gmail.com) | ||
-- ============================================================================ | ||
-- Author : Dan Andrei STEFAN | ||
-- Create date : 26.05.2017 | ||
-- Module : Database Analysis & Performance Monitoring | ||
-- ============================================================================ | ||
|
||
----------------------------------------------------------------------------------------------------- | ||
--Health Check: database statistics & details | ||
----------------------------------------------------------------------------------------------------- | ||
RAISERROR('Create table: [health-check].[statsDatabaseAlwaysOnDetails]', 10, 1) WITH NOWAIT | ||
GO | ||
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[health-check].[statsDatabaseAlwaysOnDetails]') AND type in (N'U')) | ||
DROP TABLE [health-check].[statsDatabaseAlwaysOnDetails] | ||
GO | ||
CREATE TABLE [health-check].[statsDatabaseAlwaysOnDetails] | ||
( | ||
[id] [int] IDENTITY (1, 1) NOT NULL, | ||
[catalog_database_id] [smallint] NOT NULL, | ||
[instance_id] [smallint] NOT NULL, | ||
[cluster_name] [sysname] NOT NULL, | ||
[ag_name] [sysname] NOT NULL, | ||
[role_desc] [nvarchar](60) NULL, | ||
[synchronization_health_desc] [nvarchar](60) NULL, | ||
[synchronization_state_desc] [nvarchar](60) NULL, | ||
[data_loss_sec] [int] NULL, | ||
[event_date_utc] [datetime] NOT NULL, | ||
CONSTRAINT [PK_statsDatabaseAlwaysOnDetails] PRIMARY KEY CLUSTERED | ||
( | ||
[id], | ||
[catalog_database_id] | ||
) ON [FG_Statistics_Data], | ||
CONSTRAINT [FK_statsDatabaseAlwaysOnDetails_catalogDatabaseNames] FOREIGN KEY | ||
( | ||
[catalog_database_id] | ||
, [instance_id] | ||
) | ||
REFERENCES [dbo].[catalogDatabaseNames] | ||
( | ||
[id] | ||
, [instance_id] | ||
) | ||
)ON [FG_Statistics_Data] | ||
GO | ||
|
||
CREATE INDEX [IX_statsDatabaseAlwaysOnDetails_CatalogDatabaseID] ON [health-check].[statsDatabaseAlwaysOnDetails] ([catalog_database_id], [instance_id]) ON [FG_Statistics_Index] | ||
GO | ||
CREATE INDEX [IX_statsDatabaseAlwaysOnDetails_InstanceID] ON [health-check].[statsDatabaseAlwaysOnDetails] ([instance_id]) ON [FG_Statistics_Index] | ||
GO |
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
44 changes: 44 additions & 0 deletions
44
source/health-check/views/health-check.vw_statsDatabaseAlwaysOnDetails.sql
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
RAISERROR('Create view : [health-check].[vw_statsDatabaseAlwaysOnDetails]', 10, 1) WITH NOWAIT | ||
GO | ||
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[health-check].[vw_statsDatabaseAlwaysOnDetails]')) | ||
DROP VIEW [health-check].[vw_statsDatabaseAlwaysOnDetails] | ||
GO | ||
|
||
CREATE VIEW [health-check].[vw_statsDatabaseAlwaysOnDetails] | ||
/* WITH ENCRYPTION */ | ||
AS | ||
|
||
-- ============================================================================ | ||
-- Copyright (c) 2004-2015 Dan Andrei STEFAN (danandrei.stefan@gmail.com) | ||
-- ============================================================================ | ||
-- Author : Dan Andrei STEFAN | ||
-- Create date : 05.12.2014 | ||
-- Module : Database Analysis & Performance Monitoring | ||
-- ============================================================================ | ||
|
||
SELECT cin.[project_id] AS [project_id] | ||
, cmn.[id] AS [machine_id] | ||
, cmn.[name] AS [machine_name] | ||
, cin.[id] AS [instance_id] | ||
, cin.[name] AS [instance_name] | ||
, sdaod.[catalog_database_id] | ||
, cdn.[database_id] | ||
, cdn.[name] AS [database_name] | ||
, cdn.[active] | ||
, cdn.[state] | ||
, cdn.[state_desc] | ||
, sdaod.[cluster_name] | ||
, sdaod.[ag_name] | ||
, sdaod.[role_desc] | ||
, sdaod.[synchronization_health_desc] | ||
, sdaod.[synchronization_state_desc] | ||
, sdaod.[data_loss_sec] | ||
, sdaod.[event_date_utc] | ||
FROM [dbo].[catalogInstanceNames] cin | ||
INNER JOIN [dbo].[catalogMachineNames] cmn ON cmn.[id] = cin.[machine_id] AND cmn.[project_id] = cin.[project_id] | ||
INNER JOIN [dbo].[catalogDatabaseNames] cdn ON cin.[id] = cdn.[instance_id] AND cin.[project_id] = cdn.[project_id] | ||
INNER JOIN [health-check].[statsDatabaseAlwaysOnDetails] sdaod ON sdaod.[catalog_database_id] = cdn.[id] AND sdaod.[instance_id] = cdn.[instance_id] | ||
GO | ||
|
||
|
||
|
Oops, something went wrong.