Lists all stopped instances for a BizTalk host. The output of this module gets displayed in the diagnostic pane of the System Center Operations Manager (SCOM) console.
'This script generates diagnostics data for BizTalk host based on the availability
'of all its host instances (BTSNTSvc.exe). For error and warning states it shows
'host instance that are not running.
Dim oAPI, oBagState
Dim oParams, HostName, TargetComputer, bLogSuccessEvent
Dim strErrorDetail
Dim strNamespaceToUse, strQueryToUse
Dim dtStart, strMessage
dtStart = Now
Set oParams = WScript.Arguments
If oParams.Count < 3 then
Wscript.Quit -1
End if
Dim parameters
Dim arg
for each arg in oParams
parameters = parameters & " , " & arg
Next
strNamespaceToUse = "\ROOT\MicrosoftBizTalkServer"
strQueryToUse = "select * from MSBTS_HostInstance where ClusterInstanceType != 3 and HostName = '"
strErrorDetail = ""
Set oAPI = CreateObject("Mom.ScriptAPI")
Set oBagState = oAPI.CreateTypedPropertyBag(StateDataType)
Dim HostInstanceStatus
Set HostInstanceStatus = CreateObject("Scripting.Dictionary")
GetMonitorStatus
Sub GetMonitorStatus()
Dim objInst, objInstSet, name, server, hosttype, status, successState
strQueryToUse = strQueryToUse & HostName & "'"
Set objInstSet = GetWMICollection(TargetComputer, strNamespaceToUse, strQueryToUse)
If objInstSet.Count > 0 then
For Each objInst in objInstSet
name = CStr(objInst.Properties_("Name").value)
server = CStr(objInst.Properties_("RunningServer").value)
status = CStr(objInst.Properties_("ServiceState").value)
hosttype = CStr(objInst.Properties_("HostType").value)
if hosttype = "1" then
successState = "4"
else
successState = "8"
end if
if status <> successState then
strErrorDetail = "The host instance '" & name & "' on computer '" & server & "' is not running."
if not (HostInstanceStatus.Exists(name)) then
HostInstanceStatus.Add name, strErrorDetail
else
HostInstanceStatus.Item(name) = strErrorDetail
end if
end if
Next
End If
Dim key, count
count = 1
strErrorDetail = ""
for each key in HostInstanceStatus.Keys
oBagState.AddValue count, CStr(HostInstanceStatus.Item(key))
strErrorDetail = strErrorDetail & CStr(HostInstanceStatus.Item(key)) & " | "
count = count + 1
next
If bLogSuccessEvent Then
CreateEvent EVENTID_SUCCESS, EVENT_TYPE_INFORMATION, strErrorDetail
strMessage = "The script '" & SCRIPT_NAME & "' completed successfully in " & DateDiff("s", dtStart, Now) & " seconds."
CreateEvent EVENTID_SUCCESS, EVENT_TYPE_INFORMATION, strMessage
End If
oAPI.AddItem oBagState
Call oAPI.ReturnItems
End Sub
Sub CreateEvent(lEventID, lEventType, strMessage)
oAPI.LogScriptEvent SCRIPT_NAME, lEventID, lEventType, strMessage
End Sub
Function GetWMICollection(TargetComputerToUse, strNamespace, strQuery)
Dim WbemSrv, WbemObjectSet
Set WbemSrv = Getobject("winmgmts:{impersonationLevel=impersonate}!\\" & TargetComputerToUse & strNamespace)
Set WbemObjectSet = WbemSrv.ExecQuery(strQuery)
Set GetWMICollection = WbemObjectSet
End Function
Function MomCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error
On Error Resume Next
Set MomCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0
If oError.Number <> 0 Then ThrowScriptError "Unable to create automation object '" & sProgramId & "'", oError
End Function
Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile
Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub
Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = m_lNumber
End Property
Public Property Get Source()
Source = m_sSource
End Property
Public Property Get Description()
Description = m_sDescription
End Property
Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class </Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>