Management Pack Authoring in SCOM SDK - Quick Start Guide

Management Pack Authoring in SCOM SDK - Quick Start Guide

  • Comments 88

Well, it has been quite a holiday! My wife delivered our son, Jamison Jakub, on December 26th at 8:14 AM. Mom and baby are doing great. I've posted some photos on our families personal site: www.oleksyfamily.com. I am more or less back at work for now and will be taking my paternity leave later, most likely after we ship SCOM 2007.

I wanted to talk a little about management pack authoring and editing in the SDK. This is the largest part of the SDK that I did not write, so I am not an expert at the internal workings of a lot of it, but I do know how it works.

First, there is a rather large object hierarchy when it comes to management pack related objects. At the most derived level, you will almost always find a Monitoring* object derived from a ManagementPack* object (e.g. MonitoringRule and ManagementPackRule). Monitoring* objects are returned by the online, connected SDK from the database. These objects are not "newable" and contain slightly more context, and sometimes more functionality, then their respective base class. (For instance they always have a pointer to ManagementGroup, which ManagementPack* object do not). Whenever you want to create a new management pack object, you have to use the ManagementPack* version of it to create it.

The context of a management pack object is always a management pack. When you create an object, you need to specify which management pack it goes into. This is the management pack that the ultimate commit call (AcceptChanges()) will need to be made.

