Share via


How to Query for Recoveries

Applies To: System Center 2012 - Operations Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

A recovery object is triggered by a monitor state change or by a diagnostic object operation. The recovery workflow performs an action that can change the state of a monitored component.

You can query for recovery objects by defining criteria in the Microsoft.EnterpriseManagement.Configuration.ManagementPackRecoveryCriteria class constructor. The criteria syntax is defined in Criteria Expression Syntax. The following property names are valid names that can be used in the criteria expression:

  • Id

  • Name

  • Accessibility

  • ManagementPackId

  • Enabled

  • Target

  • Monitor

  • ResetMonitor

  • ExecuteOnState

  • ExecuteOnDiagnostic

  • Remotable

  • CategoryOld

  • Timeout

  • TimeAdded

  • LastModified

  • DisplayName

  • Description

  • HasNonCategoryOverride

  • Category

The following code queries for all recovery objects that contain SystemCenter in their name:

/// <summary> 
/// Query for recoveries.
/// </summary>
using System;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;

namespace SDKSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementGroup mg = new ManagementGroup("localhost");

            // The criteria specifies that you want to collect
            // all the recoveries that contain SystemCenter in their name.
            ManagementPackRecoveryCriteria recoveryCriteria =
                new ManagementPackRecoveryCriteria(
                "Name LIKE '%SystemCenter%'");

            Console.WriteLine("Querying for data...");
            IList<ManagementPackRecovery> recoveries =
                mg.Monitoring.GetRecoveries(recoveryCriteria);

            // Display information about each recovery.
            foreach (ManagementPackRecovery recovery in recoveries)
            {
                Console.WriteLine("Recovery name: " + recovery.Name);
                Console.WriteLine("Status: " + recovery.Status.ToString());
                Console.WriteLine("Category: " + recovery.Category);
                Console.WriteLine("Description: " + recovery.Description +
                    Environment.NewLine);
            }
        }
    }
}

See Also

Concepts

Operations Manager Data Queries Overview