Authoring Management Packs – the fast and easy way, using Visual Studio???


 

imageimage

 

I know what you are thinking.  “Wait, what did he just say?”

 

image

 

Well, hear me out.

Over the years, there have been many tools that we have used to write MP’s.  The SCOM UI Authoring tab, Notepad, XML Notepad, Notepad++, SCOM 2007R2 Authoring Console, Silect MP Author, and Visual Studio.

 

They all have tradeoffs.  I’d argue the most powerful tool over the years that was “somewhat” user friendly was the SCOM 2007R2 authoring console.  Once you learned the quirks, it was pretty good when you needed to make complex MP’s.  But even it was far from perfect.  And moving into SCOM 2012, now that the schema changed, using it becomes VERY challenging to update your existing MP’s.  Silect’s MPAuthor (http://www.silect.com/mp-author) has stepped up in a big way to fill some of these gaps, and they have done a fantastic job of creating wizards that spit out MP’s that are useful, and relatively easy to author.  But they don’t have a wizard for all scenarios, and they don’t offer a way to update the workflows using the same UI that created them, so you are back to XML at that point.

 

Visual Studio has a powerful plugin called VSAE (Visual Studio Authoring Extensions) https://www.microsoft.com/en-us/download/details.aspx?id=30169

The challenge with VSAE is unless you come from a developer background using Visual Studio, or you write management packs all day for a living, most people find it VERY daunting to use.  Even with experience, I find adding certain module types VERY cumbersome to use.  I find customers rarely use Visual Studio for authoring because of this.

 

I think that can change.  I have been presenting a different method on using VSAE with my customers and it has resonated very well.  The most powerful part of VSAE to me, is the ability to use Management Pack fragments.

A Management Pack fragment is simply a bit of XML, that contains all the “working parts” for a specific workflow….   Several authors have written about the power of fragments since VSAE launched, but the biggest gap I saw can be broken up into two major issues:

  • Nobody provided a good “library” of workable MP fragments
  • Nobody came up with a VERY simple method to reuse fragments quickly and easily

 

I hope to change that.  I am presenting an MP fragment library for you to download, and a simple methodology to add fragments to a MP you wish to create.  If you can do a FIND and REPLACE in notepad, you can use this.

 

What if I told you, in a few *minutes*, you could write a full Management Pack, that discovered an application dynamically, created views for the app, monitored for events and performance, monitored key services, and could even run your custom scripts against the app using VBScript or PowerShell?

 

I will be starting a blog series, which will include step by step examples of these fragments, and how to use them.

 

You can download the fragment library here on TechNet gallery:  https://gallery.technet.microsoft.com/SCOM-Management-Pack-VSAE-2c506737

 

This will be a step by step series.  You really should go in order if you are just getting started, but it isn’t really required except for the first two parts.  You can complete ALL of these in less than an hour, even for a first timer.

 

Part 1: Use VSAE to create a new Management Pack Project

Part 2: Use VSAE fragments to dynamically discover an application based on the existence of a registry key or value

Part 3: Use VSAE fragments to monitor a service

Part 4: Use VSAE fragments to create an alert generating event log rule

Part 5: Use VSAE fragments to create a performance collection rule

Part 6: Use VSAE fragments to add Alert, State, and Performance views to your MP

Part 7: Use VSAE fragments to add custom Groups to your MP

Part 8: Use VSAE fragments to create a Windows Performance Monitor with Consecutive Samples

 

There MANY more fragments available in my download than just what I am documenting here.  These are just a basic walkthrough of VERY common workflows, to show how easy it can be, to use VSAE and create great management packs, quickly.  I will add additional examples as time goes on.  I welcome any feedback or MP fragment requests to be added to the library.

 

One of the important things to remember – is you aren’t limited by the fragments I provide.  You can (and should) make your own fragments, specializing them to your company.  For instance, one of the FIRST things you should do, is download all the fragments, and replace ##CompanyID## with your actual company ID.  This way – that is one step already eliminated in your find/replace steps.  If you ALWAYS do specific things with your classes (such as you always create classes AND groups) then you should combine these fragments into one.  It will just make it that much faster.

 

 

Let the “easy series” begin.  Smile

 

image


Comments (19)

  1. Chris Gibson says:

    Amazing, This is exactly what I’ve been after. Complex discoveries is always something that has caused me trouble (Script discoveries – creating the right king of class and Discovering new classes based on properties of other classes – i.e. DB name). If you post code for those two, that would be awesome

    1. Kevin Holman says:

      Help me understand exactly what you are looking for. Not sure I follow you Chris.

      1. Chris Gibson says:

        Sorry the delay. If I discover a server, which has a property of “DBName” I would like to able to use the value of this property to find the DB and populate a group. So if in the future the DB gets changes, scom can just discover it. Does that make sense?

        1. Kevin Holman says:

          No – I am afraid I am not following you.

          What are you trying to accomplish at the end of the day?

  2. rob1974 says:

    Hi Kevin,

    Great initiative, allthough i wonder why you’ve chosen the “mp fragment” way and not create a “template” from within Visual studio itself that contains all the snippets in it. It would make the creation of mp’s even easier with the “snippet data” item.

    1. Kevin Holman says:

      Hi Rob,

      That’s certainly possible – and I wrote about those here: https://blogs.technet.microsoft.com/kevinholman/2014/01/21/how-to-use-snippets-in-vsae-to-write-lots-of-workflows-quickly/ Anyone could take these base fragments, and create their own snippet templates from them using find and replace for the text strings pretty easily. I was trying to make this as simple as possible, while focusing on creating a large library of fragments first. If a customer decides they want to create a large amount of workflows, they can always convert one of them into a snippet. I expect customers to modify these fragments into their own standards and preferred designs as they progress. I see snippets as a “next step” when they have a lot of something to write. If I only have a few rules, or a few monitors, or a single class, I’d rather work with fragments, myself.

      1. rob1974 says:

        actually you can just use the same method with snippets (add existing item > select all files and add the .snippettemplate). Now instead of the replace action you need to add a new item “snippet data” and choose the template you’ve just added. I might even call it the faster and easier way 🙂

        1. rob1974 says:

          Is there an easy way to send you fragments/snippets? Here’s my 2property.serviceclass.discovery.templatesnippet:

          Discovery

          $Target/Property[Type=”#alias(‘Microsoft.Windows.Library’)#!Microsoft.Windows.Computer”]/PrincipalName$
          #text(‘servicename’)#
          86400
          $MPElement[Name=”Custom.Service.#text(‘serviceclassname’)#”]$

          $MPElement[Name=”#alias(‘Microsoft.Windows.Library’)#!Microsoft.Windows.Computer”]/PrincipalName$
          $Target/Property[Type=”#alias(‘Microsoft.Windows.Library’)#!Microsoft.Windows.Computer”]/PrincipalName$

          $MPElement[Name=”#alias(‘System.Library’)#!System.Entity”]/DisplayName$
          #text(‘serviceclassdisplayname’)# ($Target/Property[Type=”#alias(‘Microsoft.Windows.Library’)#!Microsoft.Windows.Computer”]/NetbiosComputerName$)

          $MPElement[Name=”Custom.Service.#text(‘serviceclassname’)#”]/Servername$
          $Target/Property[Type=”#alias(‘Microsoft.Windows.Library’)#!Microsoft.Windows.Computer”]/PrincipalName$

          $MPElement[Name=”Custom.Service.#text(‘serviceclassname’)#”]/Servicename$
          #text(‘servicename’)#

          Custom #text(‘serviceclassdisplayname’)# Class Discovery
          Class discovery for #text(‘serviceclassdisplayname’)#. Discovers the #text(‘servicename’)# service on windows computers

          Custom.Service.#text(‘serviceclassname’)# Class

          Servername

          Servicename

          1. rob1974 says:

            well that’s not easy as it removes quite some things 🙂

    2. Hi!

      I did something like this actually. And released it last week. 🙂
      If you look at the site http://mpdev.mattew.se there is a number of guides there and an extension to Visual Studio that gives you a number of snippets to use. These are “Visual studio snippets”, so you right-click and inserts the code. Then you tab your way through a number of fields and enter your values.

      Me and some of my customers have been using this for almost a year and it’s really quick to use.
      So please check it out to see if it fits your needs. 🙂

      Not all guides are up yet, and there’s more snippets coming. But it’s a start.
      Oh, forgot to say that it’s free. 🙂

      1. rob1974 says:

        not the “snippets” i was looking for, but very cool you’ve installed it in visualstudio like this.

      2. Andres Naranjo says:

        Mattias,
        Your snippets built into Visual Studio like this are pretty awesome. Great job!
        I wish you had Monitors too!

  3. sepeck says:

    The challenge with VSAE is Visual Studio. Visual Studio and it’s cryptic errors are such a huge barrier in and of itself. People who work with it often have adjusted to it, usually within a week or two. Also the flexibility and power of Visual Studio contribute to this. Property windows not being the ‘right’ property windows unless you have clicked the right thing, if you detach a window and ‘lose it’ recovering it is insanely hard if you have no clue. Before firing up VSAE, I suggest people take a basic Level 100 coding course on MS Virtual Academy and just focus on learning Visual Studio. I did a level 100 C# class. It helped a ton when I got to take the MP Authoring WorkshopPLUS course last month because I was able to focus on mostly the VSAE stuff and the few little things I missed in the VS interface previously. Just a suggestion for anyone new to VSAE.

    https://mva.microsoft.com/en-US/training-courses/c-fundamentals-for-absolute-beginners-16169

  4. sepeck says:

    Alright. I figured I would report back. This snippet approach rocks.

    I had an app with 16 services they wanted monitored, so a pretty straight forward one. Having just attended the WorkshopPLUS course I was working my way through the example labs and such to create my MP. This came out and I decided to give it a try. Fast. It’s also helping me better understand how this whole thing works. I may be able to understand that template method now. Of course I have this backlog of requests to knock out first. A lot of ours has to do with Process monitors so I will have to look at what I did in the past and adapt.

    Thanks for the resource.

  5. Amazing. I’ve been using VSAE for about 2 years to create so many MPs and after some while I found that Templates are not useful enough. Then I started using MP fragments and they are great. However, there are some difficulties using VSAE such as finding errors, debugging, and analyzing the code. Moreover, there are some tools for analyzing, simulating or Cookdown checking which are not usable. Simulating specifically is a good approach if we could use it for finding our errors.
    Thanks again for your great job.

  6. User says:

    The “easy series” needs to exist for SCSM!

  7. Just awesome Kevin. Keep up de excellent work.

  8. John Austin says:

    FYI, there seems to be an issue with the “Monitor.TimedScript.PowerShell.SQLQuery.mpx” fragment. The ##ClassID## tag in the UnitMonitor section needs quotes around it, I believe.

    1. Kevin Holman says:

      You are correct – and I caught that recently – it will go into 1.7 which should be published today to include new goodies for you. Thanks for the feedback. Feel free to shoot me direct email as well!

Skip to main content