How to Query for Discoveries
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
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 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:
Id
Name
Accessibility
ManagementPackId
Enabled
TargetMonitoringClassId
ConfirmDelivery
Remotable
Category
Priority
TimeAdded
LastModified
DisplayName
Description
HasNonCategoryOverride
The following code queries for all discoveries with a priority less than or equal to 2.
/// <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);
}
}
}
}