Compartilhar via


How to Create a Knowledge Article

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

A knowledge article contains custom information aimed at helping a user of the Operations Manager Operations Console or the Web Console. Knowledge articles are added to a Management Pack, or an element of a Management pack such as a monitor, a discovery object, or a rule, by using the ManagementPackKnowledgeArticle class. The knowledge article is written in HTML, and it can contain specific information about the element or Management Pack that it is associated with.

The following code example creates a knowledge article for a rule.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EnterpriseManagement;
using Microsoft.EnterpriseManagement.Configuration;
using System.Collections.ObjectModel;

namespace SDKSamples
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementGroup mg = new ManagementGroup("localhost");
            ManagementPack defaultMP = mg.GetManagementPacks(
                "Microsoft.SystemCenter.OperationsManager.DefaultUser")[0];

            MonitoringRuleCriteria ruleCriteria = 
                new MonitoringRuleCriteria("DisplayName = 'SQL User Connections'");

            MonitoringRule rule = null;
            try
            {
                rule = mg.GetMonitoringRules(ruleCriteria)[0];
            }
            catch (ArgumentOutOfRangeException)
            {
                Console.WriteLine("Error: Could not retrieve the specified rule.");
                return;
            }
            
            ManagementPackKnowledgeArticle article = 
                new ManagementPackKnowledgeArticle(rule, "ENU", defaultMP);
            article.HtmlContent = 
                "<html><body>This is a placeholder for a knowledge article</body></html>";

            defaultMP.AcceptChanges();
        }
    }
}      
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.EnterpriseManagement
Imports Microsoft.EnterpriseManagement.Configuration
Imports System.Collections.ObjectModel


Namespace SDKSamples
    Class Program

        Public Overloads Shared Function Main(ByVal args() As String) As Integer

            Dim mg As New ManagementGroup("localhost")
            Dim defaultMP As ManagementPack = mg.GetManagementPacks("Microsoft.SystemCenter.OperationsManager.DefaultUser")(0)

            Dim ruleCriteria As New MonitoringRuleCriteria("DisplayName = 'SQL User Connections'")

            Dim rule As MonitoringRule = Nothing
            Try
                rule = mg.GetMonitoringRules(ruleCriteria)(0)
            Catch e As System.ArgumentOutOfRangeException

                Console.WriteLine("Error: Could not retrieve the specified rule.")
                Return 1
            End Try

            Dim article As New ManagementPackKnowledgeArticle(rule, "ENU", defaultMP)
            article.HtmlContent = "<html><body>This is a placeholder for a knowledge article</body></html>"

            defaultMP.AcceptChanges()
        End Function 'Main
    End Class 'Program
End Namespace 'SDKSamples