﻿<ManagementPack xsi:noNamespaceSchemaLocation="c:\enlistments\momv3.main\private\product\sdk\server\MPInfrastructure\schema\ManagementPackSchema.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:maml="http://schemas.microsoft.com/maml/2004/10">
  <Manifest>
    <Identity>
      <ID>Demo.AppThresholds.MP</ID>
      <Version>7.0.0.0</Version>
    </Identity>
    <Name>Demo MP for Monitoring Ole-DB Messages</Name>
    <References>
      <Reference Alias="System">
        <ID>System.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>9396306c2be7fcc4</PublicKeyToken>
      </Reference>
      <Reference Alias="AEMLib">
        <ID>Microsoft.SystemCenter.ClientMonitoring.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>9396306c2be7fcc4</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <TypeDefinitions>
    <ModuleTypes>
      <DataSourceModuleType ID="ErrorGroupThresholdDefiner" Accessibility="Public">
        <Configuration>
          <xsd:element name="BucketType" type="xsd:string" />
          <xsd:element name="Parameter1" type="xsd:string" />
          <xsd:element name="Parameter2" type="xsd:string" />
          <xsd:element name="Parameter3" type="xsd:string" />
          <xsd:element name="Parameter4" type="xsd:string" />
          <xsd:element name="Parameter5" type="xsd:string" />
          <xsd:element name="Parameter6" type="xsd:string" />
          <xsd:element name="Parameter7" type="xsd:string" />
          <xsd:element name="Parameter8" type="xsd:string" />
          <xsd:element name="Parameter9" type="xsd:string" />
          <xsd:element name="Parameter10" type="xsd:string" />
          <xsd:element name="Parameter11" type="xsd:string" />
          <xsd:element name="HitCountThresholdValue" type="xsd:unsignedInt" />
          <xsd:element name="UniqueUserThresholdValue" type="xsd:unsignedInt" />
          <xsd:element name="UniqueComputerThresholdValue" type="xsd:unsignedInt" />
        </Configuration>
        <ModuleImplementation>
          <Composite>
            <MemberModules>
              <DataSource ID="Scheduler" TypeID="System!System.Scheduler">
                <Scheduler>
                  <SimpleReccuringSchedule>
                    <Interval Unit="Minutes">15</Interval>
                  </SimpleReccuringSchedule>
                  <ExcludeDates />
                </Scheduler>
              </DataSource>
              <ProbeAction ID="OleDbProbe" TypeID="System!System.OleDbProbe">
                <ConnectionString>Provider=SQLOLEDB;Integrated Security=SSPI</ConnectionString>
                <Query>
                  SELECT BaseManagedEntityId from MT_WatsonBucket Where BucketType $Config/BucketType$ AND 
                  Parameter1 $Config/Parameter1$ AND Parameter2 $Config/Parameter2$ AND 
                  Parameter3 $Config/Parameter3$ AND Parameter4 $Config/Parameter4$ AND 
                  Parameter5 $Config/Parameter5$ AND Parameter6 $Config/Parameter6$ AND 
                  Parameter7 $Config/Parameter7$ AND Parameter8 $Config/Parameter8$ AND 
                  Parameter9 $Config/Parameter9$ AND Parameter10 $Config/Parameter10$ AND 
                  Parameter11 $Config/Parameter11$
                </Query>
                <GetValue>true</GetValue>
                <OneRowPerItem>true</OneRowPerItem>
                <DatabaseNameRegLocation>SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\DatabaseName</DatabaseNameRegLocation>
                <DatabaseServerNameRegLocation>SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\DatabaseServerName</DatabaseServerNameRegLocation>
              </ProbeAction>
              <ProbeAction ID="DiscoveryMapper" TypeID="AEMLib!Microsoft.SystemCenter.CM.DiscoveryMapperPA">
                <ManagedEntity>
                  <Detailed>
                    <TimeGenerated UseCurrent="true" />
                    <DiscoveryType>AddUpdate</DiscoveryType>
                    <DiscoverySourceType>Rule</DiscoverySourceType>
                    <SourceObjectId>$MPElement$</SourceObjectId>
                    <SourceManagedEntityId>$Target/Id$</SourceManagedEntityId>
                    <Properties>
                      <Evaluate If=".">
                        <Property ID="ManagedEntityIdValue">//Columns/Column[1]</Property>
                      </Evaluate>
                    </Properties>
                    <PropertySets />
                    <ClassInstances>
                      <ClassInstance If=".">
                        <TypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]$</TypeId>
                        <Properties>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/ManagedEntityId$</Name>
                            <Value>ManagedEntityIdValue</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/HitCountThresholdValue$</Name>
                            <Value>$Config/HitCountThresholdValue$</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/UniqueUserThresholdValue$</Name>
                            <Value>$Config/UniqueUserThresholdValue$</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/UniqueComputerThresholdValue$</Name>
                            <Value>$Config/UniqueComputerThresholdValue$</Value>
                          </Property>
                        </Properties>
                      </ClassInstance>
                    </ClassInstances>
                    <RelationshipInstances>
                      <RelationshipInstance If=".">
                        <TypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.ClientMonitoringGroupHasClientMonitoringEntities"]$</TypeId>
                        <SourceTypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.ClientMonitoringGroup"]$</SourceTypeId>
                        <TargetTypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]$</TargetTypeId>
                        <SourceProperties />
                        <TargetProperties>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/ManagedEntityId$</Name>
                            <Value>ManagedEntityIdValue</Value>
                          </Property>
                        </TargetProperties>
                        <Properties />
                      </RelationshipInstance>
                    </RelationshipInstances>
                  </Detailed>
                </ManagedEntity>
              </ProbeAction>
              <ConditionDetection ID="Filter" TypeID="System!System.ExpressionFilter">
                <Expression>
                  <Exists>
                    <ValueExpression>
                      <XPathQuery Type="String">Columns/Column[1]</XPathQuery>
                    </ValueExpression>
                  </Exists>
                </Expression>
              </ConditionDetection>
            </MemberModules>
            <Composition>
              <Node ID="DiscoveryMapper">
                <Node ID="Filter">
                  <Node ID="OleDbProbe">
                    <Node ID="Scheduler" />
                  </Node>
                </Node>
              </Node>
            </Composition>
          </Composite>
        </ModuleImplementation>
        <OutputType>System!System.Discovery.Data</OutputType>
      </DataSourceModuleType>
      <DataSourceModuleType ID="ApplicationThresholdDefiner" Accessibility="Public">
        <Configuration>
          <xsd:element name="ApplicationName" type="xsd:string" />
          <xsd:element name="ApplicationVersion" type="xsd:string" />
          <xsd:element name="HitCountThresholdValue" type="xsd:unsignedInt" />
          <xsd:element name="UniqueUserThresholdValue" type="xsd:unsignedInt" />
          <xsd:element name="UniqueComputerThresholdValue" type="xsd:unsignedInt" />
        </Configuration>
        <ModuleImplementation>
          <Composite>
            <MemberModules>
              <DataSource ID="Scheduler" TypeID="System!System.Scheduler">
                <Scheduler>
                  <SimpleReccuringSchedule>
                    <Interval Unit="Minutes">15</Interval>
                  </SimpleReccuringSchedule>
                  <ExcludeDates />
                </Scheduler>
              </DataSource>
              <ProbeAction ID="OleDbProbe" TypeID="System!System.OleDbProbe">
                <ConnectionString>Provider=SQLOLEDB;Integrated Security=SSPI</ConnectionString>
                <Query>
                  SELECT BaseManagedEntityId from MT_Application Where 
                  ApplicationName $Config/ApplicationName$ AND 
                  ApplicationVersion $Config/ApplicationVersion$
                </Query>
                <GetValue>true</GetValue>
                <OneRowPerItem>true</OneRowPerItem>
                <DatabaseNameRegLocation>SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\DatabaseName</DatabaseNameRegLocation>
                <DatabaseServerNameRegLocation>SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\DatabaseServerName</DatabaseServerNameRegLocation>
              </ProbeAction>
              <ProbeAction ID="DiscoveryMapper" TypeID="AEMLib!Microsoft.SystemCenter.CM.DiscoveryMapperPA">
                <ManagedEntity>
                  <Detailed>
                    <TimeGenerated UseCurrent="true" />
                    <DiscoveryType>AddUpdate</DiscoveryType>
                    <DiscoverySourceType>Rule</DiscoverySourceType>
                    <SourceObjectId>$MPElement$</SourceObjectId>
                    <SourceManagedEntityId>$Target/Id$</SourceManagedEntityId>
                    <Properties>
                      <Evaluate If=".">
                        <Property ID="ManagedEntityIdValue">//Columns/Column[1]</Property>
                      </Evaluate>
                    </Properties>
                    <PropertySets />
                    <ClassInstances>
                      <ClassInstance If=".">
                        <TypeId>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]$</TypeId>
                        <Properties>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/ManagedEntityId$</Name>
                            <Value>ManagedEntityIdValue</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/HitCountThresholdValue$</Name>
                            <Value>$Config/HitCountThresholdValue$</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/UniqueUserThresholdValue$</Name>
                            <Value>$Config/UniqueUserThresholdValue$</Value>
                          </Property>
                          <Property>
                            <Name>$MPElement[Name="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride"]/UniqueComputerThresholdValue$</Name>
                            <Value>$Config/UniqueComputerThresholdValue$</Value>
                          </Property>
                        </Properties>
                      </ClassInstance>
                    </ClassInstances>
                    <RelationshipInstances />
                  </Detailed>
                </ManagedEntity>
              </ProbeAction>
              <ConditionDetection ID="Filter" TypeID="System!System.ExpressionFilter">
                <Expression>
                  <Exists>
                    <ValueExpression>
                      <XPathQuery Type="String">Columns/Column[1]</XPathQuery>
                    </ValueExpression>
                  </Exists>
                </Expression>
              </ConditionDetection>
            </MemberModules>
            <Composition>
              <Node ID="DiscoveryMapper">
                <Node ID="Filter">
                  <Node ID="OleDbProbe">
                    <Node ID="Scheduler" />
                  </Node>
                </Node>
              </Node>
            </Composition>
          </Composite>
        </ModuleImplementation>
        <OutputType>System!System.Discovery.Data</OutputType>
      </DataSourceModuleType>
  </ModuleTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="ChangeMyErrorGroupThresholdValue" Target="AEMLib!Microsoft.SystemCenter.CM.AEM.CrashListener">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride" />
        </DiscoveryTypes>
        <DataSource ID="DS" TypeID="ErrorGroupThresholdDefiner">
          <!-- Properties for Error Group(s) whose threshold value needs to be changed -->
          <BucketType>= 'DW20'</BucketType>
          <Parameter1>= 'sample.exe'</Parameter1>
          <Parameter2>like '%'</Parameter2>
          <Parameter3>like '%'</Parameter3>
          <Parameter4>like '%'</Parameter4>
          <Parameter5>like '%'</Parameter5>
          <Parameter6>like '%'</Parameter6>
          <Parameter7>like '%'</Parameter7>
          <Parameter8>like '%'</Parameter8>
          <Parameter9>like '%'</Parameter9>
          <Parameter10>like '%'</Parameter10>
          <Parameter11>like '%'</Parameter11>
          <HitCountThresholdValue><!-- the new value-->100</HitCountThresholdValue>
          <UniqueUserThresholdValue><!-- the new value -->100</UniqueUserThresholdValue>
          <UniqueComputerThresholdValue><!-- the new value -->100</UniqueComputerThresholdValue>
        </DataSource>
      </Discovery>
      <Discovery ID="ChangeMyAppThresholdValue" Target="AEMLib!Microsoft.SystemCenter.CM.AEM.CrashListener">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryClass TypeID="AEMLib!Microsoft.SystemCenter.CM.AEM.MonitorOverride" />
        </DiscoveryTypes>
        <DataSource ID="DS" TypeID="ApplicationThresholdDefiner">
          <!-- Properties for Error Group(s) whose threshold value needs to be changed -->
          <ApplicationName>= 'Foo.exe'</ApplicationName>
          <ApplicationVersion>like '%'</ApplicationVersion>
          <HitCountThresholdValue><!-- the new value-->100</HitCountThresholdValue>
          <UniqueUserThresholdValue><!-- the new value -->100</UniqueUserThresholdValue>
          <UniqueComputerThresholdValue><!-- the new value -->100</UniqueComputerThresholdValue>
        </DataSource>
      </Discovery>
    </Discoveries>    
  </Monitoring>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="Demo.AppThresholds.MP">
          <Name>AppThresholds Demo MP</Name>
          <Description>AppThresholds DEMO MP: This Management Pack contains a discovery that would change default client-monitoring threshold values for given application.</Description>
        </DisplayString>
        <DisplayString ElementID="ErrorGroupThresholdDefiner">
          <Name>ErrorGroup ThresholdDefiner Module</Name>
          <Description>This module helps changing default threshold values of 50 for error group(s) at 3 levels: hit/crash/error count, unique users affected and unique computers affected.</Description>
        </DisplayString>
        <DisplayString ElementID="ApplicationThresholdDefiner">
          <Name>Application ThresholdDefiner Module</Name>
          <Description>This module helps changing default threshold values of 50 for application(s) at 3 levels: hit/crash/error count, unique users affected and unique computers affected.</Description>
        </DisplayString>
        <DisplayString ElementID="ChangeMyErrorGroupThresholdValue">
          <Name>Discovery ID: ChangeMyErrorGroupThresholdValue</Name>
          <Description>This discovery changes threshold for all errorgroups with parameter1 being sample.exe and bucket type being DW20.</Description>
        </DisplayString>
        <DisplayString ElementID="ChangeMyAppThresholdValue">
          <Name>Discovery ID: ChangeMyAppThresholdValue</Name>
          <Description>This discovery changes threshold for all applications with name being 'foo.exe'.</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>
