BizTalk Host Probe Action

Microsoft.BizTalk.Server.2016.BizTalkHost.ProbeAction (ProbeActionModuleType)

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.

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsMicrosoft.BizTalk.ProbeAccount
InputTypeSystem.BaseData
OutputTypeSystem.PropertyBagData

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
LogSuccessEventstring$Config/LogSuccessEvent$Log Success EventAn event is logged based on successful completion of the script associated with the module when value is set to 'true'.
TimeoutSecondsint$Config/TimeoutSeconds$Timeout SecondsThis is the timeout (in seconds) after which execution of the script associated with the module is terminated if not yet completed.

Source Code:

<ProbeActionModuleType ID="Microsoft.BizTalk.Server.2016.BizTalkHost.ProbeAction" Accessibility="Public" RunAs="Microsoft.BizTalk.ProbeAccount" Batching="false" PassThrough="false">
<Configuration>
<xsd:element name="HostName" type="xsd:string"/>
<xsd:element name="TargetComputerName" type="xsd:string"/>
<xsd:element name="LogSuccessEvent" type="xsd:boolean"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="LogSuccessEvent" Selector="$Config/LogSuccessEvent$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>BizTalkHostProbeAction.vbs</ScriptName>
<Arguments>"$Config/HostName$" "$Config/TargetComputerName$" "$Config/LogSuccessEvent$"</Arguments>
<ScriptBody><Script>
'Copyright (c) Microsoft Corporation. All rights reserved

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

Option Explicit

'Event Constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
'Other constants
Const SCRIPT_NAME = "BizTalk Server Host Diagnostics"
' Event ID Constants
Const EVENTID_SUCCESS = 99
Const EVENTID_SCRIPT_ERROR = 1000

Const StateDataType = 3

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 &lt; 3 then
Wscript.Quit -1
End if

Dim parameters
Dim arg
for each arg in oParams
parameters = parameters &amp; " , " &amp; arg
Next

strNamespaceToUse = "\ROOT\MicrosoftBizTalkServer"
strQueryToUse = "select * from MSBTS_HostInstance where ClusterInstanceType != 3 and HostName = '"
strErrorDetail = ""

HostName = oParams(0)
TargetComputer = oParams(1)
bLogSuccessEvent = CBool(oParams(2))

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 &amp; HostName &amp; "'"
Set objInstSet = GetWMICollection(TargetComputer, strNamespaceToUse, strQueryToUse)

If objInstSet.Count &gt; 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 &lt;&gt; successState then
strErrorDetail = "The host instance '" &amp; name &amp; "' on computer '" &amp; server &amp; "' 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 &amp; CStr(HostInstanceStatus.Item(key)) &amp; " | "
count = count + 1
next

If bLogSuccessEvent Then
CreateEvent EVENTID_SUCCESS, EVENT_TYPE_INFORMATION, strErrorDetail
strMessage = "The script '" &amp; SCRIPT_NAME &amp; "' completed successfully in " &amp; DateDiff("s", dtStart, Now) &amp; " 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}!\\" &amp; TargetComputerToUse &amp; 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 &lt;&gt; 0 Then ThrowScriptError "Unable to create automation object '" &amp; sProgramId &amp; "'", 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>