WebLogic application server process probe action

Microsoft.JEE.WebLogic.Windows.ServerProcessAvailabilityProbe (ProbeActionModuleType)

The probe action for checking if a WebLogic application server process is running on Windows.

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout In Seconds

Source Code:

<ProbeActionModuleType ID="Microsoft.JEE.WebLogic.Windows.ServerProcessAvailabilityProbe" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>IsWebLogicProcessRunning.vbs</ScriptName>
<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: July 6th, 2010
'
' This script is to be incorporated into the WebLogic JEE MP.
' This script will discover the running java process of an Oracle
' WebLogic Application server's server.
' This is captured and returned back to the MP's unit monitor as
' a property bag
'
SetLocale("en-us")
'''
''' Simple Class defining the Profile Discovery data
'''
Class ServerMonitoringInfo
Public ProcessCount
Public ServerPathList
Private Sub class_initialize()
Set ServerPathList = CreateObject("Scripting.Dictionary")
End Sub
End Class
Function GetProcessInformation(userSuppliedRegExp, userSuppliedWmi)
DIM objWMIService
If IsEmpty(userSuppliedWmi) Or userSuppliedWmi Is Nothing Then
Set objWMIService = GetObject("winmgmts:\root\cimv2")
Else
Set objWMIService = userSuppliedWmi
End If
' Get a list of the running processes
DIM collectionOfProcesses
SET collectionOfProcesses = objWMIService.ExecQuery("SELECT CommandLine FROM Win32_Process WHERE Name LIKE 'java%.exe'")
DIM objServerMonitoringInfo
SET objServerMonitoringInfo = new ServerMonitoringInfo
' Get the Process count. This is returned because something always must be returned
' or otherwise the workflow will terminate. Also, this is used to determine the ERROR
' condition when there are no java processes running
IF 0 = collectionOfProcesses.Count THEN
objServerMonitoringInfo.ProcessCount = 0
ELSE
' For the value returned, we need some way of indicating which server this content
' pertains to. This must be unique because there is not a way to have the XPATH match
' the appropriate piece of the property bag (i.e. the Name attribute should be unique).
DIM runningProcess
FOR EACH runningProcess IN collectionOfProcesses
IF CheckIfWebLogicProcess(userSuppliedRegExp, runningProcess.CommandLine) THEN
Dim strServerPath
strServerPath = ParseOutServerPathFromCommandLine(runningProcess.CommandLine)
IF NOT strServerPath = "" THEN
objServerMonitoringInfo.ProcessCount = 1 + objServerMonitoringInfo.ProcessCount
objServerMonitoringInfo.ServerPathList.Add strServerPath, "Running"
' NB: The 'Running' value is presently not used. A dynamicly sized array/vector is
' needed here and VBscript does not (easily) support this. Hence the use of a dictionary
END IF
END IF
NEXT
END IF
Set GetProcessInformation = objServerMonitoringInfo
End Function
'
' Method to verify if the given command line is a WebLogic process.
' This is done by verifying the string contains:
' weblogic.Server
'
Public Function CheckIfWebLogicProcess(userSuppliedRegExp, strInput)
DIM objIsWebLogicRegExp
IF userSuppliedRegExp is Nothing THEN
Set objIsWebLogicRegExp = New RegExp
objIsWebLogicRegExp.IgnoreCase = True
objIsWebLogicRegExp.Global = True
objIsWebLogicRegExp.Pattern = " weblogic\.Server"
ELSE
Set objIsWebLogicRegExp = userSuppliedRegExp
END IF
DIM objMatchesCol, boolIsWebLogic
boolIsWebLogic = false
Set objMatchesCol = objIsWebLogicRegExp.Execute(strInput)
IF (1 = objMatchesCol.Count) THEN
boolIsWebLogic = true
END IF
CheckIfWebLogicProcess = boolIsWebLogic
End Function
'
' Method for parsing out the server path name from the command line.
'
' We use the weblogic.system.BootIdentityFile property set in the arguments.
' This points to a file that is two level below the server path:
'
' -Dweblogic.system.BootIdentityFile=C:\Oracle\Middleware\user_projects\domains\base_domain\servers\Server-0\data\nodemanager\boot.properties
'
' In this example the server path is: C:\Oracle\Middleware\user_projects\domains\base_domain\servers\Server-0
'
Public Function ParseOutServerPathFromCommandLine(strInput)
DIM identityFile, serverPath, index
identityFile = ParseOutCommandLineArg(strInput, "-Dweblogic.system.BootIdentityFile")
serverPath = ""
IF NOT identityFile = "" THEN
' Remove the file name
index = InStrRev(identityFile, "\")
tmpStr = Left(identityFile, index - 1 )
' Remove the nodemanager directory
index = InStrRev(tmpStr, "\")
tmpStr = Left(tmpStr, index - 1 )
' Remove the data directory
index = InStrRev(tmpStr, "\")
tmpStr = Left(identityFile, index - 1 )
serverPath = tmpStr
END IF
ParseOutServerPathFromCommandLine = serverPath
End Function
'
' Return the discovered process information back to
'
Function ReturnProcessRunning(userSuppliedOpsMgrAPI, userSuppliedRegExp, userSuppliedWmi)
Dim objServerMonitoringInfo
Set objServerMonitoringInfo = GetProcessInformation(userSuppliedRegExp, userSuppliedWmi)
Dim oAPI, oBag
IF userSuppliedOpsMgrAPI is Nothing THEN
Set oAPI = CreateObject("MOM.ScriptAPI")
ELSE
Set oAPI = userSuppliedOpsMgrAPI
END IF
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue "Count", objServerMonitoringInfo.ProcessCount
'
' The key added here is the server path. As far as we know, this path cannot have spaces.
' These values must be in the keys so that the XPATH in the MP can find
' them in the attributes of the Property Bag.
'
FOR EACH entry IN objServerMonitoringInfo.ServerPathList.keys
oBag.AddValue entry, objServerMonitoringInfo.ServerPathList.Item(entry)
NEXT
Call oAPI.Return(oBag)
End Function

ReturnProcessRunning Nothing, Nothing, Nothing
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>