VMware.View.ConnectionServerRole.v0405.VcConnectivityCheckProvider (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.PropertyBagProvider Default

Source Code:

<DataSourceModuleType ID="VMware.View.ConnectionServerRole.v0405.VcConnectivityCheckProvider" Accessibility="Internal">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="SyncTime" type="xsd:string"/>
<xsd:element name="NetbiosComputerName" type="xsd:string"/>
</Configuration>
<ModuleImplementation>
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
<ScriptName>VMware.View.ConnectionServerRole.v0405.VcConnectivityCheck.vbs</ScriptName>
<Arguments>$Config/NetbiosComputerName$</Arguments>
<ScriptBody><Script>

' *
' * VMware.View.ConnectionServerRole.v0405.VcConnectivityCheck.vbs
' *
' * Probes for event database connectivity.
' *


Option Explicit


Const STATUS_OK = 1
Const STATUS_ERROR = 0

Sub ReturnSystemBag(ByRef oApi, ByVal status, ByVal message)

' Create SCOM property bag
Dim oBag
Set oBag = oApi.CreatePropertyBag()

' Set Status property
If status = STATUS_OK Then
WScript.Echo "Info: Status: OK" &amp; ", Message: " &amp; message
oBag.AddValue "Status", "OK"
Else
WScript.Echo "Info: Status: ERROR" &amp; ", Message: " &amp; message
oBag.AddValue "Status", "ERROR"
End If

oBag.AddValue "Info", message

' Return bag
Call oApi.Return(oBag)

End Sub


WScript.Echo "Info: Initializing..."

' Get SCOM API object
Dim oApi
Set oApi = CreateObject("MOM.ScriptAPI")

' Validate arguments
Dim oArgs
Set oArgs = WScript.Arguments
If Not oArgs.Count = 1 Then
On Error Goto 0
Err.Raise 8, _
"VMware.View.ConnectionServerRole.v0405.VcConnectivityCheck.vbs", _
"Wrong number of arguments"
End If

Dim netbiosComputerName
netbiosComputerName = oArgs(0)

' Status of Monitor
Dim message
Dim status
status = STATUS_OK

' Create mfw channel
Dim oChannel
Set oChannel = CreateObject("VMware.MfwSimpleChannel")

' Create request property bag
Dim oReqIDsBag
Set oReqIDsBag = CreateObject("VMware.MfwPropertyBag")

' Get monitor IDs
oReqIDsBag.add "monitor", "VcMonitor"

On Error Resume Next
Dim oRespIDsBag
Set oRespIDsBag = oChannel.SendMsg("JAdmin", _
"getMonitorIds", _
oReqIDsBag)
Dim errNum
errNum = Err.Number
On Error Goto 0
If errNum &lt;&gt; 0 Then
If errNum = &amp;H80070001 Then
WScript.Echo "Info: Could not open a channel to broker"
ReturnSystemBag oApi, STATUS_ERROR, "Could not open a channel to broker"
WScript.Quit(0)
ElseIf errNum = &amp;H80070003 Then
WScript.Echo "Info: JAdmin queue not present"
ReturnSystemBag oApi, STATUS_ERROR, "JAdmin queue not present"
WScript.Quit(0)
Else
Err.Raise errNum, _
"VMware.View.ConnectionServerRole.v0405.DomainConnectivityCheck.vbs", _
""
End If
End If

' Get each monitor instance
Dim idx
For idx = 0 to oRespIDsBag.Size() - 1

Dim propName
propName = oRespIDsBag.GetName(idx)

If LCase(propName) = "id" Then

Dim instanceID
instanceID = oRespIDsBag.GetIndex(idx)

If Len(instanceID) &gt; 0 Then

' Create request property bag
Dim oReqInstBag
Set oReqInstBag = CreateObject("VMware.MfwPropertyBag")

oReqInstBag.add "monitor", "VcMonitor"
oReqInstBag.add "id", instanceID

' Get monitor info
Dim oRespInstBag
Set oRespInstBag = oChannel.SendMsg("JAdmin", _
"getMonitorInstance", _
oReqInstBag)

If oRespInstBag.isBag("monitorBag") = False Then
On Error Goto 0
Err.Raise 9, _
"VMware.View.ConnectionServerRole.v0405.VcConnectivityCheck.vbs", _
"Unexpected response. Cannot find monitorBag"
End If

Dim oMonitorBag
Set oMonitorBag = oRespInstBag.GetBag("monitorBag")

Dim monitorBagIdx
For monitorBagIdx = 0 to oMonitorBag.Size() - 1

If LCase(oMonitorBag.GetName(monitorBagIdx)) = "brokerentry" Then

Dim oBrokerBag
Set oBrokerBag = oMonitorBag.GetBagIndex(monitorBagIdx)

Dim brokerName
brokerName = oBrokerBag.Get("brokerNetbiosName", "")

If UCase(brokerName) = UCase(netbiosComputerName) Then

Dim brokerStatus
brokerStatus = oBrokerBag.get("status", "")

If Not UCase(brokerStatus) = "STATUS_UP" Then

status = STATUS_ERROR
If Len(message) &gt; 0 Then
message = message &amp; ", " &amp; oMonitorBag.get("URL", "Unknown")
Else
message = oMonitorBag.get("URL", "Unknown")
End If
End If
End If
End If
Next
End If
End If

Next

WScript.Echo "Info: Status: " &amp; status &amp; ", Message: " &amp; message
WScript.Echo ""

ReturnSystemBag oApi, status, message

WScript.Quit(0)

</Script></ScriptBody>
<TimeoutSeconds>120</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>