Managed Server for WebLogic 11gR1 application server on Windows

Microsoft.JEE.WebLogic.11gR1.Windows.Managed.Server.Discovery (Discovery)

Discovers WebLogic application servers (instances of managed servers) on Windows.

Knowledge Base article:

Summary

The managed server discovery locates managed servers for WebLogic application server. After they have been discovered, a monitoring template should be applied to enable monitoring.

Element properties:

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

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships 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.Managed.Server.Discovery" Target="Microsoft.JEE.WebLogic.11gR1.Windows.Domain" Remotable="true" Enabled="true">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.JEE.WebLogic.11gR1.Windows.Managed.Server"/>
<DiscoveryRelationship TypeID="Microsoft.JEE.WebLogic.11gR1.WindowsComputerContainsServer.Relationship"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.JEE.WebLogic.11gR1.Managed.Server.Discover.vbs</ScriptName>
<Arguments>$MPElement$ $MPElement[Name='Microsoft.JEE.WebLogic.11gR1.Windows.Managed.Server']$ $MPElement[Name='Microsoft.JEE.WebLogic.11gR1.WindowsComputerContainsServer.Relationship']$ $Target/Id$ $Target/Host/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ --DomainPath=$Target/Property[Type="WebLogic!Microsoft.JEE.WebLogic.Windows.Domain"]/DomainPath$</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: Nov 9th, 2010
'
' This Script is to be incoporated into the WebLogic JEE MP.
' This script will discover instances of a WebLogic application
' server.
SetLocale("en-us")
'''
''' Simple Class defining a WebLogic Server
'''
CLASS WebLogicServer
PUBLIC ServerName
PUBLIC ServerPath
PUBLIC Version
PUBLIC HTTPPort
PUBLIC HTTPSPort
PUBLIC IsAdminServer
END CLASS
'''
''' Constants for use in this script
'''
CONST WEBLOGIC_DISCOVERY_SCRIPT_NAME = "WebLogicDiscovery.vbs"
'''
''' Given a domain path, parse the domain config.xml file for servers
'''
PUBLIC FUNCTION FindWebLogicServers(oAPI, userSuppliedFso, domainPath, userSuppliedXmlDom)
DIM objXMLDoc, objXmlNodes, objServer, strDomainPath, returnValue
DIM objVersionNode, objAdminNode, AdminName, DomainVersion
DIM strFilePath, strFileName
SET returnValue = CreateObject("Scripting.Dictionary")
If userSuppliedFso Is Nothing Then
Set fso = CreateObject("Scripting.FileSystemObject")
Else
Set fso = userSuppliedFso
End If
strFilePath = domainPath + "\config\"
strFileName = "config.xml"
If (Not fso.FileExists(strFilePath &amp; strFileName)) Or isFileTooBig(fso, strFilePath, strFileName) Then
Set FindWebLogicServers = returnValue
LogErrorFileNotFound oAPI, WEBLOGIC_DISCOVERY_SCRIPT_NAME, strFilePath &amp; strFileName
Exit Function
End If
IF userSuppliedXmlDom IS NOTHING THEN
SET objXMLDoc = CreateObject("Microsoft.XMLDOM")
ELSE
SET objXMLDoc = userSuppliedXmlDom
END IF
objXMLDoc.async = FALSE
objXMLDoc.load(strFilePath &amp; strFileName)
SET objXmlNodes = objXMLDoc.SelectNodes("/domain/server")
SET objAdminNode = objXMLDoc.SelectSingleNode("/domain/admin-server-name")
AdminName = "NO ADMIN SERVER"
if NOT (objAdminNode IS NOTHING) THEN
AdminName = objAdminNode.text
END IF
SET objVersionNode = objXMLDoc.SelectSingleNode("/domain/domain-version")
DomainVersion = "NOT FOUND"
if NOT (objVersionNode IS NOTHING) THEN
DomainVersion = objVersionNode.text
END IF
DIM objNameNode, objHTTPPortNode, objHTTPSPortNode, objHTTPSEnabledNode
FOR EACH objServer IN objXmlNodes
IF NOT (objServer IS NOTHING) THEN
DIM objWebLogicServer
SET objWebLogicServer = NEW WebLogicServer
SET objNameNode = objServer.SelectSingleNode("name")
objWebLogicServer.ServerName = objNameNode.text
objWebLogicServer.ServerPath = domainPath &amp; "\servers\" &amp; objWebLogicServer.ServerName
'
' If the folder does not exist within this weblogic installation folder
' structure it is assumed that the Server is part of a cluster and
' does not belong to this installation. We do not include it as a
' discovered instance.
'
IF fso.FolderExists(objWebLogicServer.ServerPath) THEN
objWebLogicServer.Version = DomainVersion
SET objHTTPPortNode = objServer.SelectSingleNode("listen-port")
objWebLogicServer.HTTPPort = ""
if NOT (objHTTPPortNode IS NOTHING) THEN
objWebLogicServer.HTTPPort = objHTTPPortNode.text
END IF
SET objHTTPSEnabledNode = objServer.SelectSingleNode("ssl/enabled")
objWebLogicServer.HTTPSPort = ""
IF NOT (objHTTPSEnabledNode IS NOTHING) THEN
IF objHTTPSEnabledNode.text = "true" THEN
SET objHTTPSPortNode = objServer.SelectSingleNode("ssl/listen-port")
IF NOT (objHTTPSPortNode IS NOTHING) THEN
objWebLogicServer.HTTPSPort = objHTTPSPortNode.text
ELSE
objWebLogicServer.HTTPSPort = "7002"
END IF
END IF
END IF
objWebLogicServer.IsAdminServer = FALSE
IF objWebLogicServer.ServerName = AdminName THEN
objWebLogicServer.IsAdminServer = TRUE
END IF
'''
''' Sometimes the admin server for the default domain has no specified HTTP port
''' If that is the case, dfeault to port 7001
'''
IF objWebLogicServer.HTTPPort = "" AND objWebLogicServer.IsAdminServer THEN
objWebLogicServer.HTTPPort = "7001"
END IF
returnValue.Add objWebLogicServer.ServerName, objWebLogicServer
END IF
END IF
NEXT
SET FindWebLogicServers = returnValue
END FUNCTION
'''
''' Add the properties needed to crate a WebLogic server instance in OpsMgr
'''
PUBLIC FUNCTION AddProperties(oDiscoveryData, ClassGuid, ReleationGuid, TargetComputer, server)
SET oInst = oDiscoveryData.CreateClassInstance(ClassGuid)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/Id$", server.ServerPath)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/HostName$", TargetComputer)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/HttpPort$", server.HTTPPort)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/HttpsPort$", server.HTTPSPort)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/Version$", server.Version)
CALL oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/DiskPath$", server.ServerPath)
CALL oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "WebLogic|" &amp; server.ServerPath)
IF server.IsAdminServer THEN
CALL oInst.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Server']/ServerType$", "Admin")
ELSE
CALL oInst.AddProperty("$MPElement[Name='WebLogic!Microsoft.JEE.WebLogic.Server']/ServerType$", "Managed")
END IF
CALL oDiscoveryData.AddInstance(oInst)
SET oComputer = oDiscoveryData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.Computer']$")
CALL oComputer.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
SET oInst2 = oDiscoveryData.CreateClassInstance(ClassGuid)
CALL oInst2.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/Id$", server.ServerPath)
CALL oInst2.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/HostName$", TargetComputer)
SET oContains = oDiscoveryData.CreateRelationShipInstance(ReleationGuid)
oContains.Source = oComputer
oContains.Target = oInst2
CALL oDiscoveryData.AddInstance(oContains)
Set oHealthServiceInstance = oDiscoveryData.CreateClassInstance( "$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$" )
call oHealthServiceInstance.AddProperty ("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer )
set oHsCnRel = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oHsCnRel.Source = oHealthServiceInstance
oHsCnRel.Target = oInst2
call oDiscoveryData.AddInstance(oHsCnRel)
END FUNCTION
'''
''' Create instances in OpsMgr for all found instances of WebLogic managed servers
'''
PUBLIC FUNCTION ReturnWebLogicManagedServers(oAPI, userSuppliedXmlDom, SourceId, ClassGuid, ReleationGuid, ManagedEntityId, TargetComputer, DomainPath, userSuppliedFso)
DIM server, servers, oDiscoveryData
SET oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
SET servers = FindWebLogicServers(oAPI, userSuppliedFso, DomainPath, userSuppliedXmlDom)
FOR EACH server IN servers.Keys
IF NOT servers.item(server).IsAdminServer THEN
AddProperties oDiscoveryData, ClassGuid, ReleationGuid, TargetComputer, servers.item(server)
END IF
NEXT
CALL oAPI.Return(oDiscoveryData)
END FUNCTION
'''
''' Create instances in OpsMgr for all found instances of WebLogic admin servers
'''
PUBLIC FUNCTION ReturnWebLogicAdminServer(oAPI, userSuppliedXmlDom, SourceId, ClassGuid, ReleationGuid, ManagedEntityId, TargetComputer, DomainPath, userSuppliedFso)
DIM server, servers, oDiscoveryData
SET oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
SET servers = FindWebLogicServers(oAPI, userSuppliedFso, DomainPath, userSuppliedXmlDom)
FOR EACH server IN servers.Keys
IF servers.item(server).IsAdminServer THEN
AddProperties oDiscoveryData, ClassGuid, ReleationGuid, TargetComputer, servers.item(server)
END IF
NEXT
CALL oAPI.Return(oDiscoveryData)
END FUNCTION

Dim oArgs, oAPI, strDomainPath, strSourceId, strClassGuid, strRelationGuid, strManagedEntityId, strTargetComputer

Set oArgs = WScript.Arguments
if oArgs.Count &lt; 6 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 domain path). Ideally domain 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")
'

strKey = "--DomainPath="
strDomainPath = "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
strDomainPath = Mid(strCommandLineArg, InStrRev(strCommandLineArg, strKey) + Len(strKey))
END IF

strSourceId = oArgs(0)
strClassGuid = oArgs(1)
strRelationGuid = oArgs(2)
strManagedEntityId = oArgs(3)
strTargetComputer = oArgs(4)

Set oAPI = CreateObject("MOM.ScriptAPI")
ReturnWebLogicManagedServers oAPI, NOTHING, strSourceId, strClassGuid, strRelationGuid, strManagedEntityId, strTargetComputer, strDomainPath, NOTHING
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>