HIS 2006 Service Discovery

HIS_2006_Service_Discovery (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{097811E3-E7E9-4FAB-822A-D1494D0B3830}

Member Modules:

ID Module Type TypeId RunAs 
RunScriptAction WriteAction System.Mom.BackwardCompatibility.ScriptResponse Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
Monitor_Connections_with_Activation__By_Administratorstring$Config/Parameters/Monitor_Connections_with_Activation__By_Administrator$Monitor Connections with Activation = By Administrator
Monitor_Connections_with_Activation__On_Server_Startupstring$Config/Parameters/Monitor_Connections_with_Activation__On_Server_Startup$Monitor Connections with Activation = On Server Startup
Monitor_Connections_with_Activation__On_demandstring$Config/Parameters/Monitor_Connections_with_Activation__On_demand$Monitor Connections with Activation = On demand

Source Code:

<WriteActionModuleType ID="HIS_2006_Service_Discovery" Accessibility="Internal" Comment="{097811E3-E7E9-4FAB-822A-D1494D0B3830}">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>MomBackwardCompatibility!System.Mom.BackwardCompatibility.AlertGenerationSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AlertGeneration" type="AlertGenerationType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InvokerType" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Parameters" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Monitor_Connections_with_Activation__By_Administrator" type="xsd:string" minOccurs="0"/>
<xsd:element name="Monitor_Connections_with_Activation__On_Server_Startup" type="xsd:string" minOccurs="0"/>
<xsd:element name="Monitor_Connections_with_Activation__On_demand" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Monitor_Connections_with_Activation__By_Administrator" Selector="$Config/Parameters/Monitor_Connections_with_Activation__By_Administrator$" ParameterType="string"/>
<OverrideableParameter ID="Monitor_Connections_with_Activation__On_Server_Startup" Selector="$Config/Parameters/Monitor_Connections_with_Activation__On_Server_Startup$" ParameterType="string"/>
<OverrideableParameter ID="Monitor_Connections_with_Activation__On_demand" Selector="$Config/Parameters/Monitor_Connections_with_Activation__On_demand$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="RunScriptAction" TypeID="MomBackwardCompatibility!System.Mom.BackwardCompatibility.ScriptResponse">
<AlertGeneration>$Config/AlertGeneration$</AlertGeneration>
<InvokerType>$Config/InvokerType$</InvokerType>
<Body><Script>
'--------------------------------------------------------------------------------------------------
' &lt;name&gt;HIS 2006 Service Discovery.vbs&lt;/name&gt;
' &lt;company&gt;Microsoft Corporation&lt;/company&gt;
' &lt;copyright&gt;Copyright (c) Microsoft Corporation 2006&lt;/copyright&gt;
' &lt;summary&gt;
' Microsoft Host Integration Server 2006 service discovery script for use with MOM 2005. Provides
' discovery functions for HIS SNA, HIS Svcs, and HIS HIP state monitoring roles, and components
' without state monitoring.
' &lt;/summary&gt;
'
' See Management Pack Guide for details on parameters and usage
'--------------------------------------------------------------------------------------------------

CONST HIS_PACKAGE_CODE = "{0CDBAFE3-08E1-47DF-9E91-C86A540C9C08}"

Dim strIndent, strIndent2, strIndent3

strIndent=" "
strIndent2=strIndent &amp; strIndent
strIndent3=strIndent2 &amp; strIndent

Dim intMonitoredConnections, intTN3Sessions, intPrintSessions, intTN5Defs, intLUResync, intIPResync, strDomain, strRole
Dim intSI, intMI, intDI, intWIP

intMonitoredConnections = 0
intTN3Sessions = 0
intTN5Defs = 0
intPrintSessions = 0
intHIPApps = 0
intLUResync = 0
intIPResync = 0
intSI = 0
intMI = 0
intDI = 0
intWIP = 0

Dim bDisableTN3Monitoring, bDisableTN5Monitoring, bDisablePrintMonitoring, bDisableHIPMonitoring, bDisableLU62ResyncMonitoring, bDisableIPResyncMonitoring

bDisableTN3Monitoring = FALSE
bDisableTN5Monitoring = FALSE
bDisablePrintMonitoring = FALSE
bDisableHIPMonitoring = FALSE
bDisableLU62ResyncMonitoring = FALSE
bDisableIPResyncMonitoring = FALSE
bDisableSIMonitoring = FALSE
bDisableMIMonitoring = FALSE
bDisableDIMonitoring = FALSE
bDisableWIPMonitoring = FALSE

Dim bSNAService
bSNAService = FALSE

Dim Locator, Service
Set Locator = CreateObject("WbemScripting.SWbemLocator")

Sub Main()

ScriptContext.Echo ("Starting HIS service discovery")

GetRegParams()

if NOT CheckServices() then
ScriptContext.Echo("Required services are not running, exiting")
else

SNADiscovery()
SNASvcsDiscovery()
HIPDiscovery()
SetComputerAttributes()

end if

ScriptContext.Echo ("Ending HIS service discovery")

End Sub

Function CheckServices()

' If SNA Services are present, verify that SNABase and SNA Manage Agent services are running.
' If not, the system is starting up and since those functions are not available the discovery
' script should not continue to run.

if NOT bSNAService then

ScriptContext.Echo(strIndent &amp; "Required services check passed - SNA Service not installed.")
CheckServices=True

else

if ScriptContext.isTargetAgentless then
Set Service = Locator.ConnectServer(ScriptContext.TargetNetBiosComputer, "root\cimv2")
else
Set Service = Locator.ConnectServer(".", "root\cimv2")
end if

set objService = Service.Get("Win32_Service.Name='SNABase'")

if objService.State &lt;&gt; "Running" then

ScriptContext.Echo(strIndent &amp; "SNABase state: " &amp; objService.State)
CheckServices=False

else

set objService = Service.Get("Win32_Service.Name='MngAgent'")
if objService.State &lt;&gt; "Running" then

ScriptContext.Echo(strIndent &amp; "MngAgent state: " &amp; objService.State)
CheckServices=False

else

ScriptContext.Echo(strIndent &amp; "Required services are running")
CheckServices=True

end if

end if

end if

End Function

Sub GetRegParams()

' Sub GetRegParams()
' Performs all registry lookups required for service discovery.

CONST WMI_REG_HKLM = &amp;H80000002

CONST HIS_OPTOUT_KEYPATH = "SOFTWARE\Microsoft\SNA Server\CurrentVersion\Monitoring\"
CONST HIS_TN3_OPTOUT_KEY = "DisableTN3270Monitoring"
CONST HIS_TN5_OPTOUT_KEY = "DisableTN5250Monitoring"
CONST HIS_PRINT_OPTOUT_KEY = "DisablePrintMonitoring"
CONST HIS_HIP_OPTOUT_KEY = "DisableHIPMonitoring"
CONST HIS_LU62RESYNC_OPTOUT_KEY = "DisableLU62ResyncMonitoring"
CONST HIS_IPRESYNC_OPTOUT_KEY = "DisableIPResyncMonitoring"
CONST HIS_SI_OPTOUT_KEY = "DisableSessionIntegratorMonitoring"
CONST HIS_DI_OPTOUT_KEY = "DisableDataIntegrationMonitoring"
CONST HIS_MI_OPTOUT_KEY = "DisableMessageIntegrationMonitoring"
CONST HIS_WIP_OPTOUT_KEY = "DisableWIPMonitoring"

CONST HIS_SNA_CONFIG_KEYPATH = "SOFTWARE\Microsoft\Host Integration Server\ConfigFramework\ConfiguredFeatures"
CONST HIS_SNA_SERVICE_KEY = "SNA_SERVICE"
CONST HIS_SNA_APPLICATION_SUPPORT_KEY = "SNA_APPLICATION_SUPPORT"

Dim oRegProvider
Dim intReturn
Dim colValues, strValue
Dim colTypes

' =============================================================

' Check for the possible set of monitoring opt-out keys, and for each that exists
' set the corresponding boolean variable to TRUE

if ScriptContext.isTargetAgentless then
set oRegProvider=GetObject("winmgmts:\\" &amp; ScriptContext.TargetNetBiosComputer &amp; "\root\default:StdRegProv")
else
set oRegProvider=GetObject("winmgmts:\\.\root\default:StdRegProv")
end if

ScriptContext.Echo (strIndent &amp; "Checking for opt-out keys")

intReturn = oRegProvider.EnumValues (WMI_REG_HKLM, HIS_OPTOUT_KEYPATH, colValues, colTypes)

if intReturn = 0 AND NOT(IsNull(colValues)) then

for each strValue in colValues

Select Case strValue

Case HIS_TN3_OPTOUT_KEY
bDisableTN3Monitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_TN5_OPTOUT_KEY
bDisableTN5Monitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_PRINT_OPTOUT_KEY
bDisablePrintMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_HIP_OPTOUT_KEY
bDisableHIPMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_LU62RESYNC_OPTOUT_KEY
bDisableLU62ResyncMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_IPRESYNC_OPTOUT_KEY
bDisableIPResyncMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_SI_OPTOUT_KEY
bDisableSIMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_MI_OPTOUT_KEY
bDisableMIMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_DI_OPTOUT_KEY
bDisableDIMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

Case HIS_WIP_OPTOUT_KEY
bDisableWIPMonitoring = TRUE
ScriptContext.Echo (strIndent2 &amp; strValue)

End Select

next

end if

' Check the HIS setup configuration to determine if SNA Service is installed.
' If it's not, SNA-based portions of service discovery should not be run.

ScriptContext.Echo (strIndent &amp; "Checking SNA setup keys")

intReturn = oRegProvider.EnumValues (WMI_REG_HKLM, HIS_SNA_CONFIG_KEYPATH, colValues, colTypes)

if intReturn = 0 AND NOT(IsNull(colValues)) then

for each strValue in colValues

if strValue = HIS_SNA_SERVICE_KEY then

bSNAService = True

end if

next

end if

if bSNAService then
ScriptContext.Echo (strIndent2 &amp; "SNA Service present")
else
ScriptContext.Echo (strIndent2 &amp; "SNA Service not present")
end if

End Sub

Sub SNADiscovery()

' SNA Connection discovery
' If SNA Service is present, get the set of connections for this HIS server, and add a state monitoring
' instance for each SNA service with at least one monitored connection.

CONST HIS_SNA_ROLE = "HIS SNA"
CONST HIS_CONNECTION_COMP = "Connections"
CONST HIS_CONNECTION_PROP = "Monitored connections"
CONST HIS_COMPUTER_PROP = "ComputerName"
CONST HIS_SERVER_PROP = "Server Name"

CONST HIS_ACTIVATION_ON_SERVER_STARTUP = 0
CONST HIS_ACTIVATION_ON_DEMAND = 1
CONST HIS_ACTIVATION_BY_ADMINISTRATOR = 2

Dim oParameters
Dim bMonitorOSS
Dim bMonitorOD
Dim bMonitorBA

Dim oDiscDataHIS
Dim oCollectionHIS
Dim oInstanceSNA

Dim intServiceMonitoredConnections(5)
Dim strServiceName(5)

strServiceName(1) = ScriptContext.TargetNetbiosComputer
strServiceName(2) = ScriptContext.TargetNetbiosComputer &amp; ".02"
strServiceName(3) = ScriptContext.TargetNetbiosComputer &amp; ".03"
strServiceName(4) = ScriptContext.TargetNetbiosComputer &amp; ".04"

' =============================================================

ScriptContext.Echo (strIndent &amp; "HIS SNA discovery")

' Create discovery objects and set basic properties. These objects are used when
' the set of instances are enumerated.

Set oDiscDataHIS = ScriptContext.CreateDiscoveryData
Set oCollectionHIS = oDiscDataHIS.CreateCollection

With oCollectionHIS
.ClassID = HIS_SNA_ROLE
.AddScopeFilter HIS_COMPUTER_PROP, ScriptContext.TargetComputerIdentity
.AddScopeComponent HIS_CONNECTION_COMP
.AddScopeProperty HIS_CONNECTION_PROP
End With

if NOT bSNAService then

ScriptContext.Echo(strIndent2 &amp; "SNA Service not installed")

else

if ScriptContext.isTargetAgentless then
Set Service = Locator.ConnectServer(ScriptContext.TargetNetBiosComputer, "root\MicrosoftHIS")
else
Set Service = Locator.ConnectServer(".", "root\MicrosoftHIS")
end if

' Get script parameters that control which connection activation types are monitored
set oParameters = ScriptContext.Parameters
' Get script parameters that control which connection activation types are monitored
bMonitorBA = CBool(oParameters.get("Monitor_Connections_with_Activation__By_Administrator"))
bMonitorOSS = CBool(oParameters.get("Monitor_Connections_with_Activation__On_Server_Startup"))
bMonitorOD = CBool(oParameters.get("Monitor_Connections_with_Activation__On_demand"))

ScriptContext.Echo (strIndent2 &amp; "Monitor: On Server Startup = " &amp; bMonitorOss &amp; _
", On demand = " &amp; bMonitorOD &amp; _
", On By Administrator = " &amp; bMonitorBA)

for i = 1 to 4
intServiceMonitoredConnections(i) = 0
next

' ''Enumerate the number of monitored connections on each service of this server by:
' 1) Getting the full set of connections for this server
' 2) For each connection verify if it should monitored based on the script parameters, and if so
' increment a counter for that connection's service
' 3) For each service that has at least one monitored connection, add a state monitoring instance
' and the property containing the number of monitored connections for that instance

Set colConnections = Service.ExecQuery("ASSOCIATORS OF {MsSna_Server.Name='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'} where ResultClass=MsSna_Connection",, 0)

for each objConnection in colConnections

if ((objConnection.Activation=HIS_ACTIVATION_ON_SERVER_STARTUP AND bMonitorOSS) OR _
(objConnection.Activation=HIS_ACTIVATION_BY_ADMINISTRATOR AND bMonitorBA) OR _
(objConnection.Activation=HIS_ACTIVATION_ON_DEMAND AND bMonitorOD)) then

Select Case right(objConnection.Service, 3)

Case ".02"

intServiceMonitoredConnections(2) = intServiceMonitoredConnections(2) + 1

Case ".03"

intServiceMonitoredConnections(3) = intServiceMonitoredConnections(3) + 1

Case ".04"

intServiceMonitoredConnections(4) = intServiceMonitoredConnections(4) + 1

Case Else

intServiceMonitoredConnections(1) = intServiceMonitoredConnections(1) + 1

End Select

End if

Next

for i = 1 to 4

if intServiceMonitoredConnections(i) &gt; 0 then

ScriptContext.Echo (strIndent2 &amp; strServiceName(i) &amp; " = True, monitored connections: " &amp; intServiceMonitoredConnections(i))

Set oInstanceSNA = oCollectionHIS.CreateInstance
oInstanceSNA.AddKeyProperty HIS_SERVER_PROP, strServiceName(i)
oInstanceSNA.AddComponent HIS_CONNECTION_COMP
oInstanceSNA.AddProperty HIS_CONNECTION_PROP, intServiceMonitoredConnections(i)

oCollectionHIS.AddInstance oInstanceSNA

intMonitoredConnections = intMonitoredConnections + intServiceMonitoredConnections(i)

end if

next

end if

ScriptContext.Echo (strIndent2 &amp; "Total monitored connections: " &amp; intMonitoredConnections)

' Save the discovery object

oDiscDataHIS.AddCollection oCollectionHIS
ScriptContext.Submit oDiscDataHIS

End Sub

Sub SNASvcsDiscovery()

' SNA Svcs discovery - TN3, TN5, Print, LUResync, IPResync, SI
' All state components within a role must be discovered within a single discovery data instance.
'
' Also discovers and sets attributes for components w/o health states:
' WIP, Data Integration, Message Integration

CONST HIS_SNA_SVCS_ROLE = "HIS Svcs"
CONST HIS_TN3_COMP = "TN3270"
CONST HIS_TN3_PROP = "TN3270 Sessions Defined"
CONST HIS_TN5_COMP = "TN5250"
CONST HIS_TN5_PROP = "TN5250 Definitions"
CONST HIS_PRINT_COMP = "Print"
CONST HIS_PRINT_PROP = "Print Sessions Defined"
CONST HIS_LURESYNC_COMP = "LUResync"
CONST HIS_IPRESYNC_COMP = "IPResync"
CONST HIS_LURESYNC_PROP = "LU Resync"
CONST HIS_IPRESYNC_PROP = "IP Resync"
CONST HIS_IPRESYNC_PATTERN = "HIS TCP/IP Resync Service"
CONST HIS_SI_COMP = "SI"
CONST HIS_SI_PROP = "Session Integrator"
CONST HIS_SI_PATTERN = "Session Integrator Server"
CONST HIS_MI_PROP = "Message Integration"
CONST HIS_MI_PATTERN = "Microsoft MSMQ-MQSeries Bridge"
CONST HIS_DI_PROP = "Data Integration"
CONST HIS_DI_FEATURE = "DATA_DB2"
CONST HIS_WIP_PROP = "WIP"
CONST HIS_WIP_FEATURE = "TRANSACTION_INTEGRATOR"
CONST HIS_COMPUTER_PROP = "ComputerName"
CONST HIS_SERVER_PROP = "Server Name"
CONST HIS_ROLE_PROP = "Role"
CONST HIS_SUBDOMAIN_PROP = "Subdomain"

Dim oDiscDataHIS
Dim oCollectionHIS
Dim oInstanceSNASvcs

Dim colSessions, colTN5Defs, colServices

Dim colLocalAPPCLUs, colRemoteAPPCLUs, objRemoteAPPCLU
Dim intLocalResyncLUs, intRemoteResyncLUs

Dim colWin32Services
Dim objWin32Service

' =============================================================

ScriptContext.Echo (strIndent &amp; "HIS SNA Svcs discovery")

' Setup common discovery data, which will be filled in as discovery is performed for each component.

Set oDiscDataHIS = ScriptContext.CreateDiscoveryData
Set oCollectionHIS = oDiscDataHIS.CreateCollection

With oCollectionHIS
.ClassID = HIS_SNA_SVCS_ROLE
.AddScopeFilter HIS_COMPUTER_PROP, ScriptContext.TargetComputerIdentity
.AddScopeComponent HIS_TN3_COMP
.AddScopeComponent HIS_TN5_COMP
.AddScopeComponent HIS_PRINT_COMP
.AddScopeComponent HIS_LURESYNC_COMP
.AddScopeComponent HIS_IPRESYNC_COMP
.AddScopeComponent HIS_SI_COMP
.AddScopeProperty HIS_TN5_PROP
.AddScopeProperty HIS_TN3_PROP
.AddScopeProperty HIS_PRINT_PROP
.AddScopeProperty HIS_LURESYNC_PROP
.AddScopeProperty HIS_IPRESYNC_PROP
.AddScopeProperty HIS_SI_PROP
.AddScopeProperty HIS_MI_PROP
.AddScopeProperty HIS_DI_PROP
.AddScopeProperty HIS_WIP_PROP
.AddScopeProperty HIS_ROLE_PROP
.AddScopeProperty HIS_SUBDOMAIN_PROP
End With

Set oInstanceSNASvcs = oCollectionHIS.CreateInstance
oInstanceSNASvcs.AddKeyProperty HIS_SERVER_PROP, ScriptContext.TargetNetbiosComputer

if bSNAService then
' Connect to WMI
if ScriptContext.isTargetAgentless then
Set Service = Locator.ConnectServer(ScriptContext.TargetNetBiosComputer, "root\MicrosoftHIS")
else
Set Service = Locator.ConnectServer(".", "root\MicrosoftHIS")
end if
end if

' TN3270 Discovery
' Get the set of TN3270 sessions for this HIS server, and if &gt; 0 add the
' TN3 state monitoring component in the HIS Svcs role.

if bDisableTN3Monitoring then

ScriptContext.Echo (strIndent2 &amp; "TN3270 service = False, opt-out key present")

elseif NOT bSNAService then

ScriptContext.Echo (strIndent2 &amp; "TN3270 service = False, SNA Service not present")

else

' Get TN3270 session count
set colSessions = Service.ExecQuery("select * FROM MsSna_TN3270Session where Service='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'",, 0)

if colSessions.Count = 0 then

ScriptContext.Echo (strIndent2 &amp; "TN3270 service = False, no sessions defined on this server")

else

intTN3Sessions = colSessions.Count
ScriptContext.Echo (strIndent2 &amp; "TN3270 service = True, number of TN3270 sessions defined: " &amp; intTN3Sessions)
oInstanceSNASvcs.AddComponent HIS_TN3_COMP

end if

end if

oInstanceSNASvcs.AddProperty HIS_TN3_PROP, intTN3Sessions

' TN5250 Discovery
' Get the set of TN5250 definitions for this HIS server, and if &gt; 0 add the
' TN5 state monitoring component in the HIS Svcs role.
'

if (bDisableTN5Monitoring) then

ScriptContext.Echo (strIndent2 &amp; "TN5250 service = False, opt-out key present")

elseif NOT bSNAService then

ScriptContext.Echo (strIndent2 &amp; "TN5250 service = False, SNA Service not present")

else

' Get TN5250 definition count
set colTN5Defs = Service.ExecQuery("select * FROM MsSna_TN5250Definition where Service='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'",, 0)

if colTN5Defs.Count = 0 then

ScriptContext.Echo (strIndent2 &amp; "TN5250 service = False, no definitions on this server")

else

intTN5Defs = colTN5Defs.Count
ScriptContext.Echo (strIndent2 &amp; "TN5250 service = True, number of TN5250 definitions: " &amp; intTN5Defs)
oInstanceSNASvcs.AddComponent HIS_TN5_COMP

end if

end if

oInstanceSNASvcs.AddProperty HIS_TN5_PROP, intTN5Defs

' Print Discovery
' Get the set of print sessions for this HIS server, and if &gt; 0 add the
' Print state monitoring component in the HIS Svcs role.
'

if (bDisablePrintMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "Print service = False, opt-out key present")

elseif NOT bSNAService then

ScriptContext.Echo (strIndent2 &amp; "Print service = False, SNA Service not present")

else

' Get Print session count
set colSessions = Service.ExecQuery("select * FROM MsSna_PrintSession where Service='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'",, 0)

if colSessions.Count = 0 then

ScriptContext.Echo (strIndent2 &amp; "Print service = False, no sessions defined on this server")

else

intPrintSessions = colSessions.Count
ScriptContext.Echo (strIndent2 &amp; "Print service = True, number of print sessions defined: " &amp; intPrintSessions)
oInstanceSNASvcs.AddComponent HIS_PRINT_COMP

end if

end if

oInstanceSNASvcs.AddProperty HIS_PRINT_PROP, intPrintSessions

' LU 6.2 Resync Service Discovery
' Get the instances of Local and Remote APPC LUs configured for LU 6.2 Resync support
' by this HIS server, and if &gt; 0 add the LUResync state monitoring component in the HIS Svcs role.
'
if (bDisableLU62ResyncMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "LU 6.2 resync service = False, opt-out key present")

elseif NOT bSNAService then

ScriptContext.Echo (strIndent2 &amp; "LU 6.2 resync service = False, SNA Service not present")

else

' Get count of local APPC LUs configured for resync support
set colLocalAPPCLUs = Service.ExecQuery("select * from MsSna_LUAPPCLocal where SyncPoint=True and SyncPointClient='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'",, 0)

if colLocalAPPCLUs.Count = 0 then

ScriptContext.Echo(strIndent2 &amp; "LU 6.2 Resync service = False, no local resync LUs configured for this server")

else

' Get count of remote APPC LUs configured for resync support,
' and count those on a connection on this server
set colRemoteAPPCLUs = Service.ExecQuery("select * from MsSna_LUAPPCRemote where SyncPoint=True",, 0)

if colRemoteAPPCLUs.Count = 0 then

ScriptContext.Echo(strIndent2 &amp; "LU 6.2 Resync service = False, no remote resync LUs configured in the subdomain")

else

set colServerConnections = Service.ExecQuery("ASSOCIATORS OF {MsSna_Server.Name='" &amp; ScriptContext.TargetNetbiosComputer &amp; "'} where ResultClass=MsSna_Connection",, 0)

for each objRemoteAPPCLU in colRemoteAPPCLUs
for each objConnection in colServerConnections
if objRemoteAPPCLU.Connection = objConnection.Name then
intRemoteResyncLUs = inRemoteResyncLUs + 1
exit for
end if
next
next

if intRemoteResyncLUs = 0 then

ScriptContext.Echo(strIndent2 &amp; "LU 6.2 Resync service = False, no remote resync LUs configured for this server")

else

intLUResync = 1
oInstanceSNASvcs.AddComponent HIS_LURESYNC_COMP
ScriptContext.Echo(strIndent2 &amp; "LU 6.2 resync service = True, local resync LUs: " &amp; colLocalAPPCLUs.Count &amp; ", remote resync LUs: " &amp; intRemoteResyncLUs)

end if
end if
end if
end if

oInstanceSNASvcs.AddProperty HIS_LURESYNC_PROP, intLUResync

' Discover general SNA Properties and add them to the SNA Svcs discovery data
'

if bSNAService then

' Subdomain
set colDomains = Service.ExecQuery("select * from MsSna_Domain",, 0)
for each objDomain in colDomains
strDomain = objDomain.Name
next

' Role
set objServer = Service.Get("MsSna_Server.Name=" &amp; chr(34) &amp; ScriptContext.TargetNetbiosComputer &amp; chr(34))
strRole = objServer.RoleName

else

strDomain = "N/A"
strRole = "N/A"

end if

ScriptContext.Echo(strIndent2 &amp; "Role: " &amp; strRole)
oInstanceSNASvcs.AddProperty HIS_ROLE_PROP, strRole

ScriptContext.Echo(strIndent2 &amp; "Subdomain: " &amp; strDomain)
oInstanceSNASvcs.AddProperty HIS_SUBDOMAIN_PROP, strDomain

' IP Resync Service Discovery
' Check for Win32 service names that match the IP Resync service name pattern.
' If present add the IPResync state component and set IP Resync attribute = number found.
'

if (bDisableIPResyncMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "IP resync service = False, opt-out key present")

else

intIPResync = FindService(HIS_IPRESYNC_PATTERN)

if intIPResync = 0 then
ScriptContext.Echo (strIndent2 &amp; "IP Resync service = False, no service present")
else
ScriptContext.Echo (strIndent2 &amp; "IP Resync service = True")
oInstanceSNASvcs.AddComponent HIS_IPRESYNC_COMP
end if

end if

oInstanceSNASvcs.AddProperty HIS_IPRESYNC_PROP, intIPResync

' Session Integrator Discovery
' Check for Win32 service names that match the SI service name pattern.
' If present add the SI state component and set Session Integrator attribute = 1.
'

if (bDisableSIMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "SI service = False, opt-out key present")

elseif NOT bSNAService then

ScriptContext.Echo (strIndent2 &amp; "SI service = False, SNA Service not present")

else

intSI = FindService(HIS_SI_PATTERN)

if intSI = 0 then
ScriptContext.Echo (strIndent2 &amp; "Session Integrator service = False, no service present")
else
ScriptContext.Echo (strIndent2 &amp; "Session Integrator service = True")
oInstanceSNASvcs.AddComponent HIS_SI_COMP
end if

end if

oInstanceSNASvcs.AddProperty HIS_SI_PROP, intSI

' Message Integration Discovery
' Check for Win32 service names that match the MI service name pattern.
' If present set Message Integration attribute = 1.
'

if (bDisableMIMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "Message Integration service = False, opt-out key present")

else

intMI = FindService(HIS_MI_PATTERN)

if intMI = 0 then
ScriptContext.Echo (strIndent2 &amp; "Message Integration service = False, no service present")
else
ScriptContext.Echo (strIndent2 &amp; "Message Integration service = True")
end if

end if

oInstanceSNASvcs.AddProperty HIS_MI_PROP, intMI

' Data Integration Discovery
' Check for MSI feature installed, if present set Data Integration attribute = 1.
'

if (bDisableDIMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "Data Integration = False, opt-out key present")

else

intDI = FindFeature(HIS_DI_FEATURE)

if intDI = 0 then
ScriptContext.Echo (strIndent2 &amp; "Data Integration = False, feature not present")
else
ScriptContext.Echo (strIndent2 &amp; "Data Integration = True")
end if

end if

oInstanceSNASvcs.AddProperty HIS_DI_PROP, intDI

' WIP Discovery
' Check for MSI feature installed, if present set Data Integration attribute = 1.

if (bDisableWIPMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "WIP = False, opt-out key present")

else

intWIP = FindFeature(HIS_WIP_FEATURE)

if intWIP = 0 then
ScriptContext.Echo (strIndent2 &amp; "WIP = False, feature not present")
else
ScriptContext.Echo (strIndent2 &amp; "WIP = True")
end if

end if

oInstanceSNASvcs.AddProperty HIS_WIP_PROP, intWIP

' Save and submit discovery data for SNA Svcs
' Verify there is at least one component for the role before saving the instance,
' otherwise the computer will have the SNA Svcs role with no components

if NOT (intTN3Sessions = 0 AND intTN5Defs = 0 AND intPrintSessions = 0 AND intLocalResyncLUs = 0 AND intRemoteResyncLUs = 0 AND intIPResync = 0 AND intSI = 0) then

oCollectionHIS.AddInstance oInstanceSNASvcs

end if

oDiscDataHIS.AddCollection oCollectionHIS
ScriptContext.Submit oDiscDataHIS

End Sub

Sub HIPDiscovery()

' HIP Discovery
' Pattern match instances of root\cimv2\Win32_Service that start with "HIPService:".
' If &gt; 0, create the HIS HIP role and add Service, Listeners, and APP state components
' for each instance.

CONST HIS_HIP_ROLE = "HIS HIP"
CONST HIS_HIP_LISTENERS_COMP = "Listeners"
CONST HIS_HIP_APP_COMP = "App"
CONST HIS_HIP_KEY_PROP = "Application Name"
CONST HIP_PATTERN = "HIPService:"
CONST HIS_COMPUTER_PROP = "ComputerName"

Dim colWin32Services
Dim objWin32Service

' =============================================================

ScriptContext.Echo (strIndent &amp; "HIS HIP discovery")

set oDiscDataHIS = ScriptContext.CreateDiscoveryData
set oCollectionHIS = oDiscDataHIS.CreateCollection

With oCollectionHIS
.ClassID = HIS_HIP_ROLE
.AddScopeFilter HIS_COMPUTER_PROP, ScriptContext.TargetComputerIdentity
.AddScopeComponent HIS_HIP_LISTENERS_COMP
.AddScopeComponent HIS_HIP_APP_COMP
End With

if (bDisableHIPMonitoring) then

ScriptContext.Echo (strIndent2 &amp; "HIP role = False, opt-out key present")

else

if ScriptContext.isTargetAgentless then
Set Service = Locator.ConnectServer(ScriptContext.TargetNetBiosComputer, "root\cimv2")
else
Set Service = Locator.ConnectServer(".", "root\cimv2")
end if

set colWin32Services = Service.ExecQuery("select * from Win32_Service",, 0)

for each objWin32Service in colWin32Services

if Left(objWin32Service.DisplayName,11) = HIP_PATTERN then

ScriptContext.Echo (strIndent2 &amp; objWin32Service.Name &amp; " = True")

Set oInstanceHIP = oCollectionHIS.CreateInstance
With oInstanceHIP
.AddComponent HIS_HIP_LISTENERS_COMP
.AddComponent HIS_HIP_APP_COMP
.AddKeyProperty HIS_HIP_KEY_PROP, objWin32Service.Name
End With

oCollectionHIS.AddInstance oInstanceHIP
intHIPApps = intHIPApps + 1

end if

next

if intHIPApps = 0 then

ScriptContext.Echo (strIndent2 &amp; "HIP role = False, no apps defined")

else

ScriptContext.Echo (strIndent2 &amp; "HIP role = True")
ScriptContext.Echo (strIndent2 &amp; "Total HIP applications: " &amp; intHIPApps)

end if

end if

oDiscDataHIS.AddCollection oCollectionHIS
ScriptContext.Submit oDiscDataHIS

End Sub

Sub SetComputerAttributes()

' SetComputerAttributes
'
' Retrieves general HIS server properties and then creates and submits discovery data
' for the set of HIS attributes added to the MOM Computer object.

CONST COMPUTER_COMPUTER_PROP = "ComputerName"
CONST COMPUTER_CONNECTIONS_PROP = "HIS Monitored Connections"
CONST COMPUTER_TN3_PROP = "HIS TN3270 Sessions Defined"
CONST COMPUTER_TN5_PROP = "HIS TN5250 Definitions"
CONST COMPUTER_PRINT_PROP = "HIS Print Sessions Defined"
CONST COMPUTER_HIP_PROP = "HIS HIP Applications"
CONST COMPUTER_SUBDOMAIN_PROP = "HIS Subdomain"
CONST COMPUTER_ROLE_PROP = "HIS Role"
CONST COMPUTER_LURESYNC_PROP = "HIS LU Resync"
CONST COMPUTER_IPRESYNC_PROP = "HIS IP Resync"
CONST COMPUTER_SI_PROP = "HIS Session Integrator"
CONST COMPUTER_DI_PROP = "HIS Data Integration"
CONST COMPUTER_MI_PROP = "HIS Message Integration"
CONST COMPUTER_WIP_PROP = "HIS WIP"

Dim oDiscDataComputer
Dim oCollectionComputer
Dim oInstanceComputer

Dim colDomains
Dim objDomain

Dim objServer

' =============================================================

ScriptContext.Echo (strIndent &amp; "Set computer object attributes")

' Create discovery object and set properties

Set oDiscDataComputer = ScriptContext.CreateDiscoveryData
Set oCollectionComputer = oDiscDataComputer.CreateCollection

With oCollectionComputer
.ClassID = "Computer"
.AddScopeFilter COMPUTER_COMPUTER_PROP, ScriptContext.TargetComputerIdentity
.AddScopeProperty COMPUTER_CONNECTIONS_PROP
.AddScopeProperty COMPUTER_PRINT_PROP
.AddScopeProperty COMPUTER_TN3_PROP
.AddScopeProperty COMPUTER_TN5_PROP
.AddScopeProperty COMPUTER_HIP_PROP
.AddScopeProperty COMPUTER_SUBDOMAIN_PROP
.AddScopeProperty COMPUTER_ROLE_PROP
.AddScopeProperty COMPUTER_LURESYNC_PROP
.AddScopeProperty COMPUTER_IPRESYNC_PROP
.AddScopeProperty COMPUTER_SI_PROP
.AddScopeProperty COMPUTER_DI_PROP
.AddScopeProperty COMPUTER_MI_PROP
.AddScopeProperty COMPUTER_WIP_PROP
End With

Set oInstanceComputer = oCollectionComputer.CreateInstance

With oInstanceComputer
.AddProperty COMPUTER_CONNECTIONS_PROP, intMonitoredConnections
.AddProperty COMPUTER_PRINT_PROP, intPrintSessions
.AddProperty COMPUTER_TN3_PROP, intTN3Sessions
.AddProperty COMPUTER_TN5_PROP, intTN5Defs
.AddProperty COMPUTER_HIP_PROP, intHIPApps
.AddProperty COMPUTER_SUBDOMAIN_PROP, strDomain
.AddProperty COMPUTER_ROLE_PROP, strRole
.AddProperty COMPUTER_LURESYNC_PROP, intLUResync
.AddProperty COMPUTER_IPRESYNC_PROP, intIPResync
.AddProperty COMPUTER_SI_PROP, intSI
.AddProperty COMPUTER_DI_PROP, intDI
.AddProperty COMPUTER_MI_PROP, intMI
.AddProperty COMPUTER_WIP_PROP, intWIP
End with

ScriptContext.Echo (strIndent2 &amp; COMPUTER_CONNECTIONS_PROP &amp; ": " &amp; intMonitoredConnections)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_PRINT_PROP &amp; ": " &amp; intPrintSessions)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_TN3_PROP &amp; ": " &amp; intTN3Sessions)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_TN5_PROP &amp; ": " &amp; intTN5Defs)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_HIP_PROP &amp; ": " &amp; intHIPApps)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_SUBDOMAIN_PROP &amp; ": " &amp; strDomain)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_ROLE_PROP &amp; ": " &amp; strRole)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_LURESYNC_PROP &amp; ": " &amp; intLUResync)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_IPRESYNC_PROP &amp; ": " &amp; intIPResync)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_SI_PROP &amp; ": " &amp; intSI)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_DI_PROP &amp; ": " &amp; intDI)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_MI_PROP &amp; ": " &amp; intMI)
ScriptContext.Echo (strIndent2 &amp; COMPUTER_WIP_PROP &amp; ": " &amp; intWIP)

