There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
VBScript for a W2K3 Cluster failover


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
strogonof's Avatar
Junior Member with 2 posts.
 
Join Date: Aug 2004
Experience: Intermediate
06-Aug-2004, 12:00 PM #1
VBScript for a W2K3 Cluster failover
Hi,

I'm doing a script to fail over my company's W2K3 cluster with 2 nodes.
The idea is to simulate a cluster fail over by the script, count the time of fail over for each group and put them in a .html file to send by email.
I found some useful scripts on the web, where I took part of the code.
Here's what I have until now:

Option Explicit
Dim objClus, WSHShell, objNet, objFS, strSysName, strDir, strClusDir, strOutputFile, fsoOutputFile
Dim itmNode, itmGroup
Dim c1, c2, c3, p1, p2, p3, v1, v2, v3
Dim cOff, pOff, vOff, cOn, pOn, vOn, cSt, pSt, vSt

Set objNet = WScript.CreateObject("WScript.Network")
Set WSHShell = Wscript.CreateObject("WScript.Shell")
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objClus = CreateObject("MSCluster.Cluster")


objClus.Open ""

strSysName = objNet.ComputerName

strDir = WSHShell.ExpandEnvironmentStrings("%SYSTEMROOT%")
strClusDir = strDir & "\Cluster\"

strOutputFile = strClusDir & objClus.Name & ".htm"

'if (objFS.FileExists(strOutputFile)) then
' strOutputFile = strClusDir & objClus.Name & ".htm"
'end if

Set fsoOutputFile = objFS.CreateTextFile(strOutputFile, True)



fsoOutputFile.WriteLine()
fsoOutputFile.WriteLine("<HTML>")
fsoOutputFile.WriteLine("<BODY>")
fsoOutputFile.WriteLine("<HEAD>")
fsoOutputFile.WriteLine("<style>")
fsoOutputFile.WriteLine("BODY {margin-left: .5in; margin-right: .5in;margin-top: .25in; font-family: 'arial'; font-size: 10pt}")
fsoOutputFile.WriteLine("H2 {margin-bottom: 1mm}")
fsoOutputFile.WriteLine("TD {font-size: 10pt}")
fsoOutputFile.WriteLine("HR {margin-bottom: 0mm}")
fsoOutputFile.WriteLine("</style>")
fsoOutputFile.WriteLine("</HEAD>")
fsoOutputFile.WriteLine()
fsoOutputFile.WriteLine("<H2> Cluster Failover " & objClus.Name & "</H2>")
fsoOutputFile.WriteLine("<HR WIDTH='75%' ALIGN='LEFT' COLOR=#000000><p>")
fsoOutputFile.WriteLine()


fsoOutputFile.WriteLine("<TABLE CELLPADDING='5'>")


'Print the cluster nodes
For Each itmNode in objClus.Nodes
fsoOutputFile.WriteLine("<TD ALIGN='RIGHT' VALIGN='TOP'><b>Nó:</b></TD>")
fsoOutputFile.WriteLine("<TD>")

fsoOutputFile.WriteLine(itmNode.Name & "</TD><TD> " & itmNode.state & "</TD><BR>")

Next
fsoOutputFile.WriteLine("</TR>")
fsoOutputFile.WriteLine("</TABLE><P>")

fsoOutputFile.WriteLine("<HR WIDTH='75%' ALIGN='LEFT' COLOR=#cccccc>")

'Begin the resources summary table
fsoOutputFile.WriteLine("<P>")
fsoOutputFile.WriteLine("<b><i>Failover</i></b>")
fsoOutputFile.WriteLine("<blockquote>")
fsoOutputFile.WriteLine("<TABLE BORDER='0' BORDERCOLOR='#cccccc' CELLPADDING='5'>")
fsoOutputFile.WriteLine("<TR><TD><b>Group</b></TD>")
fsoOutputFile.WriteLine("<TD><b>Time/Date</b></TD>")
fsoOutputFile.WriteLine("<TD><b>Offline Time</b></TD>")
fsoOutputFile.WriteLine("<TD><b>Online Time</b></TD>")
fsoOutputFile.WriteLine("<TD><b>Startup Time</b></TD></TR>")



'Run this For-Each loop for each resource group in the cluster


For Each itmGroup in objClus.ResourceGroups

'Move Groups to appropriate node


'Print the name of the group
fsoOutputFile.WriteLine("<TR><TD VALIGN='TOP' ROWSPAN='" & itmGroup.Resources.Count & "'>" & itmGroup.Name & " </TD>")



'Print the time and date
fsoOutputFile.WriteLine("<TD VALIGN='TOP' ROWSPAN='" & itmGroup.Resources.Count & "'>" & Now & " </TD>")


If itmGroup.Name <> "Cluster Group" Then
c1 = Now
itmGroup.Offline(120)
c2=Now
cOff = (c2-c1)*86400.0
itmGroup.Move(20)
itmGroup.Online(60)
c3 = Now
cOn = (c3-c2)*86400.0
cSt = cOff + cOn

fsoOutputFile.WriteLine("<TD VALIGN='TOP' ROWSPAN='" & itmGroup.Resources.Count & "'>" & cstr(cOff) & " </TD>")
fsoOutputFile.WriteLine("<TD VALIGN='TOP' ROWSPAN='" & itmGroup.Resources.Count & "'>" & cOn & " </TD>")
fsoOutputFile.WriteLine("<TD VALIGN='TOP' ROWSPAN='" & itmGroup.Resources.Count & "'>" & cSt & " </TD></TR>")

End If

Next


'End of the resource details table
fsoOutputFile.WriteLine("</TABLE>")
fsoOutputFile.WriteLine("</blockquote>")

'Print the footer
fsoOutputFile.WriteLine("<P>")
fsoOutputFile.WriteLine("<HR WIDTH='75%' ALIGN='LEFT' COLOR=#cccccc>")
fsoOutputFile.WriteLine("<i>End of Report</i>")
fsoOutputFile.WriteLine("<HR WIDTH='75%' ALIGN='LEFT' COLOR=#cccccc>")

fsoOutputFile.WriteLine("</BODY>")
fsoOutputFile.WriteLine("</HTML>")

fsoOutputFile.Close


The cluster is configured with 3 groups (quorum, sql, exchange) and when I run the script it goes directly to the 3rd group, without doing the fail over for the other 2 groups. And it gives an error saying: "The resource or group is not in the correct state to perform the requested operation" (something like this).

Well...this isn't working as I expected to. It's bringing a group offline and it doesn't move the group. Consequently, the next group isn't brought offline, and the times for the 3 groups doesn't appear in the html file.

Any suggestions ???

Thanks!!!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:39 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.