Share via


How to Query for Overrides

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

Overrides adjust the configuration of Operations Manager monitoring settings for monitors, attributes, object discoveries, and rules. You can query for overrides by defining criteria in the MonitoringOverrideCriteria 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

  • ManagementPackId

  • TargetId

  • ContextId

  • ContextObjectId

  • Value

  • Enforced

  • DisplayName

  • Description

  • TimeAdded

  • LastModified

The following code queries for all the overrides that are enforced.

/// <summary> 
/// Query for overrides.
/// </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 overrides that are enforced.
            MonitoringOverrideCriteria overrideCriteria =
                new MonitoringOverrideCriteria(
                "Enforced = 1");

            Console.WriteLine("Querying for data...");
            ReadOnlyCollection<ManagementPackOverride> overrides =
                mg.GetMonitoringOverrides(overrideCriteria);

            // Display information about each override.
            foreach (ManagementPackOverride mpOverride in overrides)
            {
                Console.WriteLine("Override name: " + mpOverride.Name);
                Console.WriteLine("Status: " + mpOverride.Status);
                Console.WriteLine("Context: " + mpOverride.Context.Name);
                Console.WriteLine("Description: " + mpOverride.Description +
                    Environment.NewLine);
            }
        }
    }
}