Udostępnij za pośrednictwem


How to Query for Discoveries

Applies To: System Center 2012 - Operations Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

In Operations Manager, 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, Windows Management Instrumentation (WMI), scripts, Microsoft OLE DB, Lightweight Directory Access Protocol (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.ManagementPackDiscoveryCriteria 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

  • Target

  • ConfirmDelivery

  • Remotable

  • CategoryOld

  • Priority

  • TimeAdded

  • LastModified

  • DisplayName

  • Description

  • HasNonCategoryOverride

  • CategoryHasNonCategoryOverride

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.Generic;
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.
            ManagementPackDiscoveryCriteria discoveryCriteria =
                new ManagementPackDiscoveryCriteria(
                "Priority <= 2");

            Console.WriteLine("Querying for data...");
            IList<ManagementPackDiscovery> discoveries =
                mg.Monitoring.GetDiscoveries(discoveryCriteria);

            // Display information about each discovery.
            foreach (ManagementPackDiscovery 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);
            }
        }
    }
}

See Also

Concepts

Operations Manager Data Queries Overview