How to Create an Override for a Discovery

System Center

Updated: May 22, 2009

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

You can create an override for a property or configuration parameter for a discovery. A property override changes the default value of a discovery property, and a configuration override changes the default value of a custom configuration setting for a discovery. If you want to create an override for a discovery, use the ManagementPackDiscoveryPropertyOverride or ManagementPackDiscoveryConfigurationOverride class. These classes are derived from the ManagementPackDiscoveryOverride class.

Only the Enabled property can be overridden for discoveries. To figure out which parameters can be overridden, you must look at the definition of the discovery in the Management Pack that defines the discovery. All the parameters that can be overridden are defined in the OverrideableParameters element of the discovery. You can also call the GetOverrideableParameters method to get the list of parameters programmatically.

The following example creates an override for the Enabled property of a discovery.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;

namespace SDKSamples
    class Program
        static void Main(string[] args)
            ManagementGroup                             mg;
            ManagementPack                              mp;
            MonitoringClassCriteria                     classCriteria;
            MonitoringClass                             monitoringClass;
            MonitoringDiscoveryCriteria                 discoveryCriteria;
            MonitoringDiscovery                         discovery;
            ManagementPackDiscoveryPropertyOverride     discoveryOverride;

            mg = new ManagementGroup("localhost");

            mp = mg.GetManagementPacks("OverrideTestMP")[0];

            classCriteria = new MonitoringClassCriteria("Name='Microsoft.SQLServer.2005.DBEngine'");

            monitoringClass = mg.GetMonitoringClasses(classCriteria)[0];

            discoveryCriteria = new MonitoringDiscoveryCriteria("Name='Microsoft.SQLServer.2005.DatabaseDiscoveryRule'");

            discovery = mg.GetMonitoringDiscoveries(discoveryCriteria)[0];

            discoveryOverride = new ManagementPackDiscoveryPropertyOverride(mp, "SampleDiscoveryOverride");

            discoveryOverride.Discovery     = discovery;
            discoveryOverride.Property      = ManagementPackWorkflowProperty.Enabled;
            discoveryOverride.Value         = "false";
            discoveryOverride.Context       = monitoringClass;
            discoveryOverride.DisplayName   = "SampleDiscoveryOverride";

            //Save the changes into the management pack.