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 Microsoft.EnterpriseManagement.ConnectorFramework.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.

Visual Basic  Copy Code
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.ConnectorFramework
Imports Microsoft.EnterpriseManagement.Common
Imports Microsoft.EnterpriseManagement.Monitoring
Imports System.Collections.ObjectModel
Imports System.Threading

Namespace SDKSamples
	Class Program
		Public Overloads Shared Function Main(ByVal args() As String) As Integer

			Dim mg As ManagementGroup = New ManagementGroup("localhost")
			Dim cfAdmin As ConnectorFrameworkAdministration = mg.GetConnectorFrameworkAdministration()
			Dim connectorGuid As Guid = New Guid("{6A1F8C0E-B8F1-4147-8C9B-5A2F98F10003}")
			Dim connector As MonitoringConnector

			Try
				If (args.Length = 1) Then

					If (args(0) = "InstallConnector") Then

						Dim info As ConnectorInfo = New ConnectorInfo()

						info.Description = "Sample connector"
						info.DisplayName = "Sample connector"
						info.Name = "Sample connector"

						connector = cfAdmin.Setup(info, connectorGuid)

						connector.Initialize()
					End If
					If (args(0) = "UninstallConnector") Then

						connector = cfAdmin.GetMonitoringConnector(connectorGuid)
						Dim subscriptions As ReadOnlyCollection(Of MonitoringConnectorSubscription)

						subscriptions = cfAdmin.GetConnectorSubscriptions()

						For Each subscription As MonitoringConnectorSubscription In subscriptions

							If (subscription.MonitoringConnectorId = connectorGuid) Then
								cfAdmin.DeleteConnectorSubscription(subscription)
							End If
						Next

						connector.Uninitialize()
						cfAdmin.Cleanup(connector)
					End If

					Return 0
				End If

				connector = cfAdmin.GetMonitoringConnector(connectorGuid)

				While (True)

					Dim alerts As ReadOnlyCollection(Of ConnectorMonitoringAlert)
					alerts = connector.GetMonitoringAlerts()

					If (alerts.Count > 0) Then
						connector.AcknowledgeMonitoringAlerts(alerts)
					End If

					For Each alert As ConnectorMonitoringAlert 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")
					Next

					' Wait for a minute before checking for new alerts again.
					Thread.Sleep(60 * 1000)
				End While
			Catch e As MonitoringException

				Console.WriteLine(e.Message)
			End Try

		End Function
	End Class
End Namespace
C#  Copy Code
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);
		}
	}
}
}

Send comments about this topic to Microsoft.