Beruflich Dokumente
Kultur Dokumente
GUIDE
A STARTERS GUIDE TO DEVELOPING PRODUCT CONNECTORS
Ambrose Wong
Microsoft Corporation
December 07
TABLE OF CONTENTS
Overview..........................................................................................................1
Sample Outbound Connector...........................................................................2
Development Platform..................................................................................3
Step-By-Step Instructions.............................................................................4
Create an Outbound Connector.................................................................5
Create An Application To Query and Close Alerts......................................8
Install the Outbound Connector...............................................................10
Simulate an Alert Scenario......................................................................16
Appendix A: About Knowledge Articles..........................................................21
Adding Your Own Company Knowledge Article...........................................23
Appendix B: Operations Manager 2007 Command Shell...............................26
Getting Details from an Alert......................................................................27
Query For Alert Properties..........................................................................29
Query for Monitor....................................................................................30
Query for Monitoring Rule.......................................................................31
Query for Management Pack...................................................................33
References.....................................................................................................34
Blogs...........................................................................................................34
Newsgroups................................................................................................34
OVERVIEW
Page
2
Page
3
DEVELOPMENT PLATFORM
The samples in this document are developed and tested on the following
platforms:
1. Windows Server 2003 Enterprise Edition 32-bit (x86) with SP2, Active
Directory and Internet Information Services 6.0 enabled
2. System Center Operations Manager 2007
3. Microsoft Windows Server 2000/2003 Internet Information Services
Management Pack
4. Visual Studio 2005 Team Suite with SP1
5. SQL Server 2005 Enterprise Edition with SP2
6. Windows Powershell 1.0
Page
4
STEP-BY-STEP INSTRUCTIONS
Page
5
System;
Microsoft.EnterpriseManagement;
Microsoft.EnterpriseManagement.ConnectorFramework;
Microsoft.EnterpriseManagement.Common;
System.Collections.ObjectModel;
System.Threading;
namespace OutboundConnector
{
class Program
{
static void Main(string[] args)
{
ManagementGroup mg = new ManagementGroup("localhost");
ConnectorFrameworkAdministration cfAdmin =
mg.GetConnectorFrameworkAdministration();
Guid connectorGuid = new Guid("{6A1F8C0E-B8F1-4147-8C9B-5A2F98F10003}"); // Or
create/use your own Guid.
MonitoringConnector connector;
try
{
if (args.Length == 1)
{
if (args[0] == "InstallConnector")
{
ConnectorInfo info = new ConnectorInfo();
info.Description = "Sample connector";
info.DisplayName = "Sample connector";
info.Name = "Sample connector";
connector = cfAdmin.Setup(info, connectorGuid);
connector.Initialize();
Console.WriteLine("Created {0} with ID: {1}", connector.Name, connector.Id);
}
else if (args[0] == "UninstallConnector")
{
connector = cfAdmin.GetMonitoringConnector(connectorGuid);
ReadOnlyCollection<MonitoringConnectorSubscription> subscriptions;
subscriptions = cfAdmin.GetConnectorSubscriptions();
Page
6
Page
7
Thread.Sleep(30 * 1000);
}
}
catch (MonitoringException error)
{
Console.WriteLine(error.Message);
}
}
}
}
Note that for the following ManagementGroup constructor in the above code:
ManagementGroup mg = new ManagementGroup("localhost");
In actual connector development you should consider which cache mode that
best fit your needs. The cache mode you want to use can be specified using
the ManagementGroupConnectionSettings object for the constructor.
Page
8
Create a C# console application called Alerts with the code below, with
reference to the following assemblies under C:\Program Files\System Center
Operations Manager 2007\SDK Binaries:
Microsoft.EnterpriseManagement.OperationsManager.dll
Microsoft.EnterpriseManagement.OperationsManager.Common.dll
using
using
using
using
System;
Microsoft.EnterpriseManagement;
Microsoft.EnterpriseManagement.ConnectorFramework;
Microsoft.EnterpriseManagement.Monitoring;
namespace Alerts
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Usage: alerts [get|set] [alertid]");
return;
}
string op = args[0].ToLower();
if ((op != "get") && (op != "set"))
{
Console.WriteLine("First parameter needs to be either 'get' or 'set'.");
return;
}
if (args[1].Length != 36)
{
Console.WriteLine("Second parameter needs to be an alert id guid in the format
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.");
return;
}
try
{
ManagementGroup mg = new ManagementGroup("localhost");
ConnectorFrameworkAdministration cfAdmin =
mg.GetConnectorFrameworkAdministration();
MonitoringAlert alert = mg.GetMonitoringAlert(new Guid(args[1]));
ManagementPack mp;
if (alert.IsMonitorAlert)
{
mp = mg.GetMonitor(alert.ProblemId).GetManagementPack();
}
else
Page
9
{
mp = mg.GetMonitoringRule(alert.MonitoringRuleId).GetManagementPack();
}
Console.WriteLine(">> Management Pack Id: {0}", mp.Id.ToString());
Console.WriteLine(">> Id: {0}", alert.Id.ToString());
Console.WriteLine(">> Category: {0}", alert.Category.ToString());
Console.WriteLine(">> ConnectorId: {0}", alert.ConnectorId.ToString());
Console.WriteLine(">> ConnectorStatus: {0}", alert.ConnectorStatus.ToString());
Console.WriteLine(">> RepeatCount: {0}", alert.RepeatCount.ToString());
Console.WriteLine(">> ResolutionState: {0}", alert.ResolutionState.ToString());
if (!string.IsNullOrEmpty(alert.ResolvedBy))
{
Console.WriteLine(">> ResolvedBy: {0}", alert.ResolvedBy.ToString());
}
Console.WriteLine(">> LastModified: {0}", alert.LastModified.ToString());
Console.WriteLine(">> LastModifiedByNonConnector: {0}",
alert.LastModifiedByNonConnector.ToString());
Console.WriteLine(">> Priority: {0}", alert.Priority.ToString());
Console.WriteLine(">> Severity: {0}", alert.Severity.ToString());
Console.WriteLine(">> Description: {0}", alert.Description);
if (op == "set")
{
Console.WriteLine("Setting ResolutionState to 255.");
alert.ResolutionState = 255;
alert.Update("Alert closed.");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
Page
10
Run the following at the cmd prompt to install the outbound connector.
TestConn InstallConnector
Page
11
Right-click on Sample connector and select Properties. You should see the
Properties dialog box as shown below.
Page
12
In the General tab, put "Test" for both Subscription Name and Description.
Page
13
Page
14
In the Targets tab, select "Forward alerts from targets are automatically,
including targets in Management Packs imported in the future."
Page
15
Click the Update button to save the changes. You should now see Test listed
in the Subscriptions list.
Run the following at the cmd prompt to start polling for alerts every 30
seconds.
TestConn
Page
16
Page
17
At the cmd prompt where TestConn is running, you should see the same alert
as received by the connector:
#1 Alert received on 12/14/2007 1:46:55 PM
>> Id: 3a07c24d-a13c-43b3-be44-f6cab6ecffb3
>> Category: PerformanceHealth
>> ConnectorId: 6a1f8c0e-b8f1-4147-8c9b-5a2f98f10003
>> ConnectorStatus: Pending
>> RepeatCount: 0
>> ResolutionState: 0
>> LastModified: 12/14/2007 5:46:19 AM
>> LastModifiedByNonConnector: 12/14/2007 5:46:19 AM
>> Priority: Low
>> Severity: Error
>> Description: The Internet Information Services Web Site named W3SVC/1 is unav
ailable as the site has been stopped.
In the OperationsManager database you can see the alert in the Alert table:
Page
18
Note the AlertId and run the following command at the cmd prompt
(substitute the alert id with the one in your environment).
alerts get 3a07c24d-a13c-43b3-be44-f6cab6ecffb3
Run the following command at the cmd prompt to check the status again.
alerts get 3a07c24d-a13c-43b3-be44-f6cab6ecffb3
You should see an output similar to the following from the "get" operation:
>> Management Pack Id: 7a920be5-d53c-fa2d-07a8-b415265e95b0
>> Id: 3a07c24d-a13c-43b3-be44-f6cab6ecffb3
>> Category: PerformanceHealth
>> ConnectorId: 6a1f8c0e-b8f1-4147-8c9b-5a2f98f10003
>> ConnectorStatus: Pending
>> RepeatCount: 0
>> ResolutionState: 255
>> ResolvedBy: TESTDOMAIN\Administrator
>> LastModified: 12/14/2007 6:01:13 AM
>> LastModifiedByNonConnector: 12/14/2007 6:01:13 AM
>> Priority: Low
>> Severity: Error
>> Description: The Internet Information Services Web Site named W3SVC/1 is unav
ailable as the site has been stopped.
Since the alert is closed, you should see the alert disappear from Operations
Consoles Active Alerts list.
Run Alerts with "get" operation again, and you should see an output similar
to the following:
>>
>>
>>
>>
>>
Page
20
>> RepeatCount: 0
>> ResolutionState: 255
>> ResolvedBy: TESTDOMAIN\Administrator
>> LastModified: 12/14/2007 6:01:13 AM
>> LastModifiedByNonConnector: 12/14/2007 6:01:13 AM
>> Priority: Low
>> Severity: Error
>> Description: The Internet Information Services Web Site named W3SVC/1 is unav
ailable as the site has been stopped.
Page
21
Page
22
The output from the above code fragment shows the product knowledge
article for the Default Web Site stopped alert from the sample outbound
connector scenario.
KB ID: 6c4a6080-3fe1-1e9f-717c-15fb118c92d3
KB ElementReference: ManagementPackElementUniqueIdentifier=ce89d4d4-8264-8c51-5c
d9-a1ff0e314cdd
KB LanguageCode: ENU
KB Status: Unchanged
KB Visible: True
KB MAML: <maml:section xmlns:maml="http://schemas.microsoft.com/maml/2004/10"><m
aml:title>Summary</maml:title><maml:para>This monitor checks the status of the I
IS Web sites. If you receive an alert from this monitor, action is required in o
rder to bring the Web site back to an operational state.</maml:para><maml:para /
><maml:para>Operational States:</maml:para><maml:para>An IIS Web site can be eit
her in a "Running" or "Not Running" operational state.</maml:para><maml:para /><
/maml:section><maml:section xmlns:maml="http://schemas.microsoft.com/maml/2004/1
0"><maml:title>Causes</maml:title><maml:para>An IIS Web site can stop for many r
easons, including:</maml:para><maml:list><maml:listItem><maml:para>The Web site
was stopped by an administrator</maml:para></maml:listItem><maml:listItem><maml:
para>The Web site was stopped by IIS due to one or more errors that occured duri
ng run time.</maml:para></maml:listItem><maml:listItem><maml:para>The Web site w
as improperly configured which caused it to fail or prevented it from starting.<
/maml:para><maml:para /></maml:listItem></maml:list></maml:section><maml:section
xmlns:maml="http://schemas.microsoft.com/maml/2004/10"><maml:title>Resolutions<
Page
23
/maml:title><maml:para>If an IIS Web site is "Not Running" you can diagnose the
issue or restart the site by taking the following actions:</maml:para><maml:list
><maml:listItem><maml:para>Check for additional Web site related alerts that mig
ht have occurred concurrently. These alerts might help better identify the reaso
n why the service entered a "Not Running" state.</maml:para></maml:listItem><mam
l:listItem><maml:para>Review the event logs on the managed computer, and correct
any underlying problems that might have caused the web site to stop unexpectedl
y.</maml:para></maml:listItem><maml:listItem><maml:para>Use the following Task t
o attempt to restart the Web Site.</maml:para><maml:para><maml:navigationLink><m
aml:linkText>Start IIS Web Site</maml:linkText><maml:uri condition="Task" href="
Microsoft.Windows.InternetInformationServices.2003.WebSite.StartWebSite.Task&
;tasktarget={$TARGET$}" uri="MOM.Console.Exe" /></maml:navigationLink></maml:par
a></maml:listItem></maml:list><maml:para /></maml:section><maml:section xmlns:ma
ml="http://schemas.microsoft.com/maml/2004/10"><maml:title>Configuration</maml:t
itle><maml:para>This monitor doesn't include any configuration settings that can
be modified.</maml:para><maml:para /></maml:section>
MP ID: 7a920be5-d53c-fa2d-07a8-b415265e95b0
MP FriendlyName: Windows Internet Information Services 2003
MP DisplayName: Windows Server Internet Information Services 2003
MP Name: Microsoft.Windows.InternetInformationServices.2003
Note that the GUID for the knowledge articles ElementReference is the
monitor or monitoring rule ID, which helps tie them together.
Page
24
available, best practices dictate that you do not use the default management
pack to store information such as company knowledge articles and overrides.
You should create your own management packs to store such information.
To create a management pack, you can use Operations Console, go to
Administration tab, right-click on Management Packs, and select Create
Management Pack.
Once you created your unsealed management pack, you can use getmanagementpack cmdlet to get the management packs ID. Below is a
sample get-managementpack output for a management pack called Test
Management Pack (refer to "Operations Manager 2007 Command Shell" for
additional information on cmdlets).
>get-managementpack -name "Test.Management.Pack"
Name
TimeCreated
LastModified
KeyToken
: Test.Management.Pack
: 1/4/2008 4:47:54 PM
: 1/4/2008 4:47:54 PM
:
Page
26
Version
: 1.0.0.0
Id
: 9ec718e3-f75b-bbb6-9707-e09d42569587
VersionId
: f9d0700b-f34c-40ff-96dc-f890e69ddfa8
References
: {Microsoft.SystemCenter.Library}
Sealed
: False
ContentReadable
: True
FriendlyName
: Test Management Pack
DisplayName
: Test Management Pack
Description
: Test Management Pack
DefaultLanguageCode : ENU
LockObject
: System.Object
However, note that you cannot edit the company knowledge article through
Operations Console if your content is stored in HtmlContent property.
Page
27
Throughout the test scenario described in this document, you can use
Operations Manager 2007 cmdlets in the command shell to get additional
information about various objects, including alerts, monitors, targets,
management packs, etc.
You can start Operations Manager 2007 Command Shell by going to
Start...All ProgramsSystem Center Operations Manager 2007Command
Shell. The command shell script is
Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1
in the installation folder.
Below is an Operations Manager 2007 Command Shell prompt.
Page
28
You can get alert details by using get-alert cmdlet and the alert id from the
connector.
For the following output from the sample connector:
#1 Alert received on 12/27/2007 7:04:55 AM
>> Id: 11f18e2a-1aa0-4adc-a2f8-69d216ac1e60
>> Category: PerformanceHealth
>> ConnectorId: 6a1f8c0e-b8f1-4147-8c9b-5a2f98f10003
>> ConnectorStatus: Pending
>> RepeatCount: 0
>> ResolutionState: 0
>> LastModified: 12/27/2007 7:05:16 AM
>> LastModifiedByNonConnector: 12/27/2007 7:05:16 AM
>> Priority: Low
>> Severity: Error
>> Description: The Internet Information Services Web Site named W3SVC/1 is unav
ailable as the site has been stopped.
Note the Id value, and use get-alert cmdlet to get detailed information
regarding the alert:
>get-alert -id 11f18e2a-1aa0-4adc-a2f8-69d216ac1e60
Id
Name
: 11f18e2a-1aa0-4adc-a2f8-69d216ac1e60
: Microsoft Windows Internet Information Servic
es 2003 Web Site is Unavailable.
Description
: The Internet Information Services Web Site na
med W3SVC/1 is unavailable as the site has be
en stopped.
MonitoringObjectId
: 6aaa027f-2915-8021-e2bf-3ff0b5eec611
MonitoringClassId
: 648f8c95-dd28-84dd-dc64-eb08ee364d32
MonitoringObjectDisplayName
: Default Web Site
MonitoringObjectName
: W3SVC/1
MonitoringObjectPath
: vpc-w03.testdomain.com
MonitoringObjectFullName
: Microsoft.Windows.InternetInformationServices
.2003.WebSite:vpc-w03.testdomain.com;W3SVC/1
IsMonitorAlert
: True
ProblemId
: ce89d4d4-8264-8c51-5cd9-a1ff0e314cdd
MonitoringRuleId
: ce89d4d4-8264-8c51-5cd9-a1ff0e314cdd
ResolutionState
:0
Priority
: Low
Severity
: Error
Category
: PerformanceHealth
Owner
:
ResolvedBy
:
TimeRaised
: 12/27/2007 7:04:55 AM
TimeAdded
: 12/27/2007 7:04:56 AM
LastModified
: 12/27/2007 7:05:16 AM
LastModifiedBy
: Connector Framework Alert Write Action
TimeResolved
:
TimeResolutionStateLastModified : 12/27/2007 7:04:55 AM
Page
29
CustomField1
CustomField2
CustomField3
CustomField4
CustomField5
CustomField6
CustomField7
CustomField8
CustomField9
CustomField10
TicketId
Context
:
:
:
:
:
:
:
:
:
:
:
Page
30
: 6aaa027f-2915-8021-e2bf-3ff0b5eec611
: 648f8c95-dd28-84dd-dc64-eb08ee364d32
: True
: ce89d4d4-8264-8c51-5cd9-a1ff0e314cdd
: ce89d4d4-8264-8c51-5cd9-a1ff0e314cdd
You can use additional cmdlets to get more information about these
properties.
MonitoringObjectId:
>get-monitoringobject -id 6aaa027f-2915-8021-e2bf-3ff0b5eec611
Id
: 6aaa027f-2915-8021-e2bf-3ff0b5eec611
PathName
: Microsoft.Windows.InternetInformationServices.2003.WebSite%003
avpc%002dw03.testdomain.com%003bW3SVC%002f1
DisplayName
: Default Web Site
ManagementMode :
ManagementGroup : TestOpsMgrGroup
HealthState
: Error
OperationalState :
MonitoringClassId:
>get-monitoringclass -id 648f8c95-dd28-84dd-dc64-eb08ee364d32
ManagementGroup : TestOpsMgrGroup
ManagementGroupId : 063e1751-ae67-b39f-f191-ad32b6df5357
Abstract
: False
Base
: ManagementPackElementUniqueIdentifier=294f206e-08aa-6dc1-1bd
7-a72ce272f365
Hosted
: True
Singleton
: False
PropertyCollection : {ApplicationPoolName, ApplicationPoolID}
XmlTag
: ClassType
Accessibility
: Public
Name
: Microsoft.Windows.InternetInformationServices.2003.WebSite
Id
: 648f8c95-dd28-84dd-dc64-eb08ee364d32
DisplayName
: IIS 2003 Web Site
Description
: All IIS Web sites that are running on the Windows 2003 versi
on of Internet Information Services (IIS).
LanguageCode
: ENU
Comment
:
Status
: Unchanged
LastModified
: 11/21/2007 4:23:13 PM
TimeAdded
: 11/21/2007 4:23:13 PM
Page
31
For the Base property value, you can use the same get-monitoringclass
cmdlet.
QUERY FOR MONITOR
Note that for the get-monitor cmdlet above, the "Id" for criteria is case
sensitive.
The TypeID perperty value contains the ID for the monitors type. In this
case, this is a UnitMonitor as see from the XmlTag property value.
Page
32
If IsMonitorAlert is False, the alert is from a monitoring rule, in which case the
MonitoringRuleId contains the ID of the monitoring rule.
Instead of stopping the Default Web Site in the test scenario, you can try
stopping the OpsMgr Health Service. The resulting alert from TestConn will be
similar to below:
#1 Alert received on 12/30/2007 12:58:56 AM
>> Id: 45572286-77a9-40ba-9ec1-024d02d721e9
>> Category: Alert
>> ConnectorId: 6a1f8c0e-b8f1-4147-8c9b-5a2f98f10003
>> ConnectorStatus: Pending
>> RepeatCount: 0
>> ResolutionState: 0
>> LastModified: 12/29/2007 1:42:44 PM
>> LastModifiedByNonConnector: 12/29/2007 1:42:44 PM
>> Priority: Normal
>> Severity: Error
>> Description: The root health service (Healthservice) has either stopped or pa
used soon after Sat, 29 Dec 2007 13:39:50 GMT. This adversly affects all availab
ility calculation for the entire management group.
: 45572286-77a9-40ba-9ec1-024d02d721e9
: Root Health Service stopped.
: The root health service (Healthservice) has e
ither stopped or paused soon after Sat, 29 De
c 2007 13:39:50 GMT. This adversly affects al
l availability calculation for the entire man
agement group.
MonitoringObjectId
: 895bd899-3400-4077-5858-55b9dfa805f8
MonitoringClassId
: ab4c891f-3359-3fb6-0704-075fbfe36710
MonitoringObjectDisplayName
: vpc-w03.testdomain.com
MonitoringObjectName
:
MonitoringObjectPath
: vpc-w03.testdomain.com
MonitoringObjectFullName
: Microsoft.SystemCenter.HealthService:vpc-w03.
testdomain.com
IsMonitorAlert
: False
ProblemId
: a1297c9f-b5bc-e817-ec77-cc246008d2af
MonitoringRuleId
: a1297c9f-b5bc-e817-ec77-cc246008d2af
ResolutionState
:0
Priority
: Normal
Severity
: Error
Category
: Alert
Owner
:
ResolvedBy
:
Page
33
TimeRaised
: 12/29/2007 1:41:57 PM
TimeAdded
: 12/29/2007 1:41:57 PM
LastModified
: 12/29/2007 1:42:44 PM
LastModifiedBy
: Connector Framework Alert Write Action
TimeResolved
:
TimeResolutionStateLastModified : 12/29/2007 1:41:57 PM
CustomField1
:
CustomField2
:
CustomField3
:
CustomField4
:
CustomField5
:
CustomField6
:
CustomField7
:
CustomField8
:
CustomField9
:
CustomField10
:
TicketId
:
Context
:
ConnectorId
: 6a1f8c0e-b8f1-4147-8c9b-5a2f98f10003
LastModifiedByNonConnector
: 12/29/2007 1:42:44 PM
MonitoringObjectInMaintenanceMode : False
MonitoringObjectHealthState
: Success
ConnectorStatus
: SuccessfullyForwarded
RepeatCount
:0
NetbiosComputerName
: VPC-W03
NetbiosDomainName
: TESTDOMAIN
PrincipalName
: vpc-w03.testdomain.com
SiteName
:
MaintenanceModeLastModified
: 1/1/1900 12:00:00 AM
StateLastModified
: 12/29/2007 1:33:02 AM
Parameters
: {}
ManagementGroup
: TestOpsMgrGroup
ManagementGroupId
: 063e1751-ae67-b39f-f191-ad32b6df5357
In this case IsMonitorAlert is False. You can use get-rule cmdlet with the
MonitoringRuleId to get more information about the monitoring rule:
>get-rule -id a1297c9f-b5bc-e817-ec77-cc246008d2af
ManagementGroup
: TestOpsMgrGroup
ManagementGroupId
: 063e1751-ae67-b39f-f191-ad32b6df5357
HasNonCategoryOverride : False
Enabled
: true
Target
: ManagementPackElementUniqueIdentifier=9189a49e-b2de-cab0
-2e4f-4925b68e335d
ConfirmDelivery
: True
Remotable
: True
Priority
: Normal
DiscardLevel
: 100
Category
: Alert
ConditionDetection
:
DataSourceCollection : {EventDS}
WriteActionCollection : {GenerateAlert}
XmlTag
: Rule
Name
: Microsoft.SystemCenter.SDKService.PrincipleManagementSer
verDown.Alert
Id
: a1297c9f-b5bc-e817-ec77-cc246008d2af
DisplayName
: Root Management Server Unavailable
Description
: Alert generating rule for when the Root Management Serve
Page
34
Page
35
Page
36
REFERENCES
<><><>
Page
37