詳細な監視のレジストリ エントリの設定

Microsoft.JEE.EnableAppServerManagement.RegWriteAction (WriteActionModuleType)

詳細な監視のレジストリ エントリを書き込みます。

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.BaseData
CommentEnable management of application server

Member Modules:

ID Module Type TypeId RunAs 
UpdateRegistry WriteAction Microsoft.Windows.ScriptWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TargetInstanceIdstring$Config/TargetInstanceId$ターゲット インスタンス IDターゲット インスタンスの GUID。
TaskTimeoutSecondsstring$Config/TaskTimeoutSeconds$タイムアウトデータ ソースの非アクティブ状態のタイムアウト値 (秒)

Source Code:

<WriteActionModuleType ID="Microsoft.JEE.EnableAppServerManagement.RegWriteAction" Comment="Enable management of application server" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element name="ManagementGroupId" type="xsd:string"/>
<xsd:element name="Protocol" type="xsd:string"/>
<xsd:element name="TargetInstanceId" type="xsd:string"/>
<xsd:element name="TaskTimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TargetInstanceId" Selector="$Config/TargetInstanceId$" ParameterType="string"/>
<OverrideableParameter ID="TaskTimeoutSeconds" Selector="$Config/TaskTimeoutSeconds$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="UpdateRegistry" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>JEEAppServerEnableManagement.vbs</ScriptName>
<Arguments>$Config/ManagementGroupId$ "$Config/Protocol$" "$Config/TargetInstanceId$"</Arguments>
<ScriptBody><Script>
''' 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, add it to the registry
'
FUNCTION EnableDeepManagement(userSuppliedTypeLib, userSuppliedMOMAPI, userSuppliedRegistry, groupId, protocol, appServerId)
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
IF userSuppliedTypeLib Is Nothing THEN
SET typeLib = CreateObject("Scriptlet.TypeLib")
ELSE
SET typeLib = userSuppliedTypeLib
END IF
enabled = AppServerEnabledForDeepManagement(oApi, objRegistry, groupId, appServerId, foundKey, foundProtocol)
IF enabled = false THEN
GetBaseRegistryPath = oApi.GetScriptStateKeyPath(groupId)
ASPath = GetBaseRegistryPath &amp; "\" &amp; MONITORED_REGISTRY_KEY&amp; "\" &amp; typeLib.Guid
objRegistry.CreateKey HKEY_LOCAL_MACHINE, ASPath
objRegistry.SetStringValue HKEY_LOCAL_MACHINE, ASPath, REGISTRY_PROP_ID, appServerId
objRegistry.SetStringValue HKEY_LOCAL_MACHINE, ASPath, REGISTRY_PROP_PROTOCOL, protocol
ELSE
IF protocol &lt;&gt; foundProtocol THEN
objRegistry.SetStringValue HKEY_LOCAL_MACHINE, foundKey, REGISTRY_PROP_PROTOCOL, protocol
END IF
END IF
END FUNCTION

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

EnableDeepManagement Nothing, Nothing, Nothing, oArgs(0), oArgs(1), oArgs(2)
</Script></ScriptBody>
<TimeoutSeconds>$Config/TaskTimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="UpdateRegistry"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>