次の方法で共有


ConnectorFrameworkAdministration.InsertConnectorSubscription Method (MonitoringConnectorSubscription)

 

Applies To: Operations Manager for System Center 2012

Adds a newly created subscription to a monitoring connector.

Namespace:   Microsoft.EnterpriseManagement.ConnectorFramework
Assembly:  Microsoft.EnterpriseManagement.OperationsManager (in Microsoft.EnterpriseManagement.OperationsManager.dll)

Syntax

public void InsertConnectorSubscription(
    MonitoringConnectorSubscription connectorSubscription
)
public:
void InsertConnectorSubscription(
    MonitoringConnectorSubscription^ connectorSubscription
)
member InsertConnectorSubscription : 
        connectorSubscription:MonitoringConnectorSubscription -> unit
Public Sub InsertConnectorSubscription (
    connectorSubscription As MonitoringConnectorSubscription
)

Parameters

Remarks

Product connectors subscribe to alerts and forward them to other products.

Examples

The following example assumes there is at least one connector created in the Operations Manager. The example gets the first connector and adds a subscription to that connector.

using System;
using System.Collections.ObjectModel;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Administration;
using Microsoft.EnterpriseManagement.Monitoring;
using Microsoft.EnterpriseManagement.ConnectorFramework;
using Microsoft.EnterpriseManagement.Common;
using Microsoft.EnterpriseManagement.Configuration;


namespace ConnectorSample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Connect to a management group
            ManagementGroup mgmtGroup = new ManagementGroup("localhost");
            // Get a reference to the connector framework administration object.
            ConnectorFrameworkAdministration cfAdmin = mgmtGroup.GetConnectorFrameworkAdministration();

            // Get the first connector. The subscription will be to this object.
            ReadOnlyCollection<MonitoringConnector> connectors = cfAdmin.GetMonitoringConnectors();
            MonitoringConnector connector = connectors[0];
            // Create a subscription
            AlertNotChangedSubscriptionConfiguration config = new AlertNotChangedSubscriptionConfiguration(AlertSubscriptionConfigurationType.Any);
            config.Criteria = "<SimpleExpression><ValueExpression><Property>ResolutionState</Property></ValueExpression><Operator>Equal</Operator><ValueExpression><Value>255</Value></ValueExpression></SimpleExpression>";
            MonitoringConnectorSubscription subscription = new MonitoringConnectorSubscription("AlertSubscription", connector.Id, config);
            subscription.DisplayName = "Alerts Subscription";
            subscription.Description = "Alerts Subscription Description";
            cfAdmin.InsertConnectorSubscription(subscription);
        }
    }
}

See Also

ConnectorFrameworkAdministration Class
Microsoft.EnterpriseManagement.ConnectorFramework Namespace

Return to top