Compliance Profile Discovery

VCE.Vision.Monitoring.Discovery.ComplianceProfile (Discovery)

Discover Compliance Profiles

Element properties:

TargetVCE.Vision.Monitoring.Class.ComplianceBenchmark
EnabledTrue
Frequency900
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="VCE.Vision.Monitoring.Discovery.ComplianceProfile" Target="VCE.Vision.Monitoring.Class.ComplianceBenchmark" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="VCE.Vision.Monitoring.Class.ComplianceProfile"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ScriptName>cDiscovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Property[Type="VCE.Vision.Monitoring.Class.ComplianceBenchmark"]/vblockId$ $Target/Property[Type="VCE.Vision.Monitoring.Class.ComplianceBenchmark"]/benchmarkId$</Arguments>
<ScriptBody><Script>Option Explicit

Dim oAPI, sDebugMsg, bDebug, vblockId
Dim source0, target0, sourceKey0, sourceKey1, host0

Sub InitDiscovery(ByRef nodelist)
Dim sh, wmi, var0, oDoc, vblockIdList, svcItems, svcItem

Set oAPI = CreateObject("MOM.ScriptAPI")

If WScript.Arguments.Count &lt; 3 Then
Call oAPI.LogScriptEvent("cDiscovery", 1002, 1, "The script expects at least 3 arguments!")
Call WScript.Quit(-1)
End If

source0 = WScript.Arguments(0)
target0 = WScript.Arguments(1)
sourceKey0 = WScript.Arguments(2)
If WScript.Arguments.Count &gt; 3 Then
sourceKey1 = WScript.Arguments(3)
End If

Set sh = CreateObject("WScript.Shell")
host0 = sh.RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname")
var0 = sh.RegRead ("HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Domain")
If Len(var0) &gt; 0 Then host0 = host0 &amp; "." &amp; var0
sDebugMsg = sDebugMsg &amp; host0 &amp; ", " &amp; sourceKey0 &amp; ", " &amp; sourceKey1

Set wmi = GetObject("winmgmts:\\.\root\cimv2")
Set oDoc = CreateObject("Microsoft.XMLDOM")
Set nodeList = Nothing
On Error Resume Next
Set svcItems = wmi.ExecQuery("SELECT * FROM Win32_Service WHERE Name LIKE 'VCEProxy_%'")
For Each svcItem in svcItems
var0 = sh.RegRead ("HKLM\SYSTEM\CurrentControlSet\services\" &amp; svcItem.Name &amp; "\VcomplianceData")
Call oDoc.load(var0)
If Not oDoc.documentElement Is Nothing Then
vblockIdList = oDoc.documentElement.SelectSingleNode("./@vblockId").Text
If InStr(vblockIdList, sourceKey0) &gt; 0 Then
vblockId = sourceKey0
If sourceKey1 = "" Then
Set nodelist = oDoc.documentElement.SelectNodes("/*/complianceBenchmark")
Else
Set nodelist = oDoc.documentElement.SelectNodes("/*/complianceProfile[./benchmarkId='" &amp; sourceKey1 &amp; "']")
End If
bDebug = sh.RegRead ("HKLM\SYSTEM\CurrentControlSet\services\" &amp; svcItem.Name &amp; "\mpDebug")
Exit For
End If
End If
Next
On Error GoTo 0 'restores VBS error trapping

End Sub

Sub Main
Dim nodeList, oDiscoveryData, oHealthServiceInst

Call InitDiscovery(nodeList)

Set oDiscoveryData = oAPI.CreateDiscoveryData(0, source0, target0)
If nodeList Is Nothing Then
Call oAPI.Return(oDiscoveryData)
Exit Sub
End If

Set oHealthServiceInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$")
Call oHealthServiceInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", host0)
Call oDiscoveryData.AddInstance(oHealthServiceInst)

Dim oNode, oInst, pInst, oRel, oShouldManageInst
If sourceKey1 = "" Then
Dim defaultProfile, defaultProfileId
Set pInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='VCE.Vision.Monitoring.Class.VblockRoot']$")
Call pInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.VblockBase']/uuid$", vblockId)

For Each oNode In nodeList
Set defaultProfile = oNode.SelectSingleNode("./benchmarkInfo/defaultProfileId")
If defaultProfile Is Nothing Then
defaultProfileId = ""
Else
defaultProfileId = defaultProfile.Text
End If

If defaultProfileId = "" Then
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']$")
Else
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmarkWithDefaultProfile']$")
End If

Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", oNode.SelectSingleNode("./name").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/benchmarkId$", oNode.SelectSingleNode("./id").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/description$", oNode.SelectSingleNode("./description").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/version$", oNode.SelectSingleNode("./version").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/vblockId$", vblockId)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/defaultProfileId$", defaultProfileId)

Call oDiscoveryData.AddInstance(oInst)

Set oShouldManageInst = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oShouldManageInst.Source = oHealthServiceInst
oShouldManageInst.Target = oInst
Call oDiscoveryData.AddInstance(oShouldManageInst)

Set oRel = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='VCE.Vision.Monitoring.Relationship.VblockRootContainsComplianceBenchmarks']$")
oRel.Source = pInst
oRel.Target = oInst
Call oDiscoveryData.AddInstance(oRel)

sDebugMsg = sDebugMsg &amp; vbNewLine &amp; "+" &amp; oNode.NodeName
Next
ElseIf nodeList.length &gt; 0 Then
Dim benchmarkId : benchmarkId = nodeList.item(0).SelectSingleNode("./benchmarkId").Text
Set pInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']$")
Call pInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/benchmarkId$", benchmarkId)
Call pInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceBenchmark']/vblockId$", vblockId)

For Each oNode In nodeList
Set oInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']$")
Call oInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", oNode.SelectSingleNode("./name").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']/benchmarkId$", oNode.SelectSingleNode("./benchmarkId").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']/profileId$", oNode.SelectSingleNode("./profileId").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']/description$", oNode.SelectSingleNode("./description").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']/version$", oNode.SelectSingleNode("./version").Text)
Call oInst.AddProperty("$MPElement[Name='VCE.Vision.Monitoring.Class.ComplianceProfile']/vblockId$", vblockId)
Call oDiscoveryData.AddInstance(oInst)

Set oShouldManageInst = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oShouldManageInst.Source = oHealthServiceInst
oShouldManageInst.Target = oInst
Call oDiscoveryData.AddInstance(oShouldManageInst)

Set oRel = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='VCE.Vision.Monitoring.Relationship.ComplianceBenchmarkContainsProfiles']$")
oRel.Source = pInst
oRel.Target = oInst
Call oDiscoveryData.AddInstance(oRel)
sDebugMsg = sDebugMsg &amp; vbNewLine &amp; "+" &amp; oNode.NodeName
Next
End If

If bDebug = "true" Then
Call oAPI.LogScriptEvent("cDiscovery", 1002, 0, sDebugMsg)
End If

Call oAPI.Return(oDiscoveryData)
End Sub

Call Main()

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