If you want to change an existing object, simply change whatever you want about it (i.e. any settable properties) and then set its Status property to PendingUpdate. Once you do this, internally it gets placed into a pending changes collection for that management pack. But which instance you might ask? If you are working in connected SDK and you retrieve a management pack object from the database that object belongs to a particular management pack. Internally, this management pack is cached (unless you are running on CacheMode.None in which you should not be doing management pack authoring) and we always maintain the same instance of that management pack. No matter how many times you retrieve that object, that management pack instance will be the same. In fact no matter how you retrieve that management pack (with the ONE caveat that if you do criteria based searching for a management pack, the instance will actually be different as it doesn't use the cache to perform the query) it will be the same instance.

This poses an interesting problem in that if multiple users in the same application try to update the same management pack, they will be writing into the same management pack at the same time. To alleviate this problem, the ManagementPack class exposes a LockObject property that will lock the management pack for editing. This lock should be taken prior to updating the management pack and released after committing the changes.

In order to commit changes, simply retrieve the management pack you are changing (either by calling GetManagementPack() on the object(s) you are changing, or some other independent SDK method that is not criteria based) and call AcceptChanges(). Once this method returns, the changes are committed.

I am sure users will have questions in this area, but it is such a large topic to cover, I just wanted to put together a small quick start guide to get everyone started. As always, please ask any questions you might have or if you want an expanded post on anything in particular regarding this area.

Leave a Comment
  • Please add 6 and 2 and type the answer here:
  • Post
  • How can I add a normal parameter for the task in MP.

    If the parameter name is P1, the type is string and the default value is value1.

    Please help me on that.

    Thanks in advance.

  • It is a script based task.

  • If you are using the Microsoft.Windows.ScriptWriteAction the arguments to the script are passed in using a single Arguments field:

    <Task ID="YourTask" Target="YourTarget" Enabled="true" Accessibility="Public">

               <Category>Maintenance</Category>

               <WriteAction TypeID="Windows!Microsoft.Windows.ScriptWriteAction" ID="Script">

                   <ScriptName>YourScriptName.vbs</ScriptName>

                   <Arguments>value1</Arguments>

                   <ScriptBody>

                       <![CDATA[Your script]]>

                   </ScriptBody>

                   <TimeoutSeconds>120</TimeoutSeconds>

               </WriteAction>

           </Task>

  • ya, I know.

    But where can I put the parameter name P1? I want to let user change that from the GUI of SCOM. You know when user run the task, the parameter name can not be found(always as Arguments). User will not know what's the meaning of that parameter.

    thanks again.

  • I mean change the default value of the parameter. I know user can change that by click the overide button. But he dont know the (Name)meaning of the parameter, that will be a problem

  • Here is another example I pulled from one of our MPs. You want to look at the overrideable parameter in the definition. This will map up to your parameter. Also, you can add a display name using display strings to your overrideable parameter to be a bit more descriptive.

    <WriteActionModuleType ID="Microsoft.SystemCenter.EnableACSAction" Accessibility="Internal" Batching="false">

                   <Configuration>

                       <xsd:element name="CollectorServer" type="xsd:string"/>

                   </Configuration>

                   <OverrideableParameters>

                       <OverrideableParameter ID="CollectorServer" Selector="$Config/CollectorServer$" ParameterType="string"/>

                   </OverrideableParameters>

                   <ModuleImplementation Isolation="Any">

                       <Composite>

                           <MemberModules>

                               <WriteAction ID="EnableACS" TypeID="System!System.CommandExecuter">

                                   <ApplicationName>%windir%\system32\cscript.exe</ApplicationName>

                                   <WorkingDirectory/>

                                   <CommandLine>//NoLogo $File/EnableACSAction.vbs$ "$Config/CollectorServer$" "$Target/ManagementGroup/Name$"</CommandLine>

                                   <TimeoutSeconds>30</TimeoutSeconds>

                                   <RequireOutput>true</RequireOutput>

                                   <Files>

                                       <File>

                                           <Name>EnableACSAction.vbs</Name>

                                           <Contents><![CDATA[]]></Contents>

                                       </File>

                                   </Files>

                               </WriteAction>

                           </MemberModules>

                           <Composition>

                               <Node ID="EnableACS"/>

                           </Composition>

                       </Composite>

                   </ModuleImplementation>

                   <InputType>System!System.BaseData</InputType>

               </WriteActionModuleType>

  • Sorry, I dont know where can I to put the <Configuration>

                      <xsd:element name="CollectorServer" type="xsd:string"/>

                  </Configuration>

                  <OverrideableParameters>

                      <OverrideableParameter ID="CollectorServer" Selector="$Config/CollectorServer$" ParameterType="string"/>

                  </OverrideableParameters>

    into a task definition like <Task ID="YourTask" Target="YourTarget" Enabled="true" Accessibility="Public">

              <Category>Maintenance</Category>

              <WriteAction TypeID="Windows!Microsoft.Windows.ScriptWriteAction" ID="Script">

                  <ScriptName>YourScriptName.vbs</ScriptName>

                  <Arguments>value1</Arguments>

                  <ScriptBody>

                      <![CDATA[Your script]]>

                  </ScriptBody>

                  <TimeoutSeconds>120</TimeoutSeconds>

              </WriteAction>

          </Task>

    I tried several times. All failed.

    Any artical I can read for that?

    Please help me out. Thanks

  • I am not sure I understand the question. What are you trying that is failing?

  • I tried to put the parameter definition into the task like

    <Task ID="YourTask" Target="YourTarget" Enabled="true" ccessibility="Public">

              <Category>Maintenance</Category>

    <Configuration>

                     <xsd:element name="CollectorServer" type="xsd:string"/>

                  </Configuration>

                  <OverrideableParameters>

                     <OverrideableParameter ID="CollectorServer" Selector="$Config/CollectorServer$" ParameterType="string"/>

           </OverrideableParameters>

              <WriteAction TypeID="Windows!Microsoft.Windows.ScriptWriteAction" ID="Script">

                  <ScriptName>YourScriptName.vbs</ScriptName>

                  <Arguments>value1, </Arguments>

                  <ScriptBody>

                      <![CDATA[Your script]]>

                  </ScriptBody>

                  <TimeoutSeconds>120</TimeoutSeconds>

              </WriteAction>

          </Task>

    It can not pass the xsd verification. I also tried to move the configuration to an other place. It doesnot work also.

  • Can you provide me with the error you are getting?

  • If I put the configuration like that, I will get a error message when I try to import the MP

    Invalid Management Pack : C:\Documents and Settings\Administrator\Desktop\test.xml .: XSD verification failed for management pack. [Line: 572, Position: 6]

    The element 'Task' has invalid child element 'Configuration'. List of possible elements expected: 'ProbeAction, WriteAction'.

    I also tried to put the <Configuration> under writeaction. Also failed.

  • Ah, I see the problem. If you notice in my original post, this is part of a WriteActionModuleType definition, not a task definition. You need to define it in the module type, then use that module type in a task. A task itself has no configuration. Sorry for not seeing this earlier.

  • I tried to put <WriteActionModuleType ID =....>

    <WriteActionModuleType> into the management pack. Even I can not find a place for them. I searched that from Demo MP, sys MP, MP Authoring Guide, SDK. Could you please point out where can I get a reference for such task with new WriteActionModuleType? Thanks for your help

  • Please take a look at the management pack that is attached to this post:

    http://blogs.msdn.com/jakuboleksy/archive/2006/09/27/Sample-Alert-and-State-Change-Insertion.aspx

    It will show you where in the management pack they go.

  • OK, I got it. Thanks for your time.

Page 1 of 6 (88 items) 12345»