How to Query for All Rules That Have a Non-Category Override
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
You can query for rules that have a non-category override by defining criteria in the MonitoringRuleCriteria class constructor. The criteria syntax is defined in Criteria Expression Syntax.
The following code example queries for all the rules that have a non-category override.
/// <summary>
/// Query for rules that have a non-category override.
/// </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 rules that have a non-category override.
MonitoringRuleCriteria ruleCriteria =
new MonitoringRuleCriteria(
"HasNonCategoryOverride = 1");
Console.WriteLine("Querying for data...");
ReadOnlyCollection<MonitoringRule> monitoringRules =
mg.GetMonitoringRules(ruleCriteria);
// Display information about each rule.
foreach (MonitoringRule 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);
}
}
}
}