How to Create Outbound Connectors

System Center

Updated: May 22, 2009

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

Outbound connectors allow you to take performance, event, and alert data from Operations Manager and insert it into an external management system. The following process describes how to implement an outbound connector:

  1. Create a new instance of the MonitoringConnector class that will represent the connector.

  2. Create an alert subscription. This is a different subscription than one that is created for alert notifications. Operations Manager uses the alert subscription as the criteria that determines which alerts should be marked for the connector.

  3. If the connector needs to retrieve alerts from multiple tiers, the connector must register with all the tiers from which it needs to retrieve alerts.

  4. Regularly call GetMonitoringAlerts to retrieve alerts. There is no notification mechanism for the connector to be notified when new alerts are available for the connector, so the method must be called multiple times to retrieve all the alerts.

  5. The connector must acknowledge all the alerts it receives, otherwise, the connector receives duplicate alerts.

The following example shows how to create an outbound connector that allows you to take alert data from Operations Manager and insert it into an external management system.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.ConnectorFramework;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Monitoring;
using System.Collections.ObjectModel;
using System.Threading;
 
namespace OutboundConnector
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementGroup mg = new ManagementGroup("localhost");
            ConnectorFrameworkAdministration cfAdmin = mg.GetConnectorFrameworkAdministration();
            Guid connectorGuid = new Guid("{6A1F8C0E-B8F1-4147-8C9B-5A2F98F10003}");
            MonitoringConnector connector;
 
            try
            {
                if (args.Length == 1)
                {
                    if (args[0] == "InstallConnector")
                    {
                        ConnectorInfo info = new ConnectorInfo();
 
                        info.Description = "Sample connector";
                        info.DisplayName = "Sample connector";
                        info.Name = "Sample connector";
 
                        connector = cfAdmin.Setup(info, connectorGuid);
 
                        connector.Initialize();
                    }
                    else if (args[0] == "UninstallConnector")
                    {
                        connector = cfAdmin.GetMonitoringConnector(connectorGuid);
                        ReadOnlyCollection<MonitoringConnectorSubscription> subscriptions;
 
                        subscriptions = cfAdmin.GetConnectorSubscriptions();
 
                        foreach (MonitoringConnectorSubscription subscription in subscriptions)
                        {
                            if (subscription.MonitoringConnectorId == connectorGuid)
                            {
                                cfAdmin.DeleteConnectorSubscription(subscription);
                            }
                        }
 
                        connector.Uninitialize();
                        cfAdmin.Cleanup(connector);
                    }
 
                    return;
                }
 
                connector = cfAdmin.GetMonitoringConnector(connectorGuid);
 
                while (true)
                {
                    ReadOnlyCollection<ConnectorMonitoringAlert> alerts;
 
                    alerts = connector.GetMonitoringAlerts();
 
                    if (alerts.Count > 0)
                    {
                        connector.AcknowledgeMonitoringAlerts(alerts);
                    }

                    foreach (ConnectorMonitoringAlert alert in alerts)
                    {
                        //Send the alert to the other management system with the appropriate API 
                        //from the other management system.
                        //Add a comment to the alert.
 
                        alert.Update("Alert has been forwarded to the management system");
                    }
 
                    //Wait for a minute before checking for new alerts again.
                    Thread.Sleep(60 * 1000);
                }                
            }
            catch (MonitoringException error)
            {
                Console.WriteLine(error.Message);
            }
        }
    }
}

Show: