VMware.View.ConnectionServerRole.v0405.EventDbConnectivityCheckProvider (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.EventDbConnectivityCheckProvider" 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.EventDbConnectivityCheck.vbs</ScriptName>
<Arguments>$Config/NetbiosComputerName$</Arguments>
<ScriptBody><Script>

' *
' * VMware.View.ConnectionServerRole.v0405.EventDbConnectivityCheck.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.EventDbConnectivityCheck.vbs", _
"Wrong number of arguments"
End If

Dim netbiosComputerName
netbiosComputerName = oArgs(0)

' Status of Monitor
Dim message
Dim status
status = STATUS_OK

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

oReqBag.add "monitor", "DbMonitor"
oReqBag.add "id", "EVENTS_DATABASE"

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

' Get monitor info
On Error Resume Next
Dim oRespBag
Set oRespBag = oChannel.SendMsg("JAdmin", _
"getMonitorInstance", _
oReqBag)
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

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

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

If oMonitorBag.Contains("State") = True Then

Dim connectedNode
connectedNode = oMonitorBag.get("ConnectedNode", "")

Dim state
state = oMonitorBag.get("State", "")

If UCase(state) = "ERROR" Or UCase(state) = "RECONNECTING" Then

status = STATUS_ERROR
message = oMonitorBag.get("Error", "")
If Len(message) &gt; 0 Then
message = message &amp; " "
End If
message = message &amp; "(" &amp; state &amp; ")"

End If

End If

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>