Découverte des propriétés du serveur d’administration de l’entrepôt de données Microsoft System Center

Microsoft.SystemCenter.ServiceManager.DwManagementServerProperties.Discovery (Discovery)

Découvre les propriétés du serveur d’administration de l’entrepôt de données Microsoft System Center.

Knowledge Base article:

Résumé

Cette découverte remplit les propriétés de l’entrepôt de données Service Manager. La découverte s’exécute immédiatement après l’importation, puis de nouveau à 13:00, heure de la synchronisation. Après cela, elle s’exécute toutes les 24 heures. L’heure de synchronisation, la fréquence et le délai d’expiration sont modifiables. La modification des arguments n’est pas recommandée.

Element properties:

TargetMicrosoft.SystemCenter.ServiceManager.DwManagementServer
EnabledTrue
Frequency86400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Microsoft.SystemCenter.ServiceManager.DatabaseWriteActionAccount

Source Code:

<Discovery ID="Microsoft.SystemCenter.ServiceManager.DwManagementServerProperties.Discovery" Enabled="true" Target="SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer.2010"/>
<DiscoveryClass TypeID="SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer.2012"/>
</DiscoveryTypes>
<DataSource ID="DS" RunAs="SM!Microsoft.SystemCenter.ServiceManager.DatabaseWriteActionAccount" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime>01:00</SyncTime>
<ScriptName>DwMgtServerPropDiscovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="SM!Microsoft.SystemCenter.ServiceManager.ManagementServer"]/Version$</Arguments>
<ScriptBody><Script>
'Copyright (c) Microsoft Corporation. All rights reserved.

'*************************************************************************
' $ScriptName: "GetSqlDriverName" $
'
' Purpose: This script is used to get SQL Driver name.
'
' $File: GetSqlDriverName.vbs $
'*************************************************************************
Option Explicit

