Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to Display Operations Manager Data

System Center

Updated: May 22, 2009

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

By using the Operations Manager class libraries, you can programmatically access operations data that is stored in the Operations Manager database (such as alert, event, and performance data). You can use criteria classes to narrow the search results when you are accessing operations data. For example, you can use the MonitoringEventCriteria class to narrow the search results for event data and the MonitoringAlertCriteria class to narrow the search results for alert data.


The following example demonstrates how to display information about health service alerts that are stored in the Operations Manager database. The example also shows how to display information about stored events that are numbered 187.

/// <summary> 
/// Displays information about health service alerts 
/// that have occurred in the management group.
/// </summary>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Text;

namespace SDKSamples
    class Program
        static void Main(string[] args)
            ManagementGroup mg = new ManagementGroup("localhost");

            // Display alerts.
            Console.WriteLine("Displaying alert data...");

            MonitoringAlertCriteria alertCriteria = 
                new MonitoringAlertCriteria("Description LIKE '%health service%'");
            ReadOnlyCollection<MonitoringAlert> alerts = 

            if (alerts.Count > 0)
                foreach (MonitoringAlert alert in alerts)
                    Console.WriteLine("Name: " + alert.Name);
                    Console.WriteLine("Description: " + alert.Description);
                    Console.WriteLine("Severity: " + alert.Severity.ToString());
                    Console.WriteLine("Resolution state: " + alert.ResolutionState.ToString());
                Console.WriteLine("No alerts found.");

            // Display events.
            Console.WriteLine("Displaying events...");
            MonitoringEventCriteria eventCriteria = 
                new MonitoringEventCriteria("Number = 187");
            ReadOnlyCollection<MonitoringEvent> events = 

            if (events.Count > 0)
                foreach (MonitoringEvent OMEvent in events)
                    Console.WriteLine("Number: " + OMEvent.Number.ToString());
                    Console.WriteLine("Description: " + OMEvent.Description);
                    Console.WriteLine("Channel: " + OMEvent.Channel);
                    Console.WriteLine("Computer: " + OMEvent.LoggingComputer);
                Console.WriteLine("No events with number 187 found.");

See Also

© 2015 Microsoft