How to Create Outbound Connectors
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.]
You can use outbound connectors 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:
Create a new instance of the MonitoringConnector class that will represent the connector.
Create an alert subscription. This is a different subscription than the subscription that is created for alert notifications. Operations Manager uses the alert subscription as the criteria that determine which alerts should be marked for the connector.
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.
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; therefore the method must be called multiple times to retrieve all the alerts.
The connector must acknowledge all the alerts that it receives; otherwise, the connector receives duplicate alerts.
The following example shows how to create an outbound connector that you can use 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");
IConnectorFrameworkManagement icfm = mg.ConnectorFramework;
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 = icfm.Setup(info, connectorGuid);
connector.Initialize();
}
else if (args[0] == "UninstallConnector")
{
connector = icfm.GetConnector(connectorGuid);
IList<MonitoringConnectorSubscription> subscriptions;
subscriptions = icfm.GetConnectorSubscriptions();
foreach (MonitoringConnectorSubscription subscription in subscriptions)
{
if (subscription.MonitoringConnectorId == connectorGuid)
{
icfm.DeleteConnectorSubscription(subscription);
}
}
connector.Uninitialize();
icfm.Cleanup(connector);
}
return;
}
connector = icfm.GetConnector(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 (EnterpriseManagementException error)
{
Console.WriteLine(error.Message);
}
}
}
}