How to Create an Override for a Diagnostic

Updated: January 31, 2012

Applies To: System Center 2012 - Operations Manager

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

Only the Enabled property can be overridden for diagnostics. To figure out which parameters can be overridden, you must look at the definition of the diagnostic in the management pack that defines the diagnostic. All the parameters that can be overridden are defined in the OverrideableParameters element of the diagnostic. 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 diagnostic:

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;
			ManagementPackClass						 monitoringClass;
			ManagementPackDiagnosticCriteria			diagnosticCriteria;
			ManagementPackDiagnostic diagnostic;
			ManagementPackDiagnosticPropertyOverride	diagnosticOverride;
		
			mg = new ManagementGroup("localhost");

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

			monitoringClass = mg.EntityTypes.GetClass(SystemMonitoringClass.WindowsComputer);

			diagnosticCriteria = new ManagementPackDiagnosticCriteria("Name='Microsoft.SystemCenter.ManagedComputer.Ping.ICMPDiagnostic'");

			diagnostic = mg.Monitoring.GetDiagnostics(diagnosticCriteria)[0];

			diagnosticOverride = new ManagementPackDiagnosticPropertyOverride(mp, "SampleDiagnosticOverride");

			diagnosticOverride.Diagnostic   = diagnostic;
			diagnosticOverride.Property	 = ManagementPackWorkflowProperty.Enabled;
			diagnosticOverride.Value		= "false";
			diagnosticOverride.Context	= monitoringClass;
			diagnosticOverride.DisplayName  = "SampleDiagnosticOverride";

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

See Also