IBM.MQ.ChannelStatus.Monitor.DS (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
Scheduler DataSource System.Scheduler Default
PA ProbeAction Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe Default

Overrideable Parameters:

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

Source Code:

<DataSourceModuleType ID="IBM.MQ.ChannelStatus.Monitor.DS" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" type="xsd:integer" name="IntervalSeconds"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" type="xsd:integer" name="TimeoutSeconds"/>
</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.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
<SpreadInitializationOverInterval Unit="Seconds">$Config/IntervalSeconds$</SpreadInitializationOverInterval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="PA" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagTriggerOnlyProbe">
<ScriptName>IBM.MQ.ChannelStatus.Monitor.DS.ps1</ScriptName>
<ScriptBody><Script>
#=================================================================================
# IBM MQ Channel Status Script
#
# Author: Kevin Holman
# v1.0
#=================================================================================


# Manual Testing section - put stuff here for manually testing script - typically parameters:
#=================================================================================
#=================================================================================


# Constants section - modify stuff here:
#=================================================================================
# Assign script name variable for use in event logging.
$ScriptName = "IBM.MQ.ChannelStatus.Monitor.DS.ps1"
$EventID = "17001"
#=================================================================================


# Starting Script section - All scripts get this
#=================================================================================
# Gather the start time of the script
$StartTime = Get-Date
#Set variable to be used in logging events
$whoami = whoami
# Load MOMScript API
$momapi = New-Object -comObject MOM.ScriptAPI
#Log script event that we are starting task
#$momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript is starting. `nRunning as ($whoami).")
#=================================================================================


# Begin MAIN script section
#=================================================================================
#Get the Queue Managers
$QMGRcmd = "dspmq"
$QMGRcmdOut = Invoke-Expression $QMGRcmd
FOREACH ($QMGRLine in $QMGRcmdOut)
{
$QMGRLineSplit = $QMGRLine.Split("(,)")
[string]$QueueManagerName = $QMGRLineSplit[1]
#Write-Host "Found QM: ($QueueManagerName)"

#Get the Channels from each QueueManager
$Ccmd = "cmd /c 'echo Display channel(*) | runmqsc $QueueManagerName'"

$Cout = Invoke-Expression $Ccmd
FOREACH ($CLine in $Cout)
{
$Cmatch = $CLine | Select-String -Pattern 'CHANNEL\(' -CaseSensitive
IF ($Cmatch)
{
$CLineSplit = $CLine.Split("(,)")
[string]$ChannelName = $CLineSplit[1]

#Write-Host "Found Channel: ($ChannelName)"

#Get the channel status from ChannelName
$CStatusCmd = "cmd /c 'echo Display chs($ChannelName) | runmqsc $QueueManagerName'"

$CStatusOut = Invoke-Expression $CStatusCmd

FOREACH ($CStatusLine in $CStatusOut)
{
$CStatusMatch = $CStatusLine | Select-String -Pattern 'STATUS'
IF ($CStatusMatch)
{
$Splitter = "STATUS"
$CStatusLineSplit = $CStatusLine -Split $Splitter
$CStatus = $CStatusLineSplit[1]
$CStatus = $CStatus -Replace "[()]",""
$CStatus = $CStatus.Trim()
#Write-Host "CStatus: ($CStatus)"
#$momapi.LogScriptEvent($ScriptName,$EventID,0,"`nQueueManagerName:($QueueManagerName). `nChannelName:($ChannelName). `nChannelStatus:($CStatus).")

# Load PropertyBag function
$bag = $momapi.CreatePropertyBag()
#Create PropertyBags
$bag.AddValue('QueueManager',$QueueManagerName)
$bag.AddValue('ChannelName',$ChannelName)
$bag.AddValue('CStatus',$CStatus)
#Return each property bag as we create and populate it.
$bag
}
}
}
}
}
#=================================================================================
# End MAIN script section


# End of script section
#=================================================================================
#Log an event for script ending and total execution time.
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
$momapi.LogScriptEvent($ScriptName,$EventID,0,"`nScript Completed. `nRunning as ($whoami). `nScript Runtime: ($ScriptTime) seconds.")
#=================================================================================
# End of script
</Script></ScriptBody>
<Parameters>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="PA">
<Node ID="Scheduler"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
</DataSourceModuleType>