Diagnostics allow you to take action on alerts, state changes, and other significant issues that are generated by monitoring objects. You can query for diagnostics by defining criteria in the Microsoft.EnterpriseManagement.Configuration.MonitoringDiagnosticCriteria class constructor. The criteria syntax is defined in Criteria Expression Syntax. The following property names are valid names that can be used in the criteria expression:

The following code queries for all diagnostics that contain SystemCenter in their name.

C#  Copy Code
/// <summary> 
/// Query for diagnostics.
/// </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 diagnostics that contain SystemCenter in their name.
			MonitoringDiagnosticCriteria diagnosticCriteria =
				new MonitoringDiagnosticCriteria(
				"Name LIKE '%SystemCenter%'");

			Console.WriteLine("Querying for data...");
			ReadOnlyCollection<MonitoringDiagnostic> diagnostics =

			// Display information about each diagnostic.
			foreach (MonitoringDiagnostic diagnostic in diagnostics)
				Console.WriteLine("Diagnostic name: " + diagnostic.Name);
				Console.WriteLine("Status: " + diagnostic.Status.ToString());
				Console.WriteLine("Category: " + diagnostic.Category);
				Console.WriteLine("Description: " + diagnostic.Description +

Send comments about this topic to Microsoft.