How to Create or Remove a Connector by Using the Operations Manager Class Libraries
System Center
Updated: May 22, 2009
Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007
You can use the Operations Manager class libraries to create a connector that allows Operations Manager to communicate with an external system. If the external system runs on a Windows-based computer, using the class libraries is the preferred method for creating the connector.
Example
The following example demonstrates how to create a connector and how to remove a connector by using the Operations Manager class libraries.
/// <summary> /// Creates a new connector by using the Operations Manager /// class libraries. /// </summary> using System; using System.Collections.ObjectModel; using Microsoft.EnterpriseManagement; using Microsoft.EnterpriseManagement.ConnectorFramework; using System.IO; using System.Text; using System.Xml; namespace SDKSamples { class Program { static void Main(string[] args) { ManagementGroup mg = new ManagementGroup("localhost"); ConnectorFrameworkAdministration omcf = mg.GetConnectorFrameworkAdministration(); MonitoringConnector connector = null; Guid connectorId = Guid.NewGuid(); // Create a new connector. ConnectorInfo myConnectorInfo = new ConnectorInfo(); myConnectorInfo.Name = "myConnector"; myConnectorInfo.DisplayName = "My Connector"; myConnectorInfo.Description = "This connector was created using the Operations Manager class libraries."; connector = omcf.Setup(myConnectorInfo, connectorId); connector.Initialize(); Console.WriteLine("Created " + connector.Name + " with ID: " + connector.Id); // Remove the connector when finished with it. Console.WriteLine("Removing " + connector.Name); connector.Uninitialize(); omcf.Cleanup(connector); Console.WriteLine("Connector removed."); } } }
See Also
Show: