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 & "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 <> "Running" then
ScriptContext.Echo(strIndent & "SNABase state: " & objService.State)
CheckServices=False
else
set objService = Service.Get("Win32_Service.Name='MngAgent'")
if objService.State <> "Running" then
ScriptContext.Echo(strIndent & "MngAgent state: " & objService.State)
CheckServices=False
else
ScriptContext.Echo(strIndent & "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.
' 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:\\" & ScriptContext.TargetNetBiosComputer & "\root\default:StdRegProv")
else
set oRegProvider=GetObject("winmgmts:\\.\root\default:StdRegProv")
end if
ScriptContext.Echo (strIndent & "Checking for opt-out keys")
Case HIS_TN3_OPTOUT_KEY
bDisableTN3Monitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_TN5_OPTOUT_KEY
bDisableTN5Monitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_PRINT_OPTOUT_KEY
bDisablePrintMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_HIP_OPTOUT_KEY
bDisableHIPMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_LU62RESYNC_OPTOUT_KEY
bDisableLU62ResyncMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_IPRESYNC_OPTOUT_KEY
bDisableIPResyncMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_SI_OPTOUT_KEY
bDisableSIMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_MI_OPTOUT_KEY
bDisableMIMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_DI_OPTOUT_KEY
bDisableDIMonitoring = TRUE
ScriptContext.Echo (strIndent2 & strValue)
Case HIS_WIP_OPTOUT_KEY
bDisableWIPMonitoring = TRUE
ScriptContext.Echo (strIndent2 & 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 & "Checking SNA setup keys")
if bSNAService then
ScriptContext.Echo (strIndent2 & "SNA Service present")
else
ScriptContext.Echo (strIndent2 & "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.
ScriptContext.Echo (strIndent & "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 & "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 & "Monitor: On Server Startup = " & bMonitorOss & _
", On demand = " & bMonitorOD & _
", On By Administrator = " & 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='" & ScriptContext.TargetNetbiosComputer & "'} 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
' 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
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 > 0 add the
' TN3 state monitoring component in the HIS Svcs role.
if bDisableTN3Monitoring then
ScriptContext.Echo (strIndent2 & "TN3270 service = False, opt-out key present")
elseif NOT bSNAService then
ScriptContext.Echo (strIndent2 & "TN3270 service = False, SNA Service not present")
else
' Get TN3270 session count
set colSessions = Service.ExecQuery("select * FROM MsSna_TN3270Session where Service='" & ScriptContext.TargetNetbiosComputer & "'",, 0)
if colSessions.Count = 0 then
ScriptContext.Echo (strIndent2 & "TN3270 service = False, no sessions defined on this server")
else
intTN3Sessions = colSessions.Count
ScriptContext.Echo (strIndent2 & "TN3270 service = True, number of TN3270 sessions defined: " & intTN3Sessions)
oInstanceSNASvcs.AddComponent HIS_TN3_COMP
' TN5250 Discovery
' Get the set of TN5250 definitions for this HIS server, and if > 0 add the
' TN5 state monitoring component in the HIS Svcs role.
'
if (bDisableTN5Monitoring) then
ScriptContext.Echo (strIndent2 & "TN5250 service = False, opt-out key present")
elseif NOT bSNAService then
ScriptContext.Echo (strIndent2 & "TN5250 service = False, SNA Service not present")
else
' Get TN5250 definition count
set colTN5Defs = Service.ExecQuery("select * FROM MsSna_TN5250Definition where Service='" & ScriptContext.TargetNetbiosComputer & "'",, 0)
if colTN5Defs.Count = 0 then
ScriptContext.Echo (strIndent2 & "TN5250 service = False, no definitions on this server")
else
intTN5Defs = colTN5Defs.Count
ScriptContext.Echo (strIndent2 & "TN5250 service = True, number of TN5250 definitions: " & intTN5Defs)
oInstanceSNASvcs.AddComponent HIS_TN5_COMP
' Print Discovery
' Get the set of print sessions for this HIS server, and if > 0 add the
' Print state monitoring component in the HIS Svcs role.
'
if (bDisablePrintMonitoring) then
ScriptContext.Echo (strIndent2 & "Print service = False, opt-out key present")
elseif NOT bSNAService then
ScriptContext.Echo (strIndent2 & "Print service = False, SNA Service not present")
else
' Get Print session count
set colSessions = Service.ExecQuery("select * FROM MsSna_PrintSession where Service='" & ScriptContext.TargetNetbiosComputer & "'",, 0)
if colSessions.Count = 0 then
ScriptContext.Echo (strIndent2 & "Print service = False, no sessions defined on this server")
else
intPrintSessions = colSessions.Count
ScriptContext.Echo (strIndent2 & "Print service = True, number of print sessions defined: " & intPrintSessions)
oInstanceSNASvcs.AddComponent HIS_PRINT_COMP
' 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 > 0 add the LUResync state monitoring component in the HIS Svcs role.
'
if (bDisableLU62ResyncMonitoring) then
ScriptContext.Echo (strIndent2 & "LU 6.2 resync service = False, opt-out key present")
elseif NOT bSNAService then
ScriptContext.Echo (strIndent2 & "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='" & ScriptContext.TargetNetbiosComputer & "'",, 0)
if colLocalAPPCLUs.Count = 0 then
ScriptContext.Echo(strIndent2 & "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 & "LU 6.2 Resync service = False, no remote resync LUs configured in the subdomain")
else
set colServerConnections = Service.ExecQuery("ASSOCIATORS OF {MsSna_Server.Name='" & ScriptContext.TargetNetbiosComputer & "'} 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 & "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 & "LU 6.2 resync service = True, local resync LUs: " & colLocalAPPCLUs.Count & ", remote resync LUs: " & intRemoteResyncLUs)
' 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=" & chr(34) & ScriptContext.TargetNetbiosComputer & chr(34))
strRole = objServer.RoleName
else
strDomain = "N/A"
strRole = "N/A"
end if
ScriptContext.Echo(strIndent2 & "Role: " & strRole)
oInstanceSNASvcs.AddProperty HIS_ROLE_PROP, strRole
ScriptContext.Echo(strIndent2 & "Subdomain: " & 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 & "IP resync service = False, opt-out key present")
else
intIPResync = FindService(HIS_IPRESYNC_PATTERN)
if intIPResync = 0 then
ScriptContext.Echo (strIndent2 & "IP Resync service = False, no service present")
else
ScriptContext.Echo (strIndent2 & "IP Resync service = True")
oInstanceSNASvcs.AddComponent HIS_IPRESYNC_COMP
end if
' 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 & "SI service = False, opt-out key present")
elseif NOT bSNAService then
ScriptContext.Echo (strIndent2 & "SI service = False, SNA Service not present")
else
intSI = FindService(HIS_SI_PATTERN)
if intSI = 0 then
ScriptContext.Echo (strIndent2 & "Session Integrator service = False, no service present")
else
ScriptContext.Echo (strIndent2 & "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 & "Message Integration service = False, opt-out key present")
else
intMI = FindService(HIS_MI_PATTERN)
if intMI = 0 then
ScriptContext.Echo (strIndent2 & "Message Integration service = False, no service present")
else
ScriptContext.Echo (strIndent2 & "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 & "Data Integration = False, opt-out key present")
else
intDI = FindFeature(HIS_DI_FEATURE)
if intDI = 0 then
ScriptContext.Echo (strIndent2 & "Data Integration = False, feature not present")
else
ScriptContext.Echo (strIndent2 & "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 & "WIP = False, opt-out key present")
else
intWIP = FindFeature(HIS_WIP_FEATURE)
if intWIP = 0 then
ScriptContext.Echo (strIndent2 & "WIP = False, feature not present")
else
ScriptContext.Echo (strIndent2 & "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
' HIP Discovery
' Pattern match instances of root\cimv2\Win32_Service that start with "HIPService:".
' If > 0, create the HIS HIP role and add Service, Listeners, and APP state components
' for each instance.
ScriptContext.Echo (strIndent & "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 & "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 & objWin32Service.Name & " = 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
' 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.
ScriptContext.Echo (strIndent2 & COMPUTER_CONNECTIONS_PROP & ": " & intMonitoredConnections)
ScriptContext.Echo (strIndent2 & COMPUTER_PRINT_PROP & ": " & intPrintSessions)
ScriptContext.Echo (strIndent2 & COMPUTER_TN3_PROP & ": " & intTN3Sessions)
ScriptContext.Echo (strIndent2 & COMPUTER_TN5_PROP & ": " & intTN5Defs)
ScriptContext.Echo (strIndent2 & COMPUTER_HIP_PROP & ": " & intHIPApps)
ScriptContext.Echo (strIndent2 & COMPUTER_SUBDOMAIN_PROP & ": " & strDomain)
ScriptContext.Echo (strIndent2 & COMPUTER_ROLE_PROP & ": " & strRole)
ScriptContext.Echo (strIndent2 & COMPUTER_LURESYNC_PROP & ": " & intLUResync)
ScriptContext.Echo (strIndent2 & COMPUTER_IPRESYNC_PROP & ": " & intIPResync)
ScriptContext.Echo (strIndent2 & COMPUTER_SI_PROP & ": " & intSI)
ScriptContext.Echo (strIndent2 & COMPUTER_DI_PROP & ": " & intDI)
ScriptContext.Echo (strIndent2 & COMPUTER_MI_PROP & ": " & intMI)
ScriptContext.Echo (strIndent2 & COMPUTER_WIP_PROP & ": " & intWIP)
' 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