MonitoringConnector.GetMonitoringAlerts Method ()

Updated: April 16, 2012

Gets alerts marked for the monitoring connector. Namespace: Microsoft.EnterpriseManagement.ConnectorFramework
Assembly: Microsoft.EnterpriseManagement.OperationsManager (in Microsoft.EnterpriseManagement.OperationsManager.dll)Dim instance As MonitoringConnector Dim returnValue As ReadOnlyCollection(Of ConnectorMonitoringAlert) returnValue = instance.GetMonitoringAlertsPublic Function GetMonitoringAlerts As ReadOnlyCollection(Of ConnectorMonitoringAlert)public ReadOnlyCollection<ConnectorMonitoringAlert> GetMonitoringAlerts ()public: ReadOnlyCollection<ConnectorMonitoringAlert^>^ GetMonitoringAlerts ()public ReadOnlyCollection<ConnectorMonitoringAlert> GetMonitoringAlerts ()public function GetMonitoringAlerts () : ReadOnlyCollection<ConnectorMonitoringAlert>Return ValueReturns a ReadOnlyCollection of ConnectorMonitoringAlert objects.

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());
		}
		 }
}
}

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


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

Development Platforms

Windows Vista, Windows Server 2003, and

Target Platforms