How to Create an Override for a Monitor

Updated: January 31, 2012

Applies To: System Center 2012 - Operations Manager

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

The following properties can be overridden for unit monitors:

  • Enabled

  • GenerateAlert

  • AutoResolve

  • AlertPriority

  • AlertOnState

  • AlertSeverity

The following properties can be overridden for rollup monitors:

  • Enabled

  • Algorithm

  • AutoResolve

  • AlertPriority

  • AlertOnState

  • AlertSeverity

The following properties can be overridden for dependency monitors:

  • Enabled

  • Algorithm

  • AutoResolve

  • AlertPriority

  • AlertOnState

  • AlertSeverity

  • MemberInMaintenance

  • MemberUnavailable

  • IgnoreMemberInMaintenance

  • IgnoreMemberUnavailable

To figure out which parameters can be overridden, you must look at the definition of the monitor in the management pack that defines the monitor. All the parameters that can be overridden are defined in the OverrideableParameters element of the monitor. You can also call the method to get the list of parameters programmatically.

The following example creates an override for the Enabled property of a monitor:

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;
			ManagementPackClassCriteria classCriteria;
			ManagementPackClass monitoringClass;
			ManagementPackMonitorCriteria						 monitorCriteria;
			ManagementPackMonitor				 monitor;
			ManagementPackMonitorPropertyOverride   monitorOverride;

			mg = new ManagementGroup("localhost");

			mp = mg.ManagementPacks.GetManagementPacks(new ManagementPackCriteria("Name='OverrideTestMP'"))[0];

			classCriteria = new ManagementPackClassCriteria("Name='Microsoft.SQLServer.2005.Database'");

			monitoringClass = mg.EntityTypes.GetClasses(classCriteria)[0];

			monitorCriteria = new ManagementPackMonitorCriteria("DisplayName='Database Status'");

			monitor = mg.Monitoring.GetMonitors(monitorCriteria)[0];

			monitorOverride = new ManagementPackMonitorPropertyOverride(mp, "SampleMonitorOverride");

			monitorOverride.Monitor	 = monitor;
			monitorOverride.Property	= ManagementPackMonitorProperty.Enabled;
			monitorOverride.Value	 = "false";
			monitorOverride.Context	 = monitoringClass;
			monitorOverride.DisplayName = "SampleMonitorOverride";

			mp.Verify();
		
			//Save the changes into the management pack.
			mp.AcceptChanges();
	}	
}
}

See Also