﻿<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.OleDB.MP</ID>
      <Version>1.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="SCLibrary">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>9396306c2be7fcc4</PublicKeyToken>
      </Reference>
      <Reference Alias="Health">
        <ID>System.Health.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>9396306c2be7fcc4</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <TypeDefinitions>
    <MonitorTypes>
      <UnitMonitorType ID="Demo.OleDB.ThresholdWatcher" Accessibility="Public">
        <MonitorTypeStates>
          <MonitorTypeState ID="Healthy"/>
          <MonitorTypeState ID="Unhealthy"/>
        </MonitorTypeStates>
        <Configuration>
          <IncludeSchemaTypes>
            <SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
          </IncludeSchemaTypes>
          <xsd:element name="Scheduler" type="PublicSchedulerType" />
          <xsd:element name="ConnectionString" type="xsd:string"/>
          <xsd:element name="Query" type="xsd:string" />
        </Configuration>
        <OverrideableParameters>
          <OverrideableParameter ID="ConnectionString" ParameterType="string" Selector="$Config/ConnectionString$" />
          <OverrideableParameter ID="Query" ParameterType="string" Selector="$Config/Query$" />
        </OverrideableParameters>
        <MonitorImplementation>
          <MemberModules>
            <DataSource ID="Scheduler" TypeID="System!System.Scheduler">
              <Scheduler>$Config/Scheduler$</Scheduler>
            </DataSource>
            <ProbeAction ID="OleDBPA" TypeID="System!System.OleDbProbe">
              <ConnectionString>$Config/ConnectionString$</ConnectionString>
              <Query>$Config/Query$</Query>
              <GetValue>true</GetValue>
              <OneRowPerItem>false</OneRowPerItem>
            </ProbeAction>
            <ProbeAction ID="OleDBTriggerPA" TypeID="System!System.OleDbTriggerProbe">
              <ConnectionString>$Config/ConnectionString$</ConnectionString>
              <Query>$Config/Query$</Query>
              <GetValue>true</GetValue>
              <OneRowPerItem>false</OneRowPerItem>
            </ProbeAction>
            <ConditionDetection ID="HealthyFilter" TypeID="System!System.ExpressionFilter">
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="UnsignedInteger">ExecutionTime</XPathQuery>
                  </ValueExpression>
                  <Operator>GreaterEqual</Operator>
                  <ValueExpression>
                    <Value Type="UnsignedInteger">30000</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </ConditionDetection>
            <ConditionDetection ID="UnhealthyFilter" TypeID="System!System.ExpressionFilter">
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="Integer">ExecutionTime</XPathQuery>
                  </ValueExpression>
                  <Operator>Less</Operator>
                  <ValueExpression>
                    <Value Type="Integer">30000</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </ConditionDetection>
          </MemberModules>
          <RegularDetections>
            <RegularDetection MonitorTypeStateID="Healthy">
              <Node ID="HealthyFilter">
                <Node ID="OleDBPA">
                  <Node ID="Scheduler"/>
                </Node>
              </Node>
            </RegularDetection>
            <RegularDetection MonitorTypeStateID="Unhealthy">
              <Node ID="UnhealthyFilter">
                <Node ID="OleDBPA">
                  <Node ID="Scheduler"/>
                </Node>
              </Node>
            </RegularDetection>
          </RegularDetections>
          <OnDemandDetections>
            <OnDemandDetection MonitorTypeStateID="Healthy">
              <Node ID="HealthyFilter">
                <Node ID="OleDBTriggerPA"/>
              </Node>
            </OnDemandDetection>
            <OnDemandDetection MonitorTypeStateID="Unhealthy">
              <Node ID="UnhealthyFilter">
                <Node ID="OleDBTriggerPA"/>
              </Node>
            </OnDemandDetection>
          </OnDemandDetections>
        </MonitorImplementation>
      </UnitMonitorType>
    </MonitorTypes>
  </TypeDefinitions>
  <Monitoring>
    <Monitors>
      <UnitMonitor ID="Demo.OleDB.ThresholdWatcherId" TypeID="Demo.OleDB.ThresholdWatcher" Target="SCLibrary!Microsoft.SystemCenter.ManagementServer" Accessibility="Public" Enabled="true" ParentMonitorID="Health!System.Health.AvailabilityState" ConfirmDelivery="false">
        <Category>Alert</Category>
        <AlertSettings AlertMessage="Demo.OleDB.AlertMessage">
          <AlertOnState>Error</AlertOnState>
          <AutoResolve>true</AutoResolve>
          <AlertPriority>High</AlertPriority>
        </AlertSettings>
        <OperationalStates>
          <OperationalState HealthState="Success" MonitorTypeStateID="Healthy" ID="Regular"/>
          <OperationalState HealthState="Error" MonitorTypeStateID="Unhealthy" ID="Iregular"/>
        </OperationalStates>
        <Configuration>
          <Scheduler>
            <SimpleReccuringSchedule>
              <Interval Unit="Minutes">60</Interval>
            </SimpleReccuringSchedule>
            <ExcludeDates/>
          </Scheduler>
          <ConnectionString><![CDATA[Provider=SQLOLEDB;Database=master;Server=.;IntegratedSecurity=SSPI]]></ConnectionString>
          <Query><![CDATA[SELECT COUNT(*) FROM SYSCOLUMNS]]></Query>
        </Configuration>
      </UnitMonitor>
    </Monitors>
  </Monitoring>
  <Presentation>
    <StringResources>
      <StringResource ID="Demo.OleDB.AlertMessage" />
    </StringResources>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="Demo.OleDB.MP">
          <Name>OleDB Demo MP</Name>
          <Description>OleDB DEMO MP: This Management Pack contains rules that generates alerts when certain thresholds aren't met.</Description>
        </DisplayString>
        <DisplayString ElementID="Demo.OleDB.AlertMessage">
          <Name>Thresholds exceeded.</Name>
          <Description>{0}</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>
