Analysis Database Monitoring Module

Microsoft.BizTalk.Server.2016.Monitor.AnalysisDatabase.DataSource (DataSourceModuleType)

This module provides data for monitoring availability of a SQL analysis database.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsMicrosoft.BizTalk.ProbeAccount
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.CommandExecuterPropertyBagSource Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval SecondsThis is the interval (in seconds) at which the script associated with the module is run.
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:

<DataSourceModuleType ID="Microsoft.BizTalk.Server.2016.Monitor.AnalysisDatabase.DataSource" Accessibility="Public" RunAs="Microsoft.BizTalk.ProbeAccount" Batching="false">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="TargetDBServer" type="xsd:string"/>
<xsd:element name="TargetAnalysisDBName" type="xsd:string"/>
<xsd:element name="LogSuccessEvent" type="xsd:boolean"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogSuccessEvent" Selector="$Config/LogSuccessEvent$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.CommandExecuterPropertyBagSource">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<ApplicationName>%windir%\system32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>//nologo $file/BizTalkAnalysisDatabaseMonitor.vbs$ "$Config/TargetDBServer$" "$Config/TargetAnalysisDBName$" "$Config/LogSuccessEvent$"</CommandLine>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>BizTalkAnalysisDatabaseMonitor.vbs</Name>
<Contents><Script>
'Copyright (c) Microsoft Corporation. All rights reserved

'This script generates monitoring data for availability of SQL analysis database
'based on connectivity. There are two states - success and error.

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 Analysis Database Monitor"
' Event ID Constants
Const EVENTID_SUCCESS = 99
Const EVENTID_SCRIPT_ERROR = 1000

Const StateDataType = 3

Dim oAPI, oBagState
Dim oParams, TargetDBServer, TargetAnalysisDBName, bLogSuccessEvent
Dim strMonitorStatus, strErrorDetail
Dim dtStart, strMessage

dtStart = Now

Set oParams = WScript.Arguments
if oParams.Count &lt; 3 then
Wscript.Quit -1
End if

strMonitorStatus = "0"

TargetDBServer = oParams(0)
TargetAnalysisDBName = oParams(1)
bLogSuccessEvent = CBool(oParams(2))

Set oAPI = CreateObject("Mom.ScriptAPI")
Set oBagState = oAPI.CreateTypedPropertyBag(StateDataType)

GetMonitorStatus

Sub GetMonitorStatus()
Dim e
Dim AnalysisDBConnStr
Dim Catalog

Set e = New Error
Set Catalog = MomCreateObject("ADOMD.Catalog")

e.Clear
On Error Resume Next
AnalysisDBConnStr = "Data Source=" &amp; TargetDBServer &amp; ";Initial Catalog=" &amp; TargetAnalysisDBName &amp; ";Provider=msolap; Integrated Security=SSPI;"
Catalog.ActiveConnection = AnalysisDBConnStr
e.Save
On Error Goto 0
If 0 &lt;&gt; e.number then
strMonitorStatus = "0"
strErrorDetail = SCRIPT_NAME &amp; ": - Database " &amp; TargetAnalysisDBName &amp; " Failure on Server " &amp; TargetDBServer &amp; " Error Detail:" &amp; e.Description
Else
strMonitorStatus = "1"
strErrorDetail = ""
End if

If bLogSuccessEvent Then
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

oBagState.AddValue "State", strMonitorStatus
oBagState.AddValue "ErrorDetail", strErrorDetail
oAPI.AddItem oBagState
Call oAPI.ReturnItems
End Sub

Sub CreateEvent(lEventID, lEventType, strMessage)
oAPI.LogScriptEvent SCRIPT_NAME, lEventID, lEventType, strMessage
End Sub

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></Contents>
<Unicode>1</Unicode>
</File>
</Files>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>