Author your MP with Snippet templates in Visual Studio

Author your MP with Snippet templates in Visual Studio
SHARE
Tom Klaver, 26

On the last day of MMS 2012, I attended the AM-B311 session “Management Pack Authoring Tools: The Next Generation”. With the new release of System Center Operations Manager 2012 there will also be two new Authoring Tools soon be available. These new Authoring tools are:

1. Visio Management Pack Designer
2. Visual Studio Authoring Extensions

More information about all Authoring Tools for Operations Manager 2012 can be found here.

In this blog I’ll describe how you can create your own “snippet” templates in Visual Studio 2010 to simplify the creation of a more advanced Management Pack. These “snippet” templates help you to create a basic Management Pack with the creation of for instance multiple classes, discoveries, groups, monitors and views. When the basic Management Pack is built in Visual Studio you only have to change the specific values in the XML code.

First you need to install Visual Studio 2010 Professional or higher and secondly you need to install the System Center 2012 Visual Studio Authoring Extensions.

Now when you start Visual Studio and select “New Project” a new window will open and you will be able to choose from the “Installed templates”. Select the “Operations Manager Core Monitoring Management Pack” template under “Management Pack – Operations Manager”. This one will generate an empty MP that you can use for Operations Manager 2007 R2 as well as 2012.



Next I create a Folder “Templates” in the “Solution Explorer” to save my Snippet Templates.

After that I add a “New Item” also in the “Solution Explorer” and now I can choose from many different SCOM items. Default the System Center 2012 Visual Studio Authoring Extensions has one “Snippet Template” to quickly create multiple rules. This one can be found under “Code” and is called “Snippet Template”. To become familiar with a “Snippet Template” open this one.



You will now notice some yellow text fields that are going to be used as input fields. If you look carefully you will see that there are three different input fields.

1. #text; this is for text input
2. #choice; this is for choosing from predefined values
3. #alias; this is for automatically setting the correct alias name of a reference MP

Now when you delete all XML code in this templatesnippet code file with you own XML code and use your own input fields you are ready to go with your own templatesnippet. For instance I created my own templatesnippet for creating some classes.

  

The following step is save the snippettemplate code and add a new Snippet template under “Templates”. Give the Snippet template a name and click the button “Add”. 

Now select the correct Snippet type. In my case the templatesnippet I just created.

You will notice in the Visual Studio Solution Explorer two files have been created. The first file (mpsd) is going to be used for the input of your fields. The second file (mptg.mpx) is currently an empty XML file that is gone be automatically generated based on the input fields in the first file.



When you fill in the input fields of the first file and save the file, you will notice that the second file has automatically generated the XML code for the classes.



Because I prefer to build each custom Management Pack basically the same, I made myself some extra templatesnippets for discoveries (registry and WMI), instance groups, monitors and views (alerts, performance and state) that helps me quickly build a basic XML MP. You can download these templatesnippets for your own purpose at the bottom of this blog.

When you’re finished authoring your Management Pack just choose to build the project and watch for any errors in the error list. If no errors are found than your XML Management Pack is created under the project folder in the subfolders \bin\debug. You can now import the custom Management Pack in Operations Manager 2007 or 2012.

One final comment: be sure to use the exact same id’s (lowercase, uppercase). If they are not the same in your project, than errors will appear in the error list!

Happy authoring!
Tom

Snippet Templates:
class_with_property.templatesnippet
class_without_property.templatesnippet
discovery_wmi_windows_computer.templatesnippet
discovery_wmi_custom_class.templatesnippet
discovery_registry_windows_computer.templatesnippet discovery_registry_custom_class.templatesnippet
instancegroup.templatesnippet
monitor_unit_windowsntservice.templatesnippet
monitor_dependency.templatesnippet
view_state.templatesnippet
view_performance.templatesnippet
view_alerts.templatesnippet

VSS Crash-Consistent vs Application-Consistent VSS Backups …

This second blog by Altaro dealing with Hyper-V backup discusses when Application-Consistent Backup is vital for proper recovery or not. What if a VSS Writer is not available for a particular application? What are the general requirements for Application-Cons…

HP ProLiant Gen8 Tech Day 1 – Customer Inspired Innovation

Today was the first of a 2-day HP ProLiant Gen8 Tech Day in Houston. The ten bloggers who were invited are all from the US except for me.  Some of them I have met from other HP events like HP Discover in 2011 and an event in Madrid in the same year. Sinc…

HP ProLiant Gen8 Tech Tour

Tomorrow I will fly to Houston from San Diego where I have been staying for a few days after a great TEC2012 event. HP asked me to join them for their HP ProLiant Gen8 Tech Tour. Coming all the way from Europe just for the 2 days would have been crazy, but as…

VSS Crash-Consistent vs Application-Consistent VSS Backups …

I can recommend an interesting 2-part series of blogs which helps you get a better understanding of the theory behind successful backups. In the first blog on Altaro’s Hyper-V blog, VSS Crash-Consistent Backups are compared to Application-Consistent VSS Backu…

VHDX Specification Now Available

Windows 8 and Windows Server 2012 Hyper-V support the new VHDX Virtual Hard Disk format. If you are interested in the technical details just became available and you can download the VHDX specification: http://www.microsoft.com/en-us/download/details.aspx?id=…

Speaking at The Experts Conference 2012 in San Diego

Having presented at TEC2011 in Frankfurt for the first time was a good experience and I was very pleased to be asked to speak again. This time in San Diego in the US. Join us for The Experts Conference for Virtualization 2012, April 29-May 2 in San Diego! TEC…

Virtual Machine Migration Toolkit

Microsoft at MMS 2012 announced a new toolkit for mass conversion of VMware VM’s to Hyper-V. VMMT is wizard based conversion tool aimed at conversion from VMware to the current version of Hyper-V. Windows Server 2012 support is still under development. Please…

Follow Inovativ on Twitter Visit Inovativ.nl Visit Inovativ.nl
Most read
Search
Keywords
Archive