Export (0) Print
Expand All

How to Get Information About an Override

System Center

Updated: May 22, 2009

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

You can use overrides to adjust the default settings that are set in Management Packs so that they are customized for your network. Overrides can adjust property values and configuration settings for rules, monitors, discovery objects, recovery objects, and diagnostic objects.

The following procedure describes how to get information about overrides.

  1. Retrieve overrides using the GetMonitoringOverrides method. This method will return a collection of objects of type ManagementPackOverride, which is the abstract base type that all override classes are derived from.

  2. To be able to gather information from the returned override objects (such as the value of the override), you must cast the ManagementPackOverride object as a specific override type. The types you can use for the cast are listed below.

  3. If one you casted the override object as one of the abstract classes listed in step 2, then you must cast the object again to access the override value. This is because you need to classify the override as a property override or a configuration override. A property override changes the default value of a class property, while a configuration override changes the default value of a custom configuration setting for a class.

The following code example shows you how to display information for all the overrides for rules, monitors, discovery objects, recovery objects, and diagnostic objects.

' Gathers information about overrides. 
Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Text
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Configuration
Imports Microsoft.EnterpriseManagement.Common

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

            Dim mg As ManagementGroup = New ManagementGroup("localhost")
            Dim mpOverrides As ReadOnlyCollection(Of ManagementPackOverride) = mg.GetMonitoringOverrides()

            For Each mpOverride As ManagementPackOverride In mpOverrides

                ' MangementPackOverride is an abstract base class, so you need
                ' to find out the type of the override.
                If (TypeOf mpOverride Is ManagementPackCategoryOverride) Then

                    PrintCategoryOverrideDetails(mpOverride, mg)

                ElseIf (TypeOf mpOverride Is ManagementPackDiagnosticOverride) Then

                    PrintDiagnosticOverrideDetails(mpOverride, mg)

                ElseIf (TypeOf mpOverride Is ManagementPackDiscoveryOverride) Then

                    PrintDiscoveryOverrideDetails(mpOverride, mg)

                ElseIf (TypeOf mpOverride Is ManagementPackMonitorOverride) Then

                    PrintMonitorOverrideDetails(mpOverride, mg)

                ElseIf (TypeOf mpOverride Is ManagementPackRecoveryOverride) Then

                    PrintRecoveryOverrideDetails(mpOverride, mg)

                ElseIf (TypeOf mpOverride Is ManagementPackRuleOverride) Then

                    PrintRuleOverrideDetails(mpOverride, mg)
                End If

            Next
        End Function

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintRuleOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                    ByVal mg As ManagementGroup)

            Console.WriteLine("--- Rule Override Details: ")

            Dim ruleOverride As ManagementPackRuleOverride
            Dim rule As ManagementPackRule

            ruleOverride = CType(mpOverride, ManagementPackRuleOverride)

            Try
                rule = mg.GetMonitoringRule(ruleOverride.Rule.Id)
                Console.WriteLine("    Rule name: " & rule.Name)

            Catch e As ObjectNotFoundException

                Console.WriteLine("    Rule name: Not Found")
            End Try

            If (TypeOf mpOverride Is ManagementPackRuleConfigurationOverride) Then

                Dim configOverride As ManagementPackRuleConfigurationOverride = _
                    CType(mpOverride, ManagementPackRuleConfigurationOverride)
                Console.WriteLine("      Parameter: " & configOverride.Parameter)
                Console.WriteLine("      Value: " & configOverride.Value)

            ElseIf (TypeOf mpOverride Is ManagementPackRulePropertyOverride) Then

                Dim propertyOverride As ManagementPackRulePropertyOverride = _
                    CType(mpOverride, ManagementPackRulePropertyOverride)
                Console.WriteLine("      Property: " & propertyOverride.Property)
                Console.WriteLine("      Value: " & propertyOverride.Value)
            End If
        End Sub

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintRecoveryOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                        ByVal mg As ManagementGroup)

            Console.WriteLine("--- Recovery Override Details: ")

            Dim recoveryOverride As ManagementPackRecoveryOverride
            Dim recovery As ManagementPackRecovery

            recoveryOverride = CType(mpOverride, ManagementPackRecoveryOverride)

            Try

                recovery = mg.GetMonitoringRecovery(recoveryOverride.Recovery.Id)
                Console.WriteLine("    Recovery name: " & recovery.Name)

            Catch e As ObjectNotFoundException

                Console.WriteLine("    Recovery name: Not Found")
            End Try

            If (TypeOf mpOverride Is ManagementPackRecoveryConfigurationOverride) Then

                Dim configOverride As ManagementPackRecoveryConfigurationOverride = _
                    CType(mpOverride, ManagementPackRecoveryConfigurationOverride)
                Console.WriteLine("      Parameter: " & configOverride.Parameter)
                Console.WriteLine("      Value: " & configOverride.Value)

            ElseIf (TypeOf mpOverride Is ManagementPackRecoveryPropertyOverride) Then

                Dim propertyOverride As ManagementPackRecoveryPropertyOverride = _
                    CType(mpOverride, ManagementPackRecoveryPropertyOverride)
                Console.WriteLine("      Property: " & propertyOverride.Property)
                Console.WriteLine("      Value: " & propertyOverride.Value)
            End If
        End Sub

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintDiscoveryOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                         ByVal mg As ManagementGroup)

            Console.WriteLine("--- Discovery Override Details: ")

            Dim discoveryOverride As ManagementPackDiscoveryOverride
            Dim discovery As ManagementPackDiscovery

            discoveryOverride = CType(mpOverride, ManagementPackDiscoveryOverride)

            Try

                discovery = mg.GetMonitoringDiscovery(discoveryOverride.Discovery.Id)
                Console.WriteLine("    Discovery name: " & discovery.Name)

            Catch e As ObjectNotFoundException

                Console.WriteLine("    Discovery name: Not Found")
            End Try

            If (TypeOf mpOverride Is ManagementPackDiscoveryConfigurationOverride) Then

                Dim configOverride As ManagementPackDiscoveryConfigurationOverride = _
                    CType(mpOverride, ManagementPackDiscoveryConfigurationOverride)
                Console.WriteLine("      Parameter: " & configOverride.Parameter)
                Console.WriteLine("      Value: " & configOverride.Value)

            ElseIf (TypeOf mpOverride Is ManagementPackDiscoveryPropertyOverride) Then

                Dim propertyOverride As ManagementPackDiscoveryPropertyOverride = _
                    CType(mpOverride, ManagementPackDiscoveryPropertyOverride)
                Console.WriteLine("      Property: " & propertyOverride.Property)
                Console.WriteLine("      Value: " & propertyOverride.Value)
            End If
        End Sub

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintDiagnosticOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                          ByVal mg As ManagementGroup)

            Console.WriteLine("--- Diagnostic Override Details: ")

            Dim diagnosticOverride As ManagementPackDiagnosticOverride
            Dim diagnostic As ManagementPackDiagnostic

            diagnosticOverride = CType(mpOverride, ManagementPackDiagnosticOverride)

            Try

                diagnostic = mg.GetMonitoringDiagnostic(diagnosticOverride.Diagnostic.Id)
                Console.WriteLine("    Diagnostic name: " & diagnostic.Name)

            Catch e As ObjectNotFoundException

                Console.WriteLine("    Diagnostic name: Not Found")
            End Try

            If (TypeOf mpOverride Is ManagementPackDiagnosticConfigurationOverride) Then

                Dim configOverride As ManagementPackDiagnosticConfigurationOverride = _
                    CType(mpOverride, ManagementPackDiagnosticConfigurationOverride)
                Console.WriteLine("      Parameter: " & configOverride.Parameter)
                Console.WriteLine("      Value: " & configOverride.Value)

            ElseIf (TypeOf mpOverride Is ManagementPackDiagnosticPropertyOverride) Then

                Dim propertyOverride As ManagementPackDiagnosticPropertyOverride = _
                    CType(mpOverride, ManagementPackDiagnosticPropertyOverride)
                Console.WriteLine("      Property: " & propertyOverride.Property)
                Console.WriteLine("      Value: " & propertyOverride.Value)
            End If
        End Sub

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintCategoryOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                        ByVal mg As ManagementGroup)

            Console.WriteLine("--- Category Override Details: ")

            Dim categoryOverride As ManagementPackCategoryOverride = _
                CType(mpOverride, ManagementPackCategoryOverride)

            Console.WriteLine("      Category: " & categoryOverride.Category)
            Console.WriteLine("      Value: " & categoryOverride.Value)

        End Sub

        ' --------------------------------------------------------------------------------------------------
        Private Shared Sub PrintMonitorOverrideDetails(ByVal mpOverride As ManagementPackOverride, _
                                                       ByVal mg As ManagementGroup)

            Console.WriteLine("--- Monitor Override Details: ")

            Dim monitorOverride As ManagementPackMonitorOverride
            Dim monitor As ManagementPackMonitor

            monitorOverride = CType(mpOverride, ManagementPackMonitorOverride)

            Try

                monitor = mg.GetMonitor(monitorOverride.Monitor.Id)
                Console.WriteLine("    Monitor name: " & monitor.Name)

            Catch e As ObjectNotFoundException

                Console.WriteLine("    Monitor name: Not Found")
            End Try

            If (TypeOf mpOverride Is ManagementPackMonitorConfigurationOverride) Then

                Dim configOverride As ManagementPackMonitorConfigurationOverride = _
                    CType(mpOverride, ManagementPackMonitorConfigurationOverride)
                Console.WriteLine("      Parameter: " & configOverride.Parameter)
                Console.WriteLine("      Value: " & configOverride.Value)

            ElseIf (TypeOf mpOverride Is ManagementPackMonitorPropertyOverride) Then

                Dim propertyOverride As ManagementPackMonitorPropertyOverride = _
                    CType(mpOverride, ManagementPackMonitorPropertyOverride)
                Console.WriteLine("      Property: " & propertyOverride.Property)
                Console.WriteLine("      Value: " & propertyOverride.Value)
            End If
        End Sub
    End Class
End Namespace

Show:
© 2014 Microsoft