Detección de relación de disco

Microsoft.MSMQ.6.3.DataSource.DiskRelationshipDiscovery (DataSourceModuleType)

Origen de datos utilizados para la detección de relación de disco

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Intervalo en segundos
LogDetailbool$Config/LogDetail$Datos de registro
TimeoutSecondsint$Config/TimeoutSeconds$Tiempo de espera en segundos

Source Code:

<DataSourceModuleType ID="Microsoft.MSMQ.6.3.DataSource.DiskRelationshipDiscovery" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="IsClustered" type="xsd:boolean"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="ServiceName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="LogDetail" type="xsd:boolean"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogDetail" Selector="$Config/LogDetail$" ParameterType="bool"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverMSMQDiskRelationship.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ "$Config/ComputerName$" "$Config/IsClustered$" "$Config/ServiceName$" "$Config/LogDetail$"</Arguments>
<ScriptBody><Script>option explicit
SetLocale("en-us")

Const SCRIPT_NAME = "DiscoverMSMQDiskRelationship.vbs"

Const EVENT_LEVEL_ERROR = 1
Const EVENT_LEVEL_WARNING = 2
Const EVENT_LEVEL_INFO = 4

Const EVENTNO_SCRIPT_STARTED = 14301
Const EVENTNO_SCRIPT_ENDED = 14302
Const EVENTNO_MESSAGE_FILE_FOLDER_FOUND = 14310
Const EVENTNO_MESSAGE_LOGGER_FOLDER_FOUND = 14311
Const EVENTNO_TRANSACTIONAL_LOGGER_FOLDER_FOUND = 14312
Const EVENTNO_DISCDATA_SUBMITTED = 14313

Const HKEY_CURRENT_USER = &amp;H80000001
Const HKEY_LOCAL_MACHINE = &amp;H80000002

Dim oApi, oArgs, wshNetwork, sUser, sDomain, sMessage
Dim SourceId, ManagedEntityId, sComputer, bIsVirtual, oServiceName, bLogDetail
Dim sregRoot, oDiscoveryData, oServerInstance
Dim sMessageFilesFolder, sMessageLoggerFolder, stransactionLoggerFolder

Set oAPI = CreateObject("MOM.ScriptAPI")

Set oArgs = WScript.Arguments
If oArgs.Count &lt; 6 Then Call ShowUsage()
SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
sComputer = oArgs(2)
If Len(oArgs(3)) &gt; 0 Then
bIsVirtual = CBool(oArgs(3))
Else
bIsVirtual = False
End If
oServiceName = oArgs(4)
bLogDetail = CBool(oArgs(5))

Set wshNetwork = CreateObject("Wscript.Network")
sUser = wshNetwork.UserName
sDomain = wshNetwork.UserDomain

sMessage = "MSMQ Disk Relationship discovery started with following parameters: " &amp; VbCrLf &amp; _
"Source ID: " &amp; SourceId &amp; VbCrLf &amp; _
"Managed Entity ID: " &amp; ManagedEntityId &amp; VbCrLf &amp; _
"Computer: " &amp; sComputer &amp; VbCrLf &amp; _
"Network: " &amp; wshNetwork.ComputerName &amp; VbCrLf &amp; _
"IsVirtual: " &amp; bIsVirtual &amp; VbCrLf &amp; _
"Service Name :" &amp; oServiceName &amp; VbCrLf &amp; _
"User credentials: " &amp; sDomain &amp; "\" &amp; sUser

Call LogDetail(EVENTNO_SCRIPT_STARTED, sMessage)

If bIsVirtual = True Then
sRegRoot = "SOFTWARE\Microsoft\MSMQ\Clustered QMs\" &amp; oServiceName
Else
sRegRoot = "SOFTWARE\Microsoft\MSMQ"
End If

Set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)

Set oServerInstance = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.MSMQ.6.3.Servers']$")
Call oServerInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sComputer)

