Partager via


MonitoringConnector.GetMonitoringAlerts Method ()

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Gets alerts marked for the monitoring connector.

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

Usage

'Usage
Dim instance As MonitoringConnector
Dim returnValue As ReadOnlyCollection(Of ConnectorMonitoringAlert)

returnValue = instance.GetMonitoringAlerts

Syntax

'Declaration
Public Function GetMonitoringAlerts As ReadOnlyCollection(Of ConnectorMonitoringAlert)
public ReadOnlyCollection<ConnectorMonitoringAlert> GetMonitoringAlerts ()
public:
ReadOnlyCollection<ConnectorMonitoringAlert^>^ GetMonitoringAlerts ()
public ReadOnlyCollection<ConnectorMonitoringAlert> GetMonitoringAlerts ()
public function GetMonitoringAlerts () : ReadOnlyCollection<ConnectorMonitoringAlert>

Return Value

Returns a ReadOnlyCollection of ConnectorMonitoringAlert objects.

Example

The following example uses the GetMonitoringAlerts method to get the first alert that is marked for this connector and display that alert.

This example assumes that a monitoring connector exists and that alerts are marked for this connector.

using System;
using System.Collections.ObjectModel;
using System.Text;
using System.Collections.Generic;
using Microsoft.EnterpriseManagement;
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 collection of all connectors.
            IList<MonitoringConnector> connectors = mgmtGroup.ConnectorFramework.GetConnectors();

            // Get the alerts of the first connector.
            MonitoringConnector connector = connectors[0];
            ReadOnlyCollection<ConnectorMonitoringAlert> alerts = connector.GetMonitoringAlerts();
            if (alerts.Count > 0)
            {
                Console.WriteLine("There are " + alerts.Count + " alerts subscribed to by " + connector.Name);
                // Get information for the first alert.
                ConnectorMonitoringAlert alert = alerts[0];
                Console.WriteLine("\nAlert Name: " + alert.Name);
                Console.WriteLine("  Management group:  " + alert.ManagementGroupName);
                Console.WriteLine("  ManagementGroupId: " + alert.ManagementGroupId);
                Console.WriteLine("  Raised:            " + alert.TimeRaised);
                Console.WriteLine("  Has been repeated: " + alert.RepeatCount + " times.");
                Console.WriteLine("  Resolution state:  " + (SystemMonitoringAlertResolutionState)alert.ResolutionState);
                Console.WriteLine("  Severity:          " + alert.Severity.ToString());
            }
         }
    }
}

Remarks

This method only gets alerts that are marked for the monitoring connector from the bookmark time to the current time less 30 seconds.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows Server 2003, and

Target Platforms

Change History

See Also

Reference

MonitoringConnector Class
MonitoringConnector Members
Microsoft.EnterpriseManagement.ConnectorFramework Namespace
MonitoringConnector.AcknowledgeMonitoringAlerts Method
MonitoringConnector.AcknowledgeMonitoringAlerts Method
ConnectorFrameworkProxy.AcknowledgeMonitoringAlerts Method