Share via


How to Query for Management Packs

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, management packs are XML files that can have either an .mp or an .xml extension and that can contain monitoring settings for applications and services. After a management pack is imported into a management server, it immediately begins monitoring objects, based on default configurations and thresholds that are already set by the author of the management pack. You can query for management packs by defining criteria in the Microsoft.EnterpriseManagement.Configuration.ManagementPackCriteria 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

  • Sealed

  • Name

  • FriendlyName

  • Version

  • KeyToken

  • LastModified

  • TimeCreated

  • DisplayName

  • Description

  • VersionId

  • Category

The following code queries for all management packs that were created after 10/25/2006:

/// <summary> 
/// Query for Management Packs.
/// </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
            // sealed management packs created after 10/25/2006.
            ManagementPackCriteria mpCriteria =
                new ManagementPackCriteria(
                "Sealed = 1 AND TimeCreated >= '" + 
                new DateTime(2006, 10, 25).ToString("G") + "'");

            Console.WriteLine("Querying for data...");
            IList<ManagementPack> managementPacks =
                mg.ManagementPacks.GetManagementPacks(mpCriteria);

            // Display information about each Management Pack.
            foreach (ManagementPack mp in managementPacks)
            {
                Console.WriteLine("Monitor name: " + mp.Name);
                Console.WriteLine("Sealed: " + mp.Sealed);
                Console.WriteLine("Id: " + mp.Id);
                Console.WriteLine("Description: " + mp.Description +
                    Environment.NewLine);
            }
        }
    }
}

See Also

Concepts

Operations Manager Data Queries Overview