Share via


How to Query for Recoveries

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

A recovery object is triggered by a monitor state change or by a diagnostic object execution. 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 MonitoringRecoveryCriteria 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

  • TargetMonitoringClassId

  • MonitorId

  • ResetMonitor

  • ExecuteOnState

  • MonitoringDiagnosticId

  • Remotable

  • Category

  • Timeout

  • TimeAdded

  • LastModified

  • DisplayName

  • Description

  • HasNonCategoryOverride

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

/// <summary> 
/// Query for recoveries.
/// </summary>
using System;
using System.Collections.ObjectModel;
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.
            MonitoringRecoveryCriteria recoveryCriteria =
                new MonitoringRecoveryCriteria(
                "Name LIKE '%SystemCenter%'");

            Console.WriteLine("Querying for data...");
            ReadOnlyCollection<MonitoringRecovery> recoveries =
                mg.GetMonitoringRecoveries(recoveryCriteria);

            // Display information about each recovery.
            foreach (MonitoringRecovery 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);
            }
        }
    }
}