'==========================================================================
' Main
'==========================================================================
'In some cases the WMI provider fails to return any status.
'This is most likely caused by the NLB driver being unloaded,
'so assume the node is stopped in such cases.
nodeStatus = 1005
Set objNLBProvider = GetObject("winmgmts:\\" & computerName & "\root\MicrosoftNLB")
wql = "SELECT * FROM MicrosoftNLB_Node WHERE Name='" & nodeIdentifier & "'"
Set nodeStatusColl = objNLBProvider.ExecQuery(wql)
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
On Error Resume Next
If nodeStatusColl.Count = 0 And Err.Number <> 0 Then
oBag.AddValue "NodeStatus", 0
oBag.AddValue "TextualStatus", ConvertNumericStatusToString(0)
oAPI.LogScriptEvent "GetNLBNodeStatus.vbs", 6104 , 2, "Failed to retrieve the status of the NLB node due to a WMI error (" & Err.Description & "). This is likely caused by a configuration problem with NLB or the network adapter used by NLB being disabled."
oAPI.Return(oBag)
Exit Sub
End If
On Error Goto 0
If nodeStatusColl.Count = 1 Then
Dim node
Set node = nodeStatusColl.ItemIndex(0)
nodeStatus = node.StatusCode
End If
'==========================================================================
'Returns the textual representation of the numeric node status
'so that its easier to understand the node status in health explorer
'==========================================================================
Public Function ConvertNumericStatusToString(ByVal nodeStatus)
'0 - Either we are asking for status of a remote node or the provider cant get the status for some reason
'1005 - Stopped
'1006 - Converging
'1007 - Converged
'1008 - Converged
'1009 - Draining
'1013 - Suspended
Dim textualStatus
Select Case nodeStatus
Case 0
textualStatus = "Misconfigured (Unable to get status from WMI)"
Case 1005
textualStatus = "Stopped"
Case 1006
textualStatus = "Converging"
Case 1007,1008
textualStatus = "Converged"
Case 1009
textualStatus = "Draining"
Case 1013
textualStatus = "Suspended"
Case Else
textualStatus = "Unknown status"
End Select
ConvertNumericStatusToString = textualStatus
End Function </Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>