Domain for WebLogic 11gR1 application server on Windows

Microsoft.JEE.WebLogic.11gR1.Windows.Domain.Discovery (Discovery)

Discovers WebLogic application server domains on Windows.

Knowledge Base article:

Summary

The domain discovery locates the domains for a WebLogic Installation.

Element properties:

TargetMicrosoft.JEE.WebLogic.11gR1.Windows.Installation
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.JEE.WebLogic.11gR1.Windows.Domain.Discovery" Target="Microsoft.JEE.WebLogic.11gR1.Windows.Installation" Remotable="true" Enabled="true">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.JEE.WebLogic.11gR1.Windows.Domain"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.JEE.WebLogic.11gR1.Domain.Discover.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ "$MPElement[Name='Microsoft.JEE.WebLogic.11gR1.Windows.Domain']$" $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ --InstallPath=$Target/Property[Type="WebLogic!Microsoft.JEE.WebLogic.Windows.Installation"]/InstallPath$</Arguments>
<ScriptBody><Script>
''' Copyright (c) Microsoft Corporation. All rights reserved.
'''
''' Date Created: Mar 21st, 2011
'
SetLocale("en-us")
'' Check if a file is too big (larger than or equal to 100 MB).
'' Return true if too big, else return false.
'' If a file does not exist, return false.
FUNCTION isFileTooBig(userSuppliedFSO, filePath, fileName)
''Set the maximum file size to 100MB
const maxFileSize = 104857600
Dim strFile, myFSO
isFileTooBig = false
strFile = filePath &amp; fileName
IF userSuppliedFSO is Nothing THEN
SET myFSO = CreateObject("Scripting.FileSystemObject")
ELSE
SET myFSO = userSuppliedFSO
END IF
IF myFSO.FileExists(strFile) = true then
'' Get a File object from a file system
set objFile = myFSO.GetFile(strFile)
'' Get the file size
fileSize = objFile.Size
IF fileSize &gt;= maxFileSize THEN
isFileTooBig = true
END IF
END IF
END FUNCTION
'
' Method to parse out a command line arguments
' The arguments can be
'
'
Function ParseOutCommandLineArg(cmdLine, arg)
Dim done
Dim pos
Dim quoted
Dim startpos
Dim gotKey
gotkey = false
quoted = false
pos = 1
startpos = 1
done = false
While not done
Select Case mid ( cmdLine , pos , 1 )
Case ""&amp;chr(34)
If gotkey and quoted Then
ParseOutCommandLineArg = mid(cmdLine,startpos,pos-startpos)
done = true
else
quoted = not quoted
End If
startpos = pos+1
Case "="
If arg = mid(cmdline,startpos,pos-startpos) Then
startpos = pos+1
gotkey = true
End If
Case " "
If gotkey Then
If not quoted Then
ParseOutCommandLineArg = mid(cmdLine,startpos,pos-startpos)
done = true
End If
Else
If arg = mid(cmdline,startpos,pos-startpos) Then
startpos = pos+1
gotkey = true
End If
End If
If not quoted Then
startpos = pos+1
End If
End Select
pos = pos + 1
if not done then
if pos &gt;len(cmdLine) Then
If gotkey Then
If not quoted Then
ParseOutCommandLineArg = mid(cmdLine,startpos,pos-startpos)
done = true
End If
End If
done = true
End If
End If
Wend
End Function
'
' Method to log an error to the windows event log
'
Function LogError(oAPI, scriptName, description)
Call oAPI.LogScriptEvent(scriptName, 100, 1, description)
End Function
'
' Method to log an error when failing to find a file
'
Function LogErrorFileNotFound(oAPI, scriptName, fileName)
LogError oAPI, scriptName, "Could not find expected configuration file: " &amp; fileName
End Function
'
' Method to log an error when failing to find a folder
'
Function LogErrorFolderNotFound(oAPI, scriptName, folderName)
LogError oAPI, scriptName, "Could not find expected folder: " &amp; folderName
End Function
'
' Method to log an error when failing to parse a file
'
Function LogErrorParsingFile(oAPI, scriptName, fileName)
LogError oAPI, scriptName, "Failed to parse configuration file: " &amp; fileName
End Function
'
' Method to log an error when failing to commuincate over HTTP
'
Function LogErrorHTTP(oAPI, scriptName, url, description, errorNumber)
LogError oAPI, scriptName, "HTTP commucation failed with: " &amp; url &amp; " - " &amp; description &amp; " - " &amp; CStr(errorNumber)
End Function

'' Copyright (c) Microsoft Corporation. All rights reserved.
'''
''' Filters out discovered instances that do not match the specified major version
''' Returns true if the desired version is the Major version.
'''
''' i.e. if desired major version is 6 and given 6.0.22, the result is true.
''' if desired major version is 6 and given 5.0.12, the result is false
'''
PUBLIC FUNCTION FilterVersion(strDesiredMajorVersion, strActualVersion)
FilterVersion = FALSE
' Filter out specific version.
' Need to be careful that the given filter is not longer
' than the string to be filtered, otherwise just make sure that
' what is at the beginning of one string matches the filter
IF (0 &lt; Len(strDesiredMajorVersion)) AND (Len(strDesiredMajorVersion) &lt;= Len(strActualVersion)) THEN
IF (0 = StrComp(strDesiredMajorVersion, Left(strActualVersion, Len(strDesiredMajorVersion)))) THEN
FilterVersion = TRUE
END IF
END IF
END FUNCTION

