Monitored WebLogic 10gR3 application server on Windows

Microsoft.JEE.WebLogic.10gR3.Monitored.Windows.Server.Discovery (Discovery)

Discovers monitored WebLogic application servers on Windows.

Knowledge Base article:

Summary

The monitored server discovery locates servers for WebLogic application server that have been marked for deep monitoring.

Element properties:

TargetMicrosoft.JEE.WebLogic.10gR3.Windows.Server
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.10gR3.Monitored.Windows.Server.Discovery" Target="Microsoft.JEE.WebLogic.10gR3.Windows.Server" Enabled="true" Remotable="true">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.JEE.WebLogic.10gR3.Monitored.Server"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.JEE.WebLogic.10gR3.Monitored.Discover.vbs</ScriptName>
<Arguments>$Target/ManagementGroup/Id$ $MPElement$ $Target/Id$ "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/Id$" "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/HostName$" "$Target/Property[Type="System!System.Entity"]/DisplayName$" $MPElement[Name='Microsoft.JEE.WebLogic.10gR3.Monitored.Server']$ "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/HttpPort$" "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/HttpsPort$" "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/Version$" "$Target/Property[Type="JEE!Microsoft.JEE.ApplicationServer.Instance"]/DiskPath$" "$Target/Property[Type="WebLogic!Microsoft.JEE.WebLogic.Server"]/ServerType$"</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.
''' Date Created: Oct 8th, 2010
'
SetLocale("en-us")
'''
''' Constants for Registry Access
'''
CONST HKEY_LOCAL_MACHINE = &amp;H80000002
CONST REGISTRY_PROP_ID = "ID"
CONST REGISTRY_PROP_PROTOCOL = "PROTOCOL"
CONST MONITORED_REGISTRY_KEY = "MonitoredJEEAppServers"
'''
''' Simple Class defining a combination of protocol and port
'''
CLASS ProtocolAndPort
PUBLIC Protocol
PUBLIC Port
END CLASS
'
' Check the registry and see if an entry have been created for the provided application server Id
'
FUNCTION AppServerEnabledForDeepManagement(userSuppliedMOMAPI, userSuppliedRegistry, groupId, appServerId, foundKey, foundProtocol)
IF userSuppliedRegistry Is Nothing THEN
SET objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
ELSE
SET objRegistry = userSuppliedRegistry
END IF
IF userSuppliedMOMAPI Is Nothing THEN
SET oApi = CreateObject("MOM.ScriptAPI")
ELSE
SET oApi = userSuppliedMOMAPI
END IF
GetBaseRegistryPath = oAPI.GetScriptStateKeyPath(groupId)
ManagedJEEAppServersPath = GetBaseRegistryPath &amp; "\" &amp; MONITORED_REGISTRY_KEY
AppServerEnabledForDeepManagement = false
objRegistry.EnumKey HKEY_LOCAL_MACHINE, ManagedJEEAppServersPath, arrSubKeys
IF NOT IsNull(arrSubKeys) THEN
DIM subKey
FOR EACH subKey In arrSubKeys
DIM fullSubKey
fullSubKey = ManagedJEEAppServersPath &amp; "\" &amp; subKey
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, fullSubKey, REGISTRY_PROP_ID, SavedAppServerId
IF SavedAppServerId = appServerId THEN
AppServerEnabledForDeepManagement = true
foundKey = fullSubKey
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, fullSubKey, REGISTRY_PROP_PROTOCOL, SavedProtocol
foundProtocol = SavedProtocol
END IF
NEXT
END IF
END FUNCTION
'
' Check if a given URL returns a valid response
'
FUNCTION URLCheck(objSvrHTTP, URL, username, password)
URLCheck = false
if objSvrHTTP is nothing then
Set objSvrHTTP = CreateObject("Microsoft.XmlHttp")
end if
ON ERROR RESUME NEXT
objSvrHTTP.open "GET", URL, false, username, password
IF Err.Number = 0 THEN
objSvrHTTP.send
IF Err.Number = 0 THEN
IF objSvrHTTP.status = 200 THEN
URLCheck = true
END IF
END IF
END IF
END FUNCTION
'
' Check if a we should use HTTPS or HTTP to communicate with BeanSpy
'
FUNCTION GetProtocolAndPort(objSvrHTTP, principalName, httpPort, httpsPort, userName, password)
SET result = NEW ProtocolAndPort
result.Protocol = "HTTPS"
result.Port = httpsPort
httpsok = false
IF httpsPort &lt;&gt; "" AND httpsPort &lt;&gt; "0" THEN
url = "https://" &amp; principalName &amp; ":" &amp; httpsPort &amp; "/BeanSpy/Stats"
httpsok = URLCheck(objSvrHTTP, url, userName, password)
END IF
IF httpsok = false THEN
httpok = false
IF httpPort &lt;&gt; "" AND httpPort &lt;&gt; "0" THEN
url = "http://" &amp; principalName &amp; ":" &amp; httpPort &amp; "/BeanSpy/Stats"
httpok = URLCheck(objSvrHTTP, url, userName, password)
END IF
IF httpok = true OR httpsPort = "" OR httpsPort = "0" THEN
result.Protocol = "HTTP"
result.Port = httpPort
END IF
END IF
SET GetProtocolAndPort = result
END FUNCTION

''' Copyright (c) Microsoft Corporation. All rights reserved.
''' Date Created: Oct 8th, 2010
'
SetLocale("en-us")
'
' Check the registry and see if an entry have been created for the provided application server Id
' If not, create discovery data for it
'
FUNCTION ReturnMonitoredInstance(userSuppliedMOMAPI, userSuppliedRegistry, groupId, sourceId, managedEntityId, appServerId, principalName, displayName, classType, httpPort, httpsPort, version, diskpath)
If userSuppliedMOMAPI Is Nothing Then
SET oApi = CreateObject("MOM.ScriptAPI")
Else
SET oApi = userSuppliedMOMAPI
End If
enabled = AppServerEnabledForDeepManagement(oApi, userSuppliedRegistry, groupId, appServerId, foundKey, foundProtocol)
set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceId, managedEntityId)
IF enabled = true THEN
set oInst = oDiscoveryData.CreateClassInstance(classType)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/Id$", appServerId)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Instance']/HostName$", principalName)
call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Monitored-" &amp; displayName)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/Id$", appServerId)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/HostName$", principalName)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/DiskPath$", diskpath)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/Version$", version)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/HttpPort$", httpPort)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/HttpsPort$", httpsPort)
port = httpsPort
IF foundProtocol = "HTTP" THEN
port = httpPort
END IF
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/Port$", port)
call oInst.AddProperty("$MPElement[Name='JEE!Microsoft.JEE.ApplicationServer.Monitored.Instance']/Protocol$", foundProtocol)
call oDiscoveryData.AddInstance(oInst)
END IF
CALL oAPI.Return(oDiscoveryData)
END FUNCTION

SET oArgs = WScript.Arguments

IF oArgs.Count &lt; 12 THEN
Wscript.Quit -1
END IF

DIM strGroupId, strSourceId, strManagedEntityId, strAppServerId, strPrincipalName, strDisplayName, strClassType, strHttpPort, strHttpsPort, strVersion, strDiskpath

strGroupId = oArgs(0)
strSourceId = oArgs(1)
strManagedEntityId = oArgs(2)
strAppServerId = oArgs(3)
strPrincipalName = oArgs(4)
strDisplayName = oArgs(5)
strClassType = oArgs(6)
strHttpPort = oArgs(7)
strHttpsPort = oArgs(8)
strVersion = oArgs(9)
strDiskpath = oArgs(10)

ReturnMonitoredInstance Nothing, Nothing, strGroupId, strSourceId, strManagedEntityId, strAppServerId, strPrincipalName, strDisplayName, strClassType, strHttpPort, strHttpsPort, strVersion, strDiskpath
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>