SCOM VSAE Authoring–Part 3: Interlude: Snippet Templates

Previously in SCOM VSAE Authoring: our heroes continued their quest in search for a new way to author SCOM management packs. They went past through the first two challenges: VSAE and a basic discovery.

I have promised to talk about group discoveries and monitoring. I won’t. Yet. Before that, I want to talk about an important weapon to help thrive in the SCOM authoring endeavour: Snippet Templates!

A bit of history: in the Authoring Console, there was no mechanism to create templates. You could, of course, create a template MP and have it in store. However, all the IDs, once saved, can’t be easily changed. Not from the console itself. If you wanted to do that, you’d need to go XML (extremely mediaeval language) and get your hands dirty copying, searching and replacing text.

But fear not, Snippet templates to the rescue! Although not that powerful yet, in my opinion, the snippet templates allow for some automatic replacement of text, choices and references.

Let’s get our classes code, for example:

image

If this is very common type of discovery I’m going to use, it would be nice to have it ready and just change some of the key parameters.

Here is how to do it: first you will need to create a new item:

image

Notice that I’m creating it inside the Snippet Templates folder.

Select:

image

and name it! Before you hit Add, otherwise you’ll be stuck with that name, not easily changeable.

What you’ll see there is a Performance Collection rule snippet. We don’t care for that right now. You can start by removing the Monitoring section and replacing with our class module:

image

Ok, but we need some variables in there. You have a few options. If you start typing a hash tag, VS will show:

image

Here are my final results:

image

After saving that, you can create another type of snippet, called Snippet Data. That’s when you actually enter data and use the template you just created.

image

Did you name it? Aha!

After you added it, you need to select which template will be used:

image

image

Now you can easily populate the parameters:

image

A note about visual studio 2010 and its VSAE: the screen above is not exactly the same. It is not smart and will show each and every field, every time it appears in the XML code. However, you don’t have to populate each one of them. If you populate for example the MPElementname and click the title of the column, for sorting, it will populate all the MPElementName ones for you. So, the tip is to create a comment section in the MP fragment, with all the fields used in the code, just so your CSV files can populate them right away, with only the necessary fields. I will try to make a special short post about this later.

Once you’re done, hit the save button (that little square thingy that no kid knows what is anymore) and voila! The magic is done!

image

image

You probably imagine how powerful that can be if you compose more complicate templates, that not only create the classes from the parameters, but also the associated discoveries and possibly some rules and monitors.

You can also add choices:

image

A typical use would be the source eventlog, for example: Application System or Security.

And Aliases: image

The idea is just so you don’t have to worry about the current alias for those libraries. This will take care of that.

 

I can certify you that this is saving a huge amount of time in the project I’m currently working on. Use your imagination and let VSAE work for you, instead of becoming a clicking monkey!

Hope this helps