Compartilhar via


Getting Started Developing an SDK Client Application

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

To get started using the Operations Manager SDK, create a new project in Visual Studio, and, in your project, add references to the following Operations Manager class libraries:

  • Microsoft.EnterpriseManagement.OperationsManager.dll

  • Microsoft.EnterpriseManagement.OperationsManager.Common.dll

The class libraries allow you to programmatically access Operations Manager data and functionality.

These assemblies are installed in the %ProgramFiles%\System Center Operations Manager 2007\SDK Binaries directory when you install Operations Manager 2007.

After you add references to the Operations Manager class libraries, create a connection to the SDK Service. The SDK Service is a Windows service that runs on the Root Management Server in a Management Group.

You can create a connection to the SDK Service by using the Connect method. This method returns a ManagementGroup object, which is the primary object for accessing most Operations Manager features and data. For more information, see How to Connect an Operations Manager SDK Client to the SDK Service.

Accessing Operations Manager Data

The Operations Manager class libraries provide classes that contain methods for accessing the data from an SDK client application. For example, to get information about the Management Packs installed in a Management Group, you can use the GetManagementPacks method. The method returns a read-only collection of ManagementPack objects, each of which contains data about a specific Management Pack.

For more information about the Operations Manager classes, see Operations Manager 2007 R2 SDK Reference.

The following example shows how to access Operations Manager data by using the ManagementGroup class. This example gets the alerts for all the Windows computers in the management group and displays the health state of the computer.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Xml;
using Microsoft.EnterpriseManagement.Monitoring.Security;

namespace SDKSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ReadOnlyCollection<PartialMonitoringObject> windowsComputerObjects;
            ManagementGroup managementGroup;
            MonitoringClass windowsComputerClass;

            managementGroup = new ManagementGroup("localhost");

            windowsComputerClass = managementGroup.GetMonitoringClass(SystemMonitoringClass.WindowsComputer);

            windowsComputerObjects = managementGroup.GetPartialMonitoringObjects(windowsComputerClass);

            foreach (PartialMonitoringObject windowsComputerObject in windowsComputerObjects)
            {
                ReadOnlyCollection<MonitoringAlert> alerts;

                alerts = windowsComputerObject.GetMonitoringAlerts();

                Console.WriteLine("{0} - State: {1} - Number of alerts: {2}",
                                  windowsComputerObject.DisplayName,
                                  windowsComputerObject.HealthState.ToString(),
                                  alerts.Count);

                foreach (MonitoringAlert alert in alerts)
                {
                    Console.WriteLine("{0}", alert.Name);
                }
            }
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Configuration
Imports Microsoft.EnterpriseManagement.Monitoring
Imports System.Collections.ObjectModel
Imports System.Diagnostics
Imports System.Xml
Imports Microsoft.EnterpriseManagement.Monitoring.Security


Namespace SDKSamples
    Class Program
        Public Overloads Shared Function Main(ByVal args() As String) As Integer
            Dim windowsComputerObjects As ReadOnlyCollection(Of PartialMonitoringObject)
            Dim managementGroup As ManagementGroup
            Dim windowsComputerClass As MonitoringClass

            managementGroup = New ManagementGroup("localhost")

            windowsComputerClass = managementGroup.GetMonitoringClass(SystemMonitoringClass.WindowsComputer)

            windowsComputerObjects = managementGroup.GetPartialMonitoringObjects(windowsComputerClass)

            For Each windowsComputerObject As PartialMonitoringObject In windowsComputerObjects
                Dim alerts As ReadOnlyCollection(Of MonitoringAlert)

                alerts = windowsComputerObject.GetMonitoringAlerts()

                Console.WriteLine("{0} - State: {1} - Number of alerts: {2}", _
                    windowsComputerObject.DisplayName, _
                    windowsComputerObject.HealthState.ToString(), alerts.Count)

                For Each alert As MonitoringAlert In alerts
                    Console.WriteLine("{0}", alert.Name)
                Next alert
            Next windowsComputerObject

        End Function 'Main

    End Class 'Program
End Namespace 'SDKSamples

Additional Information

The following sections of the documentation contain more information and code examples that explain how to use the Operations Manager SDK.

See Also

Concepts

Operations Manager SDK Architecture Overview
System Center Operations Manager 2007 R2 SDK