SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Script to get failover Information for Cluster within a span of time


Script to get failover Information for Cluster within a span of time

Author
Message
SQL!$@w$0ME
SQL!$@w$0ME
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2296 Visits: 1258
Hi Guys,

Please help with a script to get Cluster node failover information within a span of time.

Below script gives information like current node, Last node and What time it failed over for the last time.


USE tempdb

DECLARE @AFTERRESTART VARCHAR(50)

DECLARE @BEFORERESTART VARCHAR(50)

DECLARE @TIME VARCHAR(100)

CREATE TABLE #TBL_FAILOVER_INFO (C1 VARCHAR(100),C2 VARCHAR(15),C3 VARCHAR (200), C4 SMALLINT IDENTITY (0,1))

INSERT INTO #TBL_FAILOVER_INFO

EXEC master.dbo.xp_readerrorlog 0, 1, 'The NETBIOS name of the local node that is running the server is', NULL, NULL, NULL

INSERT INTO #TBL_FAILOVER_INFO

EXEC master.dbo.xp_readerrorlog 1, 1, 'The NETBIOS name of the local node that is running the server is', NULL, NULL, NULL

SET @AFTERRESTART = (SELECT REVERSE(SUBSTRING(REVERSE(SUBSTRING(C3 ,67,100)),70,100)) AS TEXT FROM #TBL_FAILOVER_INFO WHERE C4 =0)

SET @BEFORERESTART = (SELECT REVERSE(SUBSTRING(REVERSE(SUBSTRING(C3 ,67,100)),70,100)) AS TEXT FROM #TBL_FAILOVER_INFO WHERE C4 =1)

SET @TIME = (SELECT C1 FROM #TBL_FAILOVER_INFO WHERE C4 = 0)

SELECT @AFTERRESTART AS 'CURRENT NODE' , @BEFORERESTART AS 'PREVIOUS NODE' , 'FAIL OVER STATUS' =

CASE

WHEN @AFTERRESTART = @BEFORERESTART

THEN 'RESTARTED ON THE NODE:'+ @BEFORERESTART + ' APPROXIMATELY AROUND ' + @TIME

ELSE 'FAILED OVER TO THE NODE:' + @AFTERRESTART + ' APPROXIMATELY AROUND ' + @TIME

END

drop table #TBL_FAILOVER_INFO


Thanks a lot in advance..
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search