Reguła pielęgnacji jednostek aplikacji monitorowania klienta
Microsoft.SystemCenter.CM.AEM.Internal.DeleteApps (Discovery)
Ta reguła umożliwia pielęgnowanie aplikacji.
Element properties:
Object Discovery Details:
Member Modules:
Source Code:
<Discovery ID="Microsoft.SystemCenter.CM.AEM.Internal.DeleteApps" Target="AEMLib!Microsoft.SystemCenter.CM.AEM.CrashListener" Enabled="true" ConfirmDelivery="true">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="AEMLib!Microsoft.SystemCenter.CM.AEM.Application"/>
</DiscoveryTypes>
<DataSource ID="AemMEDataForDeletionDS1" TypeID="Microsoft.SystemCenter.CM.AEM.Internal.AemMEDataForDeletionDS">
<Days>14</Days>
<Query1>DECLARE @AEMTable NVARCHAR(1000), @WatsonTable NVARCHAR(1000), @Query NVARCHAR(MAX);
SELECT @AEMTable = ManagedTypeTableName FROM ManagedType WHERE TypeName = 'Microsoft.SystemCenter.CM.AEM.Application';
SELECT @WatsonTable = ManagedTypeTableName FROM ManagedType WHERE TypeName = 'Microsoft.SystemCenter.CM.AEM.WatsonBucket';
SET @Query = N'CREATE TABLE #AEMTemp (BaseManagedEntityId UNIQUEIDENTIFIER);
IF OBJECT_ID(''' + @AEMTable + ''', ''U'') IS NOT NULL
BEGIN
INSERT INTO #AEMTemp SELECT BaseManagedEntityId FROM ' +@AEMTable+ ' AS APP
LEFT OUTER JOIN [AemRelationship] AS AEM ON APP.BaseManagedEntityId = AEM.SourceEntityId
WHERE DATEDIFF(day, AEM.LastModified, getutcdate()) >= </Query1>
<Query2>OR AEM.SourceEntityId = NULL
GROUP BY BaseManagedEntityId
UPDATE BME SET BME.IsDeleted = 1 FROM [BaseManagedEntity] BME INNER JOIN #AEMTemp AT ON BME.BaseManagedEntityId = AT.BaseManagedEntityId;
DELETE APP_LOG FROM ' +@AEMTable+ '_Log APP_LOG INNER JOIN #AEMTemp AT ON APP_LOG.BaseManagedEntityId = AT.BaseManagedEntityId;
DELETE APP FROM ' +@AEMTable+ ' APP INNER JOIN #AEMTemp AT ON APP.BaseManagedEntityId = AT.BaseManagedEntityId;
DELETE WATSON FROM ' +@WatsonTable+ ' WATSON INNER JOIN #AEMTemp AT ON WATSON.BaseManagedEntityId = AT.BaseManagedEntityId;
DELETE WATSON_LOG FROM ' +@WatsonTable+ '_Log WATSON_LOG INNER JOIN #AEMTemp AT ON WATSON_LOG.BaseManagedEntityId = AT.BaseManagedEntityId
END';
EXEC sp_executesql @Query</Query2>
<ManagedEntity>
<Detailed>
<TimeGenerated UseCurrent="true"/>
<DiscoveryType>Remove</DiscoveryType>
<DiscoverySourceType>Rule</DiscoverySourceType>
<SourceObjectId>$MPElement$</SourceObjectId>
<SourceManagedEntityId>$Target/Id$</SourceManagedEntityId>
<Properties>
<Evaluate If="//Columns/Column[1]">
<Property ID="KeyValuesParamSet">//Columns/Column</Property>
</Evaluate>
</Properties>
<PropertySets/>
<ClassInstances>
<ClassInstance If="//Columns/Column[1]">
<TypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.Application"]$</TypeId>
<Properties>
<Property>
<Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.Application"]/ApplicationName$</Name>
<Value>KeyValuesParamSet[0]</Value>
</Property>
<Property>
<Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.Application"]/ApplicationVersion$</Name>
<Value>KeyValuesParamSet[1]</Value>
</Property>
</Properties>
</ClassInstance>
</ClassInstances>
<RelationshipInstances/>
</Detailed>
</ManagedEntity>
</DataSource>
</Discovery>