Function GetSqlDriverName
Dim oAPI1, oReg
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Dim strComputer, strDriverPath, strKeyPath, intValue, strValueName,arrSubKeys,oSubkey,strNewKeyPath,intDotIndex
strComputer = "."
strDriverPath="SQLOLEDB"
Set oReg=GetObject("winmgmts:\\" &amp; _
strComputer &amp; "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each oSubkey In arrSubKeys
intValue = InStr(oSubkey, "SQL Server Native Client")
if intValue &lt;&gt; 0 Then
strValueName = "Driver"
strNewKeyPath = strKeyPath&amp;"\"&amp;oSubkey
oReg.GetStringValue HKEY_LOCAL_MACHINE, strNewKeyPath, strValueName , strDriverPath
strDriverPath = Mid (strDriverPath, InStrRev(strDriverPath, "\")+1)
intDotIndex = InStr(strDriverPath, ".")
strDriverPath = Left(strDriverPath , intDotIndex-1)
end if
Next
GetSqlDriverName = strDriverPath
End Function
'*************************************************************************
' ScriptName: DwMgtServerPropDiscovery.vbs
'
' Purpose - Populate properties of DW Management Server
'
' Parameters - 0 - discovery id
' 1 - Target managed entity id
' 2 - Host Computer Principal Name
' 3 - Version
'*************************************************************************
SetLocale("en-us")
Dim sourceId,managedEntityId,oAPI,strKeyPath,principalName, version, oDiscoveryData

Set oAPI = CreateObject("MOM.ScriptAPI")
sourceId = WScript.Arguments(0)
managedEntityId = WScript.Arguments(1)
principalName = WScript.Arguments(2)
version = WScript.Arguments(3)

' Fetching Data Warehouse Management Group using WMI

Call oAPI.LogScriptEvent("DwMgtServerPropDiscovery.vbs", 3000, 4, "Starting discovery of Service Manager DataWarehouse Management Server.")
Set oDiscoveryData = oAPI.CreateDiscoveryData(0, sourceId, managedEntityId)

Dim oReg, iResult, arrSubKeys, managementGroupName
Set oReg = GetObject("winmgmts:\\" &amp; principalName &amp; "\root\default:StdRegProv")
If Err &lt;&gt; 0 Then
Call oAPI.LogScriptEvent("DwMgtServerPropDiscovery.vbs", 3000, 4, "Unable to bind to WMI registry provider on " &amp; principalName &amp; ". Terminating Discovery.")
Call oAPI.Return(oDiscoveryData)
WScript.Quit
End if
Const HKLM = &amp;H80000002

If version = "2010" or version = "2012" then
iResult = oReg.Enumkey(HKLM, "SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Server Management Groups", arrSubKeys)
If iResult = 0 then
Call oAPI.LogScriptEvent("DwMgtServerPropDiscovery.vbs", 3000, 4, "Discovered SCSM " &amp; version &amp;" DataWarehouse Server Properties.")
Dim dwMgName,oMgtServerInst,oMgGroupInst,oRelMgGroupContainsMgServer,oSmAppInst,oRelSmContainsMg, arrRegValues, oRegDictionary, strKeyRoot, queryResult, allQueriesPassed, Value
dwMgName = arrSubKeys(0)

arrRegValues = Array("DataMartSQLInstance", "DataMartDatabaseName", "RepositorySQLInstance", "RepositoryDatabaseName", "DatabaseServerName", "DatabaseName")
Set oRegDictionary = CreateObject("Scripting.Dictionary")
strKeyRoot = "SOFTWARE\Microsoft\System Center\2010\Common\Database"
allQueriesPassed = True
For Each Value in arrRegValues
iResult = oReg.GetStringValue(HKLM, strKeyRoot, Value, queryResult)
If iResult = 0 then
oRegDictionary.item(Value) = queryResult
Else
allQueriesPassed = False
Exit For
End If
Next

If allQueriesPassed = True then
'Instantiate Data Warehouse Management Server instance
If version = "2010" then
Set oMgtServerInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer.2010']$")
ElseIf version = "2012" then
Set oMgtServerInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer.2012']$")
End If
Call oMgtServerInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", principalName)
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.ManagementServer']/ManagementGroupName$", dwMgName)

Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/DataMartDbName$", oRegDictionary.item("DataMartDatabaseName"))
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/DataMartDbHostName$", oRegDictionary.item("DataMartSQLInstance"))
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/RepositoryDbName$", oRegDictionary.item("RepositoryDatabaseName"))
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/RepositoryDbHostName$", oRegDictionary.item("RepositorySQLInstance"))
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/StagingDbName$", oRegDictionary.item("DatabaseName"))
Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/StagingDbHostName$", oRegDictionary.item("DatabaseServerName"))

Dim connectionString, cnADOConnection, oResults,oQuery,sourceName, strDriverName
strDriverName = GetSqlDriverName
connectionString = "Provider=" &amp; strDriverName &amp; ";Server=" &amp; oRegDictionary.item("DatabaseServerName") &amp; ";Integrated Security=SSPI;Initial Catalog=" &amp; oRegDictionary.item("DatabaseName")
Set cnADOConnection = CreateObject("ADODB.Connection")
cnADOConnection.Open connectionString
cnADOConnection.CommandTimeout = 300
oQuery = "select SourceName from etl.source where SourceTypeId ='2'"
oResults = CreateObject("ADODB.Recordset")
Set oResults = cnADOConnection.Execute(oQuery)

If oResults.State &lt;&gt; 0 Then
Do Until oResults.EOF
If oResults.Fields("SourceName") &lt;&gt; dwMgName Then
sourceName = sourceName &amp; oResults.Fields("SourceName")&amp; ","
End If
oResults.MoveNext
Loop
End If
If oResults.State &lt;&gt; 0 Then
oResults.Close
End If
cnADOConnection.Close

if(isEmpty(sourceName)) Then
sourceName = ""
Else
sourceName = Left(sourceName,(Len(sourceName)-1))
End If

Call oMgtServerInst.AddProperty("$MPElement[Name='SM!Microsoft.SystemCenter.ServiceManager.DwManagementServer']/SmManagementGroups$", sourceName)
Call oDiscoveryData.AddInstance(oMgtServerInst)

End If
End If
End If

' Submit the discovery data to the Operations Manager database.
Call oAPI.Return(oDiscoveryData)
Call oAPI.LogScriptEvent("DwMgtServerPropDiscovery.vbs", 3000, 4, "Finishing DataWarehouse properties discovery.")
WScript.Quit


</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>