oCollectionComputer.AddInstance oInstanceComputer
oDiscDataComputer.AddCollection oCollectionComputer
ScriptContext.Submit oDiscDataComputer

End Sub

Function FindService(strServiceName)

' NOTE: the WMI WQL "LIKE" clause is not used in the query to obtain Win32 services
' because it is not supported on Win2K Server. Instead the full set of services must be
' obtained and enumerated to check for the appropriate service name.

if ScriptContext.isTargetAgentless then
Set Service = Locator.ConnectServer(ScriptContext.TargetNetBiosComputer, "root\cimv2")
else
Set Service = Locator.ConnectServer(".", "root\cimv2")
end if

set colWin32Services = Service.ExecQuery("select * from Win32_Service",, 0)

for each objWin32Service in colWin32Services
if objWin32Service.DisplayName = strServiceName then
FindService = 1
Exit Function
end if
next
FindService = 0
Exit Function

End function

Function FindFeature(strFeatureName)

' FindFeature
'
' Query MSI to determine if the specified HIS feature name is installed or advertised.
' Return 1 if true, 0 if false

dim installer, feature, features, state

set installer = CreateObject("WindowsInstaller.Installer")
set features = installer.Features(HIS_PACKAGE_CODE)

for each feature in features
if feature = strFeatureName then
state = installer.FeatureState(HIS_PACKAGE_CODE, feature)
if state = msiInstallStateAdvertised or state = msiInstallStateLocal or state = msiInstallStateSource then
FindFeature = 1
else
FindFeature = 0
end if
Exit Function
end if
next

FindFeature = 0
Exit Function

End function</Script></Body>
<Language>VBScript</Language>
<Name>HIS 2006 Service Discovery</Name>
<Parameters>
<Parameter>
<Name>Monitor_Connections_with_Activation__By_Administrator</Name>
<Value>$Config/Parameters/Monitor_Connections_with_Activation__By_Administrator$</Value>
</Parameter>
<Parameter>
<Name>Monitor_Connections_with_Activation__On_Server_Startup</Name>
<Value>$Config/Parameters/Monitor_Connections_with_Activation__On_Server_Startup$</Value>
</Parameter>
<Parameter>
<Name>Monitor_Connections_with_Activation__On_demand</Name>
<Value>$Config/Parameters/Monitor_Connections_with_Activation__On_demand$</Value>
</Parameter>
</Parameters>
<ManagementPackId>[Microsoft.HostIntegrationServer.2006,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>