NLB node status probe

Microsoft.Windows.NetworkLoadBalancing.NodeStatus.Probe (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsMicrosoft.Windows.NetworkLoadBalancing.PrivilegedAccount
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Source Code:

<ProbeActionModuleType ID="Microsoft.Windows.NetworkLoadBalancing.NodeStatus.Probe" Accessibility="Public" RunAs="Microsoft.Windows.NetworkLoadBalancing.PrivilegedAccount" Batching="false" PassThrough="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="NodeName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ComputerPrincipalName" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>GetNLBNodeStatus.vbs</ScriptName>
<Arguments>$Config/NodeName$ $Config/ComputerPrincipalName$</Arguments>
<ScriptBody><Script>'Copyright (c) Microsoft Corporation. All rights reserved.

SetLocale("en-us")

'==========================================================================
' Main
'==========================================================================

Call RetrieveNodeStatus()

'==========================================================================
' FUNCTIONS
'==========================================================================

Sub RetrieveNodeStatus()
Dim oAPI
Dim oBag
Dim nodeIdentifier
Dim computerName
Dim nodeStatusColl
Dim nodeStatus

nodeIdentifier= WScript.Arguments(0)
computerName = WScript.Arguments(1)

'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:\\" &amp; computerName &amp; "\root\MicrosoftNLB")

wql = "SELECT * FROM MicrosoftNLB_Node WHERE Name='" &amp; nodeIdentifier &amp; "'"

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 &lt;&gt; 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 (" &amp; Err.Description &amp; "). 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

oBag.AddValue "NodeStatus", nodeStatus
oBag.AddValue "TextualStatus", ConvertNumericStatusToString(nodeStatus)

oAPI.Return(oBag)
End Sub

'==========================================================================
'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>