Management pack authoring templates are a useful way to add additional monitoring on an as-needed basis. A great example is the TCP port wizard – it would make no sense to monitor every TCP port out of the box, so OpsMgr provides a wizard for adding ports on a case by case basis.
So what if you would like to modify how one of the existing templates works or create your own? There is no documentation available that I have found that describes how to do this so that is what I’m setting out to do in this article.
Creating a custom template involves two main components:
- The template elements in a management pack. I’ve attached a working sample and added lots of comments so please have a look through.
- A compiled UI screen written in managed code (c# in this case).
A word of warning: the authoring console does not support either of these components.
Here are the steps you can use to create your custom UI screen:
- Using Visual Studio, create a new class library
- Delete the class1.cs file that gets created by default
- Add references to the necessary OpsMgr DLLs. You can find these in the C:\Program Files\System Center Operations Manager 2007\ folder as well as the SDKBinaries folder within that folder.
- Add a new User Control to the project named EventDetailsPage
- Double click on the user control to open the designer screen. Add your UI widgets from the toolbox. I’ve added two text boxes named txtEventID and txtEventSource.
- Open the code view of your user control and make the following changes by copying and pasting from the code that I’ve attached to the article:
- Add all the “using” statements
- Change the class to inherit from UIPage
- Add the SavePageConfig() and LoadPageConfig() methods
- Build the project
- Copy the DLL that you’ve just compiled to the OpsMgr program files folder.
Now you are ready to run your new template!
Import your management pack and go to the authoring templates. Your new template will show up in the list. When you run the wizard, your UI screen will allow the user to input values.
A note on how OpsMgr processes templates when you’re done with the wizard:
- OpsMgr replaces $TemplateConfig/ConfigValue$ variables in the implementation section of the template with the user-provided values.
- Merges the implementation section into the management pack that you specified on the first wizard screen.
- Creates a <folder> for the template and puts every generated element in the folder using <folderitem>s. When you click on your template after running the wizard, OpsMgr uses this folder system to display previous output of the template. This is also how it knows what to delete if you delete template output. A side effect of this is that it is assumed that you will create elements with unique IDs for each run of the template. If you create non-unique elements, OpsMgr will effectively delete all runs of the template when any single run is deleted.
The sample UIPage I’ve attached barely scratches the surface of what is possible. Some fodder for future articles or your own exploration:
- There is a built-in SDK connection available in the UIPage so you can populate drop-down lists with monitored computers for example
- The UIPage has various properties that give you the context in which it is running such as a reference to the template itself
- You can handle the user editing your template as well as just creating new ones
- You can create custom UI for other workflows such as rules, monitors ,etc
See Part II : Custom Template UIPage Code Walkthrough
Download the Example => Template Test Zip File