You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are log shipping a large number of DBs it would be useful to know if you have all the databases protected from the primary server on your secondary server. DBA Dash will only alert you if the latency of any of the restoring databases hits a certain threshold. It won't tell you if you are missing any databases. This is a useful validation check - particularly if you are log shipping a larger number of databases and databases are been added frequently to the primary.
Until something is built into the app this can be used a workaround.
Create a new database on the same SQL Instance as the DBA Dash repository database.
Run this script in the context of the new database:
CREATETABLEdbo.LogShippingConfig(
PrimaryInstance SYSNAME NOT NULL,
SecondaryInstance SYSNAME NOT NULL,
NewDatabaseGracePeriodMins INTNOT NULL,
CONSTRAINT PK_LogShippingConfig PRIMARY KEY(PrimaryInstance,SecondaryInstance)
)
CREATETABLEdbo.ExcludedDBs(
PrimaryInstance SYSNAME NOT NULL,
ExcludedDatabase SYSNAME NOT NULL,
CONSTRAINT PK_ExcludedDBs PRIMARY KEY (PrimaryInstance,ExcludedDatabase)
)
CREATE OR ALTER PROC dbo.LogShippingStatus_GetASSET NOCOUNT ONSELECTLS.PrimaryInstance,
LS.SecondaryInstance,
D1.name,
D1.create_date,
CASE WHEN D2.name IS NULL THEN CAST(0ASBIT) ELSE CAST(1ASBIT) END AS IsLogShipped,
CASE WHEN DATEDIFF(mi,d1.create_date,GETUTCDATE()) <LS.NewDatabaseGracePeriodMins THEN CAST(1ASBIT) ELSE 0 END as IsGracePeriodForNewDB,
CASE WHEN X.ExcludedDatabaseIS NOT NULL THEN CAST(1ASBIT) ELSE CAST(0ASBIT) END as IsExcluded,
LSS.last_file,
LSS.LatencyOfLast,
LSS.TimeSinceLast,
LSS.TotalTimeBehind,
LSS.backup_start_date,
LSS.backup_start_date_utc,
LSS.restore_date,
LSS.restore_date_utc,
LSS.StatusDescription,
LSS.Status
INTO #LogShippingStatusFROMdbo.LogShippingConfig LS
JOINdbo.Instances I1 ONLS.PrimaryInstance=I1.ConnectionIDANDI1.IsActive=1JOINdbo.Databases D1 ONI1.InstanceID=D1.InstanceIDANDD1.IsActive=1LEFT JOINdbo.Instances I2 ONLS.SecondaryInstance=I2.ConnectionIDANDI2.IsActive=1LEFT JOINdbo.Databases D2 OND2.InstanceID=I2.InstanceIDANDD2.name=D1.nameAND(D2.state=1ORD2.is_in_standby=1) ANDD2.IsActive=1LEFT JOINdbo.LogShippingStatus LSS ONLSS.DatabaseID=D2.DatabaseIDLEFT JOINdbo.ExcludedDBs X OND1.name=X.ExcludedDatabaseANDLS.PrimaryInstance=X.PrimaryInstanceWHERED1.name NOT IN('master','model','tempdb','msdb')
SELECTLS.PrimaryInstance,
LS.SecondaryInstance,
D.name,
D.create_date,
CAST(1ASBIT) AS IsLogShipped,
NULLAS IsGracePeriodForNewDB,
CASE WHEN X.ExcludedDatabaseIS NOT NULL THEN CAST(1ASBIT) ELSE CAST(0ASBIT) END as IsExcluded,
LSS.last_file,
LSS.LatencyOfLast,
LSS.TimeSinceLast,
LSS.TotalTimeBehind,
LSS.backup_start_date,
LSS.backup_start_date_utc,
LSS.restore_date,
LSS.restore_date_utc,
LSS.StatusDescription,
LSS.Status
INTO #ExtraFROMdbo.LogShippingConfig LS
JOINdbo.Instances I ONLS.SecondaryInstance=I.InstanceJOINdbo.Databases D ONI.InstanceID=D.InstanceIDANDD.IsActive=1AND (D.state=1ORD.is_in_standby=1)
LEFT JOINdbo.LogShippingStatus LSS ONLSS.DatabaseID=D.DatabaseIDLEFT JOINdbo.ExcludedDBs X OND.name=X.ExcludedDatabaseANDLS.PrimaryInstance=X.PrimaryInstanceWHERED.name NOT IN('master','model','tempdb')
AND NOT EXISTS(SELECT1FROM#LogShippingStatus LSSWHERELSS.SecondaryInstance=LS.SecondaryInstanceANDLSS.name=D.name)
SELECT PrimaryInstance,
SecondaryInstance,
SUM(CASE WHEN IsLogShipped=0AND IsExcluded=0 THEN 1 ELSE 0 END) AS [Missing Count],
SUM(CASE WHEN IsLogShipped=1 THEN 1 ELSE 0 END) AS [LogShipped Count],
SUM(CASE WHEN IsExcluded=1 THEN 1 ELSE 0 END) AS [Excluded Count],
SUM(CASE WHEN Status=1 THEN 1 ELSE 0 END) as [Critical Count],
SUM(CASE WHEN Status=2 THEN 1 ELSE 0 END) AS [Warning Count],
SUM(CASE WHEN Status=3 THEN 1 ELSE 0 END) AS [N\A Count],
SUM(CASE WHEN Status=4 THEN 1 ELSE 0 END) AS [OK Count],
MIN(backup_start_date_utc) AS [Oldest Backup Restored Utc],
MAX(backup_start_date_utc) AS [Most Recent Backup Restored Utc],
MAX(TimeSinceLast) AS [Max Time Since Last (min)],
MAX(LatencyOfLast) AS [Max Latency of Last (min)],
MAX(TotalTimeBehind) AS [Max Total Time Behind (min)]
FROM#LogShippingStatusGROUP BY PrimaryInstance,
SecondaryInstance
SELECT'Missing'as Issue,CASE WHEN IsGracePeriodForNewDB=1 THEN 100 ELSE 1 END as Priority,*
INTO #IssuesFROM#LogShippingStatusWHERE IsExcluded=0AND IsLogShipped=0UNION ALLSELECT'Unhealthy'as Issue,2AS Priority,*FROM#LogShippingStatusWHERE IsExcluded=0AND (Status IN(1,2))
UNION ALLSELECT'Extra database on secondary'as Issue,999AS Priority,*FROM#ExtraUNION ALLSELECT'Excluded (for review purposes)'AS Issue,1000AS Priority, *FROM#LogShippingStatusWHERE IsExcluded=1
IF EXISTS(SELECT1FROM#Issues
)
BEGINSELECT*FROM#IssuesORDER BY Priority,
backup_start_date_utc
END
IF EXISTS(SELECT1FROM#IssuesWHERE Priority<100
)
BEGIN
RAISERROR('Log shipping status is not healthy',11,1)
END
DROPTABLE#LogShippingStatusDROPTABLE#IssuesDROPTABLE#Extra
Configure
We need to insert the names of the primary and secondary instances in the LogShippingConfig. e.g.
The exclusion period means we don't throw an error when the SP is run for new databases created within the last day. They are still reported in the missing tab, but we don't throw an exception.
Add any exclusions if required (system DBs are excluded automatically)
If you are log shipping a large number of DBs it would be useful to know if you have all the databases protected from the primary server on your secondary server. DBA Dash will only alert you if the latency of any of the restoring databases hits a certain threshold. It won't tell you if you are missing any databases. This is a useful validation check - particularly if you are log shipping a larger number of databases and databases are been added frequently to the primary.
Until something is built into the app this can be used a workaround.
We need to insert the names of the primary and secondary instances in the LogShippingConfig. e.g.
The exclusion period means we don't throw an error when the SP is run for new databases created within the last day. They are still reported in the missing tab, but we don't throw an exception.
The job will fail if there are issues. This allows the issue to be visible in DBA Dash as a failed SQL Agent job.
The text was updated successfully, but these errors were encountered: