<ManagementPack ContentReadable="true" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <Manifest>
    <Identity>
      <ID>Microsoft.SystemCenter.Community.Monitors.RecoverySample</ID>
      <Version>6.0.6407.0</Version>
    </Identity>
    <Name>System Center Community MP Reset State Recovery Sample</Name>
    <References>
      <Reference Alias="MicrosoftSystemCenterCommunityMonitorsExtensions">
        <ID>Microsoft.SystemCenter.Community.Monitors.Extensions</ID>
        <Version>6.0.6407.0</Version>
        <PublicKeyToken>93c669a67d62bdc4</PublicKeyToken>
      </Reference>
      <Reference Alias="SC">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>6.0.6407.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Windows">
        <ID>Microsoft.Windows.Library</ID>
        <Version>6.0.6407.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="Health">
        <ID>System.Health.Library</ID>
        <Version>6.0.6407.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="System">
        <ID>System.Library</ID>
        <Version>6.0.6407.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <TypeDefinitions>
    <MonitorTypes>
      <UnitMonitorType ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.SingleEventLogManualReset3StateMonitorType" Accessibility="Internal">
        <MonitorTypeStates>
          <MonitorTypeState ID="EventRaisedWRN" NoDetection="false" />
          <MonitorTypeState ID="EventRaisedERR" NoDetection="false" />
          <MonitorTypeState ID="ManualReset" NoDetection="true" />
        </MonitorTypeStates>
        <Configuration>
          <IncludeSchemaTypes>
            <SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
          </IncludeSchemaTypes>
          <xsd:element minOccurs="1" name="ComputerName" type="xsd:string" />
          <xsd:element minOccurs="1" name="LogName" type="xsd:string" />
          <xsd:element minOccurs="1" name="ExpressionWarning" type="ExpressionType" />
          <xsd:element minOccurs="1" name="ExpressionError" type="ExpressionType" />
        </Configuration>
        <MonitorImplementation>
          <MemberModules>
            <DataSource ID="DataSource" TypeID="Windows!Microsoft.Windows.BaseEventProvider">
              <ComputerName>$Config/ComputerName$</ComputerName>
              <LogName>$Config/LogName$</LogName>
            </DataSource>
            <ConditionDetection ID="FilterWRN" TypeID="System!System.ExpressionFilter">
              <Expression>$Config/ExpressionWarning$</Expression>
            </ConditionDetection>
            <ConditionDetection ID="FilterERR" TypeID="System!System.ExpressionFilter">
              <Expression>$Config/ExpressionError$</Expression>
            </ConditionDetection>
          </MemberModules>
          <RegularDetections>
            <RegularDetection MonitorTypeStateID="EventRaisedWRN">
              <Node ID="FilterWRN">
                <Node ID="DataSource" />
              </Node>
            </RegularDetection>
            <RegularDetection MonitorTypeStateID="EventRaisedERR">
              <Node ID="FilterERR">
                <Node ID="DataSource" />
              </Node>
            </RegularDetection>
          </RegularDetections>
        </MonitorImplementation>
      </UnitMonitorType>
    </MonitorTypes>
  </TypeDefinitions>
  <Monitoring>
    <Monitors>
      <UnitMonitor ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" Accessibility="Internal" Enabled="onStandardMonitoring" Target="SC!Microsoft.SystemCenter.RootManagementServer" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.SingleEventLogManualReset3StateMonitorType" ConfirmDelivery="true">
        <Category>AvailabilityHealth</Category>
        <AlertSettings AlertMessage="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor_AlertMessageResourceID">
          <AlertOnState>Warning</AlertOnState>
          <AutoResolve>true</AutoResolve>
          <AlertPriority>Low</AlertPriority>
          <AlertSeverity>MatchMonitorHealth</AlertSeverity>
          <AlertParameters>
            <AlertParameter1>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</AlertParameter1>
            <AlertParameter2>$Data/Context/DataItem/EventDisplayNumber$</AlertParameter2>
            <AlertParameter3>$Data/Context/EventDescription$</AlertParameter3>
          </AlertParameters>
        </AlertSettings>
        <OperationalStates>
          <OperationalState ID="EventRaisedWarning" MonitorTypeStateID="EventRaisedWRN" HealthState="Warning" />
          <OperationalState ID="EventRaisedError" MonitorTypeStateID="EventRaisedERR" HealthState="Error" />
          <OperationalState ID="ManualReset" MonitorTypeStateID="ManualReset" HealthState="Success" />
        </OperationalStates>
        <Configuration>
          <ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
          <LogName>Application</LogName>
          <ExpressionWarning>
            <And>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="UnsignedInteger">1</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="String">PublisherName</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="String">EventCreate</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </And>
          </ExpressionWarning>
          <ExpressionError>
            <And>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="UnsignedInteger">2</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <XPathQuery Type="String">PublisherName</XPathQuery>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value Type="String">EventCreate</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </And>
          </ExpressionError>
        </Configuration>
      </UnitMonitor>
    </Monitors>
    <Recoveries>
      <Recovery ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.StateErrorResetRecovery" Accessibility="Internal" Enabled="onStandardMonitoring" Target="SC!Microsoft.SystemCenter.RootManagementServer" Monitor="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" ResetMonitor="false" ExecuteOnState="Error" Remotable="true" Timeout="300">
        <Category>Maintenance</Category>
        <WriteAction ID="Reset" TypeID="MicrosoftSystemCenterCommunityMonitorsExtensions!Microsoft.SystemCenter.Community.Health.ResetTargetStateCommandExecuterAction">
          <ApplicationName><![CDATA[%windir%\system32\sc.exe]]></ApplicationName>
          <WorkingDirectory><![CDATA[%windir%\system32]]></WorkingDirectory>
          <CommandLine>\\$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$ query HealthService</CommandLine>
          <TimeoutSeconds>300</TimeoutSeconds>
          <RequireOutput>true</RequireOutput>
          <MonitorId>$MPElement[Name="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor"]$</MonitorId>
        </WriteAction>
      </Recovery>
      <Recovery ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.StateWarningResetRecovery" Accessibility="Internal" Enabled="onStandardMonitoring" Target="SC!Microsoft.SystemCenter.RootManagementServer" Monitor="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" ResetMonitor="false" ExecuteOnState="Warning" Remotable="true" Timeout="300">
        <Category>Maintenance</Category>
        <WriteAction ID="Reset" TypeID="MicrosoftSystemCenterCommunityMonitorsExtensions!Microsoft.SystemCenter.Community.Health.ResetTargetStateAction">
          <MonitorId>$MPElement[Name="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor"]$</MonitorId>
        </WriteAction>
      </Recovery>
    </Recoveries>
  </Monitoring>
  <Presentation>
    <Views>
      <View ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.View" Accessibility="Internal" Enabled="true" Target="SC!Microsoft.SystemCenter.RootManagementServer" TypeID="SC!Microsoft.SystemCenter.StateViewType" Visible="true">
        <Category>StateCollection</Category>
        <Criteria />
      </View>
    </Views>
    <FolderItems>
      <FolderItem ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.View" Folder="SC!Microsoft.SystemCenter.Monitoring.ViewFolder.Root" />
    </FolderItems>
    <StringResources>
      <StringResource ID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor_AlertMessageResourceID" />
    </StringResources>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="true">
      <DisplayStrings>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample">
          <Name>System Center Community MP Reset State Recovery Sample</Name>
          <Description>This management pack defines modules and workflows to sample capability of the recovery to hard reset the state of its monitor.</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor">
          <Name>Sample Event Based Monitor</Name>
          <Description>This is simple event based monitor serving the purpose of explaining how to hard reset the state of the monitor using recovery.</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" SubElementID="EventRaisedError">
          <Name>Error Event</Name>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" SubElementID="EventRaisedWarning">
          <Name>Warning Event</Name>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" SubElementID="ManualReset">
          <Name>Manual Reset</Name>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor_AlertMessageResourceID">
          <Name>Alert Raised By Sample Event Based Monitor</Name>
          <Description>Alert description:

Target: {0}

Event ID: {1}

Event Description: {2}</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.SingleEventLogManualReset3StateMonitorType">
          <Name>Event Based Monitor With Manual Reset</Name>
          <Description>Three states monitor, event based and manual reset states.</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.StateErrorResetRecovery">
          <Name>Sample Error Recovery</Name>
          <Description>This is recovery started for Error state which will execute command line and at the end of its execution requires monitor state reset.</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.StateWarningResetRecovery">
          <Name>Sample Warning Recovery</Name>
          <Description>This is recovery started for Warning state which will at the end of its execution requires monitor state reset.</Description>
        </DisplayString>
        <DisplayString ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.View">
          <Name>RMS </Name>
          <Description>State view</Description>
        </DisplayString>
      </DisplayStrings>
      <KnowledgeArticles>
        <KnowledgeArticle ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample" Visible="true">
          <MamlContent>
            <maml:section xmlns:maml="http://schemas.microsoft.com/maml/2004/10">
              <maml:title>Summary</maml:title>
              <maml:para>This management pack defines modules and workflows to sample capability of the recovery to hard reset the state of its monitor.</maml:para>
            </maml:section>
          </MamlContent>
        </KnowledgeArticle>
        <KnowledgeArticle ElementID="Microsoft.SystemCenter.Community.Monitors.RecoverySample.EventBasedMonitor" Visible="true">
          <MamlContent>
            <maml:section xmlns:maml="http://schemas.microsoft.com/maml/2004/10">
              <maml:title>Summary</maml:title>
              <maml:para>This is simple event based monitor serving the purpose of explaining how to hard reset the state of the monitor using recovery.</maml:para>
            </maml:section>
            <maml:section xmlns:maml="http://schemas.microsoft.com/maml/2004/10">
              <maml:title>Configuration</maml:title>
              <maml:para>Uses event created by EventCreate inside of Application log</maml:para>
            </maml:section>
          </MamlContent>
        </KnowledgeArticle>
      </KnowledgeArticles>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>