Installations for WebSphere 6.1 application server on Windows

Microsoft.JEE.WebSphere.6.1.Windows.Installation.Discovery (Discovery)

Discovers WebSphere 6.1 application server installations on Windows.

Knowledge Base article:

Summary

The installation discovery locates the default installation path of the WebSphere 6.1 application server.

Element properties:

TargetMicrosoft.Windows.Server.Computer
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.WebSphere.6.1.Windows.Installation.Discovery" Target="Windows!Microsoft.Windows.Server.Computer" Remotable="true" Enabled="true">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.JEE.WebSphere.6.1.Windows.Installation"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>Microsoft.JEE.WebSphere.Install.Discover.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $MPElement[Name='Microsoft.JEE.WebSphere.6.1.Windows.Installation']$ "6.1"</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: June 16th, 2010
'
' This Script is to be incoporated into the WebSphere JEE MP.
' This script will discover installations of WebSphere application
' servers. Information captured is the version and installation path.
' This is done by searching the registry for Software\IBM\WebSphere Application Server
' The script will also search Software\IBM\WebSphere Application Server Network Deployment and
' concatenate the arrays
SetLocale("en-us")
Const HKEY_USERS = &amp;H80000003
'''
''' Simple Class defining a WebSphere installation
'''
Class WSInstallation
Public InstallPath
Public MajorVersion
Public Version
End Class
'''
''' Return array of WSInstallation instances for all found installations of WebSphere
'''
Private Function WebSphereInstallations(oReg)
Dim asInstalls, ndInstalls, bothInstalls(), index
asInstalls = FindWebSphereRegistryKey(oReg, "\Software\IBM\WebSphere Application Server")
ndInstalls = FindWebSphereRegistryKey(oReg, "\Software\IBM\WebSphere Application Server Network Deployment")
index = 0
For Each obj in asInstalls
ReDim Preserve bothInstalls(index)
Set bothInstalls(index) = obj
index = index + 1
Next
For Each obj in ndInstalls
ReDim Preserve bothInstalls(index)
Set bothInstalls(index) = obj
index = index + 1
Next
WebSphereInstallations = bothInstalls
End Function
'''
''' Pricate helper function to get the first two digits from the version number
''' e.g. turning 6.1.0.0 into 6.1
'''
''' Parameter 1: The long version number
'''
Private Function ShortenVersion(version)
ShortenVersion = version
pos = InStr(version, ".")
If pos &gt; 0 Then
pos = InStr(pos + 1, version, ".")
If pos &gt; 0 Then
ShortenVersion = Mid(version, 1, pos - 1)
End If
End If
End Function
'''
''' Private Helper function for looking at Registry Entries for WebSphere
'''
''' Parameter 1: Registry Object
''' Parameter 2: Desired Registry Key to find
'''
Private Function FindWebSphereRegistryKey(oReg, strRegistryKey)
Dim respArr()
Dim respIndex, ret, ret2, arrSubKeys, subkey
Dim strKeyPath, arrVersions, version, installation
Dim installPath, majorVersion
ReDim Preserve respArr(-1)
respIndex = 0
ret = oReg.EnumKey(HKEY_USERS, "", arrSubKeys)
If ret = 0 Then
For Each subkey In arrSubKeys
strKeyPath = subkey + strRegistryKey
ret = oReg.EnumKey(HKEY_USERS, strKeyPath, arrVersions)
If ret = 0 Then
For Each version In arrVersions
strKeyPath = subkey + strRegistryKey + "\" + version
ret = oReg.GetStringValue(HKEY_USERS,strKeyPath, "InstallLocation", installPath)
ret2 = oReg.GetStringValue(HKEY_USERS,strKeyPath, "MajorVersion", majorVersion)
If ret = 0 And ret2 = 0 Then
ReDim Preserve respArr(respIndex)
Set installation = New WSInstallation
installation.InstallPath = installPath
installation.MajorVersion = majorVersion
installation.Version = ShortenVersion(version)
Set respArr(respIndex) = installation
respIndex = respIndex + 1
End If
Next
End If
Next
End If
FindWebSphereRegistryKey = respArr
End Function
'
' For WebSphere 6.1, the generic installation discovery works
' the same for 6.1 and 7.0. For advanced/deep monitoring, an
' additional feature pack needs to be installed on WebSphere
' 6.1. This method will check the registry to see if the
' feature pack has been installed. It is expected to be
' used with the Unit Monitor(s).
'
' This method is only concerned with if the key exists,
' (presently) there is no need for knowledge of any specific
' value
'
Public Function FindWebSphereFeaturePack_6_1(oReg)
' Much like the installation check, the key is not in HKLM.
' Instead, it is necessary to cycle through all the users
' and look for the key:
' &lt;USER&gt;\Software\IBM\WebSphere Application Server 6.1 Feature Pack for Web Services
Dim boolReturnValue
boolReturnValue = False
Dim registryCheckForFeaturePack
registryCheckForFeaturePack = FindWebSphereRegistryKey(oReg, "\Software\IBM\WebSphere Application Server 6.1 Feature Pack for Web Services")
If -1 &lt;&gt; UBound(registryCheckForFeaturePack) Then
boolReturnValue = True
End If
FindWebSphereFeaturePack_6_1 = boolReturnValue
End Function
'''
''' Create instances in OpsMgr for all found instances of WebSphere installations
'''
Public Function ReturnWebSphereInstallations(oAPI, oReg, SourceId, ManagedEntityId, TargetComputer, classGUID, MajorVersion)
Dim oDiscoveryData, installations, installation, oInst
Dim TempAllInstallPaths
Dim FoundWebSphere8
TempAllInstallPaths = ""
TempAllVersions = ""
FoundWebSphere8 = false
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)
installations = WebSphereInstallations(oReg)
For Each installation In installations
If FilterVersion(MajorVersion, installation.Version) Then
TempAllVersions = TempAllVersions + installation.Version + "|"
TempAllInstallPaths = TempAllInstallPaths + installation.InstallPath + "|"
FoundWebSphere8 = true
End If
Next
If FoundWebSphere8 Then
Set oInst = oDiscoveryData.CreateClassInstance(classGUID)
Call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
Call oInst.AddProperty("$MPElement[Name='WebSphere!Microsoft.JEE.WebSphere.Windows.Installation']/MajorVersion$", TempAllVersions)
Call oInst.AddProperty("$MPElement[Name='WebSphere!Microsoft.JEE.WebSphere.Windows.Installation']/InstallPath$", TempAllInstallPaths)
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "WebSphere")
Call oDiscoveryData.AddInstance(oInst)
End If
Call oAPI.Return(oDiscoveryData)
End Function
'''
''' Return true/false if the WebSphere 6.1 prerequiste check has passed
'''
Public Function ReturnWebSphere61PrerequisitesCheck()
Dim objMomAPI, objPropertyBag
Set objMomAPI = CreateObject("MOM.ScriptAPI")
Set objPropertyBag = objMomAPI.CreatePropertyBag()
Dim IsPrerequisitesInstalled
Dim objRegistry
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
IsPrerequisitesInstalled = FindWebSphereFeaturePack_6_1(objRegistry)
objPropertyBag.AddValue "IsPrerequisitesInstalled", IsPrerequisitesInstalled
Call objMomAPI.Return(objPropertyBag)
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

Dim oArgs, oAPI, oReg

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

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
ReturnWebSphereInstallations oAPI, oReg, oArgs(0), oArgs(1), oArgs(2), oArgs(3), oArgs(4)
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>