Share via


How to Query for All Rules That Have a Noncategory Override

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.]

You can query for rules that have a noncategory override by defining criteria in the Microsoft.EnterpriseManagement.Configuration.ManagementPackRuleCriteria class constructor. The criteria syntax is defined in Criteria Expression Syntax.

The following code example queries for all the rules that have a noncategory override:

/// <summary> 
/// Query for rules that have a non-category override.
/// </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 rules that have a non-category override.
            ManagementPackRuleCriteria ruleCriteria =
                new ManagementPackRuleCriteria(
                "HasNonCategoryOverride = 1");

            Console.WriteLine("Querying for data...");
            IList<ManagementPackRule> monitoringRules =
                mg.Monitoring.GetRules(ruleCriteria);

            // Display information about each rule.
            foreach (ManagementPackRule rule in monitoringRules)
            {
                Console.WriteLine("Rule name: " + rule.Name);
                Console.WriteLine("Category: " + rule.Category);
                Console.WriteLine("Enabled: " + rule.Enabled.ToString());
                Console.WriteLine("Has non-category override: " + rule.HasNonCategoryOverride);
                Console.WriteLine("Description: " + rule.Description +
                    Environment.NewLine);
            }
        }
    }
}

See Also

Concepts

Operations Manager Data Queries Overview