How to Resolve Alerts

System Center

Updated: May 22, 2009

Applies To: Operations Manager 2007 R2, Operations Manager 2007 SP1, System Center Operations Manager 2007

The Operations Manager class libraries can be used to view and update the properties of operations data. For example, you can change the resolution state of one or more alerts.


The following example demonstrates how to set the resolution state of database monitoring alerts in the Operations Manager database. The example selects only those alerts that are related to the database's availability health. The example then checks the resolution state of each alert that is found; if the resolution state is not already set to "Closed," the example changes the alert's resolution state and adds a comment to the alert's history.

' Sets the resolution state of alerts related to database 
' availability to "Closed".
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Text
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Administration
Imports Microsoft.EnterpriseManagement.Configuration
Imports Microsoft.EnterpriseManagement.Configuration.IO
Imports Microsoft.EnterpriseManagement.Monitoring

Namespace SDKSamples
    Class Program
        Public Overloads Shared Function Main(ByVal args() As String) As Integer

            Dim mg As ManagementGroup = New ManagementGroup("localhost")

            Console.WriteLine("Resolving alerts...")
            ' Get database availability alerts.
            Dim alertCriteria As MonitoringAlertCriteria = New MonitoringAlertCriteria( _
                "Name LIKE '%DBStatusMonitor' AND Category = 'AvailabilityHealth'")
            Dim alerts As ReadOnlyCollection(Of MonitoringAlert) = _

            ' Find the "Closed" resolution state that is defined 
            ' for this Management Group.
            Dim alertStates As ReadOnlyCollection(Of MonitoringAlertResolutionState) = _
            Dim closedState As MonitoringAlertResolutionState = Nothing
            For Each thisState As MonitoringAlertResolutionState In alertStates

                If (thisState.Name = "Closed") Then

                    closedState = thisState
                End If

            ' Close all alerts not already in the "Closed" resolution state.
            For Each a As MonitoringAlert In alerts

                If (a.ResolutionState <> closedState.ResolutionState) Then

                    a.ResolutionState = closedState.ResolutionState
                    Dim comment As String = "closing availability alert"
                End If
            Console.WriteLine("Closed availability alerts.")
        End Function
    End Class
End Namespace

See Also