In Operations Manager 2007, object discoveries are used to find the specific objects on a network that need to be monitored. The object discoveries are defined in a Management Pack. The object discoveries can use the registry, WMI, scripts, OLE DB, LDAP, or even custom managed code to find objects on a network. If an object discovery finds objects on your network that you do not want to monitor, you can limit the object discoveries scope by using overrides.

You can query for discoveries by defining criteria in the Microsoft.EnterpriseManagement.Configuration.MonitoringDiscoveryCriteria 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 discoveries with a priority less than or equal to 2.

C#  Copy Code
/// <summary> 
/// Query for discoveries.
/// </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 discoveries with a priority less than or equal to 2.
			MonitoringDiscoveryCriteria discoveryCriteria =
				new MonitoringDiscoveryCriteria(
				"Priority <= 2");

			Console.WriteLine("Querying for data...");
			ReadOnlyCollection<MonitoringDiscovery> discoveries =
				mg.GetMonitoringDiscoveries(discoveryCriteria);

			// Display information about each discovery.
			foreach (MonitoringDiscovery discovery in discoveries)
			{
				Console.WriteLine("Discovery name: " + discovery.Name);
				Console.WriteLine("Status: " + discovery.Status.ToString());
				Console.WriteLine("Category: " + discovery.Category);
				Console.WriteLine("Description: " + discovery.Description +
					Environment.NewLine);
		}
	}
}
}

Send comments about this topic to Microsoft.
[an error occurred while processing this directive]