bbcac
asked on
vbscript to gather windows cluster information
I have a script that i have created below which is intended to grab microsoft cluster information. I hacked it together from fragments on the net, but I am having trouble nailing down the logic. I'm sure its some vbscript issue that I just don't understand.
I supply a cluster name, and the script is suppose to collect all the groups from that cluster and store it in an array. For some reason it keeps inserting a blank group into the list of groups. Why is that?
My end result is to get a script that collects all the groups of a cluster, denotes their owner, and their status (online, offline, or partially online)
I've attached what I have so far. To begin in just need to figure out the storing of the cluster groups issue.
Thanks
I supply a cluster name, and the script is suppose to collect all the groups from that cluster and store it in an array. For some reason it keeps inserting a blank group into the list of groups. Why is that?
My end result is to get a script that collects all the groups of a cluster, denotes their owner, and their status (online, offline, or partially online)
I've attached what I have so far. To begin in just need to figure out the storing of the cluster groups issue.
Thanks
strClusterName = "FOSsudXV1"
Set objWMIService = GetObject("winmgmts:\\" & strClusterName & "\root\MSCluster")
Set colItems = objWMIService.ExecQuery("Associators of {MSCluster_Cluster.Name='" & strClustername & "'} WHERE AssocClass = MSCluster_ClusterToNode")
state = "ONLINE"
Dim ClusterGroups()
ClusterGroupSize = 0
Function checkGroupExists(astr)
for each grp4 in ClusterGroups
if (trim(ucase(grp4)) = trim(ucase(astr))) then
checkGroupExists = true
exit function
msgbox ucase(grp4) & " *-EXISTS* " & ucase(astr)
else
end if
next
checkGroupExists = false
exit function
End Function
Function addGroup(astr)
if ClusterGroupSize > 0 then
ReDim tempArray(ClusterGroupSize)
counter = 0
For each grp1 in ClusterGroups
tempArray(counter) = grp1
counter = counter + 1
next
end if
redim ClusterGroups (ClusterGroupSize + 1)
counter =0
if ClusterGroupSize > 0 then
for each grp2 in tempArray
ClusterGroups(counter) = grp2
counter = counter + 1
next
end if
clusterGroups(counter) = aStr 'assign the last member
ClusterGroupSize = ClusterGroupSize + 1
End Function
For each objitem in colItems
output = ""
output = output & objItem.Name & Vbcrlf
Set colAGItems = objWMIService.ExecQuery("Associators of {MSCluster_Node.Name='" & objitem.Name & "'} WHERE AssocClass = MSCluster_NodeToActiveResource")
For each objAGItem in colAGItems
Set GROUPS = objWMIService.ExecQuery("Associators of {MSCluster_Resource.Name='" & objAGItem.Name & "'} WHERE AssocClass = MSCluster_ResourceGroupToResource")
'output = output & "*" & objAGItem.Name & "*" & ": "
'output = output & objAGItem.State & ": "
For each GRP in GROUPS
if (checkGroupExists(GRP.Name) = false AND GRP.Name <> "") then
'msgbox ("adding" & grp.name)
addGroup (GRP.Name)
end if
'msgbox GRP.Name
exit for
next
output = output & Vbcrlf
Next
Next
for each gp in ClusterGroups
msgbox gp
next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
any luck with this?
zf
zf
one:
line 14
should come before the exit function(it wont ever execute)
two:
Line 59
checkGroupExists(GRP.Name)
three:
line 59
If (checkGroupExists(GRP.Name
If (checkGroupExists(GRP.Name
dont have a cluster to test sorry, hope it helps.
zf