sMessageFilesFolder = GetRegStringValue(sComputer,sRegRoot &amp; "\Parameters","StorePersistentPath")
sMessageLoggerFolder = GetRegStringValue(sComputer,sRegRoot &amp; "\Parameters","StoreLogPath")
sTransactionLoggerFolder = GetRegStringValue(sComputer,sRegRoot &amp; "\Parameters","StoreXactLogPath")

AddDiskRelationship(sMessageFilesFolder)
Call LogDetail(EVENTNO_MESSAGE_FILE_FOLDER_FOUND, "Message File Foler found.")
AddDiskRelationship(sMessageLoggerFolder)
Call LogDetail(EVENTNO_MESSAGE_LOGGER_FOLDER_FOUND, "Message Logger Folder found.")
AddDiskRelationship(sTransactionLoggerFolder)
Call LogDetail(EVENTNO_TRANSACTIONAL_LOGGER_FOLDER_FOUND, "Transactional Logger Folder found.")

oAPI.Return(oDiscoveryData)
Call LogDetail(EVENTNO_DISCDATA_SUBMITTED,"Discovery data submitted.")
Call LogDetail(EVENTNO_SCRIPT_ENDED, "Discover MSMQ Disk Relationship ended.")

Sub AddDiskRelationship(Path)
Dim sDrive, WMI, cDrives, oDrive, oDisk, oRelationship
sDrive = Left(Path,2)

If Right(sDrive,1) = ":" Then

Set WMI = GetObject("winmgmts:\\" &amp; sComputer &amp; "\root\cimv2")
Set cDrives = WMI.ExecQuery("select * from win32_logicaldisk where caption = '" &amp; sDrive &amp; "'")
For Each oDrive In cDrives
Set oDisk = oDiscoveryData.CreateClassInstance("$MPElement[Name='WindowsServer!Microsoft.Windows.Server.6.2.LogicalDisk']$")
Call oDisk.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sComputer)
Call oDisk.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.LogicalDevice']/DeviceID$", sDrive)
Next

Set oRelationship = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.MSMQ.6.3.Relationship.ServerContainsLogicalDisk']$")
oRelationship.Source = oServerInstance
oRelationship.Target = oDisk
Call oDiscoveryData.AddInstance(oRelationship)
End If

End Sub

Function GetRegStringValue(Computer,RegKeyPath,RegValueName)
Dim oReg, Value

Set oReg = GetObject("winmgmts:\\" &amp; Computer &amp; "\root\default:StdRegProv")
oReg.GetStringValue HKEY_LOCAL_MACHINE,RegKeyPath,RegValueName,Value
GetRegStringValue = Value

End Function

Sub LogDetail(EventNo,Message)

Message = VbCrLf &amp; "Calling MP Element ID: $MPElement$" &amp; vbcrlf &amp; Message
If bLogDetail = True Then
Call oAPI.LogScriptEvent(SCRIPT_NAME,EventNo,EVENT_LEVEL_INFO,Message)
End If

End Sub

Sub ThrowScriptError(EventNo,Severity,Message,Abort)

Message = VbCrLf &amp; Message
Call oAPI.LogScriptEvent(SCRIPT_NAME,EventNo,Severity,Message)
If Abort = True Then WScript.Quit

End Sub

Sub ShowUsage

WScript.Echo "Usage: "
WScript.Echo "cscript DiscoverMSMQDiskRelationship.vbs &lt;CallingRuleGUID&gt; &lt;TargetEntityGUID&gt; &lt;Computer&gt; &lt;IsVirtual&gt; &lt;ServiceName&gt; &lt;LogDetail&gt;"
WScript.Echo
WScript.Echo "Example:"
WScript.Echo "cscript DiscoverMSMQDiskRelationship.vbs {b3e9befe-173b-78a2-3e41-e19ecb58d9d5} {2fa43439-afc4-cc64-9b3a-9642ec898c1c} srv1.contoso.com 0 msmq false"

WScript.Quit

End Sub</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>