''' Copyright (c) Microsoft Corporation. All rights reserved.
''' Date Created: November 8th, 2010
'''
''' This script will be incorporated into the WebLogic JEE MP.
''' This script discovers domains of an WebLogic application
''' server installation.
'''
''' (1) Find list of Domains
''' The domain discovery for 11g will parse the domain-registry.xml XML
''' file located in the installation root.
'''
''' The domain discovery for 10gr3 will parse the a text file located at
''' &lt;install root&gt;\wlserver_10.3\common\nodemanager\nodemanager.domains
'''
''' (2)
''' For domain specified, locate the domain (path found in step 1) and then
''' parse the configuration xml file located at &lt;domain&gt;\config\config.xml
''' for domain name and domain version information
'''
SetLocale("en-us")
'''
''' Simple Class defining a WebLogic Domain
'''
CLASS WebLogicDomain
PUBLIC Level
PUBLIC ServicePackLevel
PUBLIC PatchLevel
'''
PUBLIC DomainName
PUBLIC DomainPath
PUBLIC DomainVersion
END CLASS
'''
''' Constants for use in this script
'''
CONST WEBLOGIC_DOMAINS_SCRIPT_NAME = "WebLogicDomains.vbs"
'''
''' (a) If WebLogic 11g, parse the domain-registry.xml in the base directory
''' (b) If WebLogic 10gr3, parse the nodemanager from the text file:
''' wlserver_10.3\common\nodemanager\nodemanager.domains
PUBLIC FUNCTION FindWebLogicDomains(oAPI, installationPath, userSuppliedXmlDom, userSuppliedFso)
DIM returnValue, fso
DIM strFilePath, strFileName
If userSuppliedFso Is Nothing Then
Set fso = CreateObject("Scripting.FileSystemObject")
Else
Set fso = userSuppliedFso
End If
strFilePath = installationPath &amp; "\"
strFileName = "domain-registry.xml"
If isFileTooBig(fso, strFilePath, strFileName) Then
Set FindWebLogicDomains = CreateObject("Scripting.Dictionary")
Exit Function
End If
IF fso.FileExists(strFilePath &amp; strFileName) THEN
SET returnValue = ParseRegistryXml(installationPath, userSuppliedXmlDom)
ELSE
SET returnValue = ParseNodemanagerDomainsFile(installationPath, fso)
END IF
GetNameAndVersionForEachDomain oAPI, returnValue, userSuppliedXmlDom, fso
SET FindWebLogicDomains = returnValue
END FUNCTION
'''
''' Given a list of paths to domains, for each domain look in the domain's
''' config/config.xml for both the name &amp; domain-version tags
'''
PUBLIC FUNCTION GetNameAndVersionForEachDomain(oAPI, domains, userSuppliedXmlDom, userSuppliedFso)
DIM domain
Dim fso, strFilePath, strFileName
FOR EACH domain in domains.keys
DIM objXMLDoc, objXmlNode
IF userSuppliedXmlDom IS NOTHING THEN
SET objXMLDoc = CreateObject("Microsoft.XMLDOM")
ELSE
SET objXMLDoc = userSuppliedXmlDom
END IF
objXMLDoc.async = FALSE
objXMLDoc.async = FALSE
If userSuppliedFso Is Nothing Then
Set fso = CreateObject("Scripting.FileSystemObject")
Else
Set fso = userSuppliedFso
End If
strFilePath = domains.Item(domain).DomainPath + "\config\"
strFileName = "config.xml"
IF fso.FileExists(strFilePath &amp; strFileName) AND (NOT isFileTooBig(fso, strFilePath, strFileName)) THEN
objXMLDoc.load(strFilePath &amp; strFileName)
SET objXmlNode = objXMLDoc.selectSingleNode("/domain/name")
DIM strDomainName
IF NOT (objXmlNode IS NOTHING) THEN
strDomainName = objXmlNode.text
domains.Item(domain).DomainName = strDomainName
END IF
SET objXmlNode = objXMLDoc.selectSingleNode("/domain/domain-version")
DIM strDomainVersion
IF NOT (objXmlNode IS NOTHING) THEN
strDomainVersion = objXmlNode.text
domains.Item(domain).DomainVersion = strDomainVersion
END IF
ELSE
LogErrorFileNotFound oAPI, WEBLOGIC_DOMAINS_SCRIPT_NAME, strFilePath &amp; strFileName
END IF
NEXT
END FUNCTION
'''
''' Oracle 11g stores the list of available domains in the base directory
''' in a XML file. Parse this to find the location of the available domains.
'''
PUBLIC FUNCTION ParseRegistryXml(installationPath, userSuppliedXmlDom)
DIM objXMLDoc, objXmlNodes, objXmlNode, strDomainPath, returnValue
SET returnValue = CreateObject("Scripting.Dictionary")
IF userSuppliedXmlDom IS NOTHING THEN
SET objXMLDoc = CreateObject("Microsoft.XMLDOM")
ELSE
SET objXMLDoc = userSuppliedXmlDom
END IF
objXMLDoc.async = FALSE
' The file size and existance of the domain-registry.xml has been already checked,
' so it is unnecessary to check again.
objXMLDoc.load(installationPath + "\domain-registry.xml")
SET objXmlNodes = objXMLDoc.selectNodes("/domain-registry/domain")
DIM intCounter
FOR intCounter = 0 to objXmlNodes.length - 1
IF NOT (objXmlNodes.Item(intCounter) IS NOTHING) THEN
strDomainPath = objXmlNodes.Item(intCounter).GetAttribute("location")
DIM objWebLogicDomain
SET objWebLogicDomain = NEW WebLogicDomain
objWebLogicDomain.DomainPath = strDomainPath
returnValue.Add strDomainPath, objWebLogicDomain
END IF
NEXT
SET ParseRegistryXml = returnValue
END FUNCTION
'''
''' Oracle 10g stores the list of available domains in the text file
''' wlserver_10.3\common\nodemanager\nodemanager.domains
''' in the format &lt;domain name&gt;=&lt;domain path&gt;
''' Parse this to find the location of the available domains.
'''
PUBLIC FUNCTION ParseNodemanagerDomainsFile(installPath, objFso)
DIM strDomainsFileName, fso, returnValue
DIM strFilePath, strFileName
SET returnValue = CreateObject("Scripting.Dictionary")
If objFso Is Nothing Then
Set fso = CreateObject("Scripting.FileSystemObject")
Else
Set fso = objFso
End If
strFilePath = installPath &amp; "\wlserver_10.3\common\nodemanager\"
strFileName = "nodemanager.domains"
If isFileTooBig(fso, strFilePath, strFileName) Then
Set ParseNodemanagerDomainsFile = returnValue
Exit Function
End If
strDomainsFileName = strFilePath &amp; strFileName
IF fso.FileExists(strDomainsFileName) THEN
DIM objTextFile, strLine, arrParts, strPath
SET objTextFile = fso.OpenTextFile (strDomainsFileName, 1)
DO UNTIL objTextFile.AtEndOfStream
strLine = objTextFile.Readline
arrParts = Split(strLine, "=")
IF UBound(arrParts) = 1 THEN
IF InStr(arrParts(1), "\samples\") = 0 THEN
' The path in the file uses backslash (\) for quoting colon (:) and backslash (\)
' Remove those quoting characters.
strPath = Replace(arrParts(1), "\:", ":")
strPath = Replace(strPath, "\\", "\")
DIM objWebLogicDomain
SET objWebLogicDomain = NEW WebLogicDomain
objWebLogicDomain.DomainPath = strPath
returnValue.Add strPath, objWebLogicDomain
END IF
END IF
LOOP
ELSE
LogErrorFileNotFound oAPI, WEBLOGIC_DOMAINS_SCRIPT_NAME, strDomainsFileName
END IF
SET ParseNodemanagerDomainsFile = returnValue
END FUNCTION
'''
''' Create instances in OpsMgr for all found instances of WebLogic Domains
'''
PUBLIC FUNCTION ReturnWebLogicDomains(oAPI, SourceId, ManagedEntityId, DomainGuid, TargetComputer, InstallPath)
DIM oDiscoveryData, domains, domain, objDomain
SET oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
SET domains = FindWebLogicDomains(oAPI, InstallPath, NOTHING, NOTHING)
FOR EACH domain IN domains.Keys
SET objDomain = oDiscoveryData.CreateClassInstance(DomainGuid)
CALL objDomain.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
CALL objDomain.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Windows.Installation']/InstallPath$", InstallPath)
CALL objDomain.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Windows.Domain']/DomainName$", domains.item(domain).DomainName)
CALL objDomain.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Windows.Domain']/DomainPath$", domains.item(domain).DomainPath)
CALL objDomain.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Windows.Domain']/DomainVersion$", domains.item(domain).DomainVersion)
CALL objDomain.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", domains.item(domain).DomainName)
CALL oDiscoveryData.AddInstance(objDomain)
NEXT
Call oAPI.Return(oDiscoveryData)
END FUNCTION

Dim oArgs, oAPI, oReg, SourceId, ManagedEntityId, DomainGuid, TargetComputer, WebLogicVersionFilter, InstallPath

Set oArgs = WScript.Arguments
if oArgs.Count &lt; 5 Then
Wscript.Quit -1
End If

'
' Due to how to MPs interact with the VBscript, it is necessary to rebuild the last parameter
' (which is installation path). Ideally install path does not have spaces; however, if it does
' the argument passed into the vbscript is not seen as one path (i.e. "C:\Oracle WebLogic\11"), but instead
' as multiple arguments (i.e. "C:\Oracle" "WebLogic\11")
'
DIM strKey, strInstallPath
strKey = "--InstallPath="
strInstallPath = "SCRIPT COULD NOT PARSE INSTALLPATH"

DIM strCommandLineArg
strCommandLineArg = ""

DIM strArg
FOR EACH strArg IN oArgs
strCommandLineArg = strCommandLineArg &amp; " " &amp; strArg
NEXT

IF 0 &lt;&gt; InStrRev(strCommandLineArg , strKey) THEN
strInstallPath = Mid(strCommandLineArg, InStrRev(strCommandLineArg, strKey) + Len(strKey))
END IF

Set oAPI = CreateObject("MOM.ScriptAPI")
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
DomainGuid = oArgs(2)
TargetComputer = oArgs(3)

ReturnWebLogicDomains oAPI, SourceId, ManagedEntityId, DomainGuid, TargetComputer, strInstallPath
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>