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" & ", Message: " & message
oBag.AddValue "Status", "OK"
Else
WScript.Echo "Info: Status: ERROR" & ", Message: " & 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")
' 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 <> 0 Then
If errNum = &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 = &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) > 0 Then
message = message & " "
End If
message = message & "(" & state & ")"
End If
End If
WScript.Echo "Info: Status: " & status & ", Message: " & message
WScript.Echo ""