Microsoft.IT.SCOM.ASB.Topic.Monitoring.DS (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
Scheduler DataSource System.SimpleScheduler Default
Probe ProbeAction Microsoft.Windows.PowerShellPropertyBagProbe Default

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$
TimeoutSecondsint$Config/TimeoutSeconds$

Source Code:

<DataSourceModuleType ID="Microsoft.IT.SCOM.ASB.Topic.Monitoring.DS" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" maxOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" maxOccurs="1" name="SyncTime" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="Scheduler" TypeID="System!System.SimpleScheduler">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime>$Config/SyncTime$</SyncTime>
</DataSource>
<ProbeAction ID="Probe" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>TopicMonitoring.ps1</ScriptName>
<ScriptBody><Script>param($namespaceName, $password, $assemblyLocation, $topicName)

$api = New-Object -comObject 'MOM.ScriptAPI'

#$api.LogScriptEvent("TopicMonitoring.ps1",300,4,"Staring topic monitoring for topic ${topicName} on namespace ${namespaceName}")

[Void][System.Reflection.Assembly]::LoadWithPartialName("System")
[Void][System.Reflection.Assembly]::LoadFile($assemblyLocation)

$conn = "Endpoint=sb://" + $namespaceName + "/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=" + $password
$bag = $api.CreatePropertyBag()

$namespaceManager = [Microsoft.ServiceBus.NamespaceManager]::CreateFromConnectionString($conn)
$topic = $namespaceManager.GetTopic($topicName)

$bag.AddValue("Status", $topic.Status.ToString())
$bag.AddValue("AvailabilityStatus", $topic.AvailabilityStatus.ToString())
$bag.AddValue("IsAnonymousAccessible", $topic.IsAnonymousAccessible)
$bag.AddValue("SizeInBytes", $topic.SizeInBytes)
$bag.AddValue("SubscriptionCount", $topic.SubscriptionCount)

$success = $true

$bag

if($success){
#$api.LogScriptEvent("TopicMonitoring.ps1",301,4,"Completed topic monitoring for topic ${topicName} on namespace ${namespaceName}")
}

if (($Error.Count -gt 0) -and ($success -eq $false))
{
$api.LogScriptEvent("TopicMonitoring.ps1",315,1,"The following Errors occured while trying to monitor the topic ${topicName} on Namespace ${namespaceName}:" + $Error[0])
}</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>namespaceName</Name>
<Value>$Target/Host/Property[Type="Microsoft.IT.SCOM.ASB.Namespace"]/NamespaceName$</Value>
</Parameter>
<Parameter>
<Name>password</Name>
<Value>$RunAs[Name="Microsoft.IT.SCOM.ASB.RunAsProfile.Account"]/Password$</Value>
</Parameter>
<Parameter>
<Name>assemblyLocation</Name>
<Value>$FileResource[Name="Microsoft.ServiceBus"]/Path$</Value>
</Parameter>
<Parameter>
<Name>topicName</Name>
<Value>$Target/Property[Type="Microsoft.IT.SCOM.ASB.Topic"]/TopicName$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Probe">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>