This is part 7 in a series of posts described here: https://blogs.technet.microsoft.com/kevinholman/2016/06/04/authoring-management-packs-the-fast-and-easy-way-using-visual-studio/
In our next example fragment – we will create custom groups and add them to our MP.
Groups are a critical part of any management pack. We will use them for overrides, to scope monitoring views, and to scope subscriptions.
I like to consider adding three different groups to most of my custom application MP’s, depending on how you use SCOM.
First – a group of all instances of my custom class.
I will use this for overrides, and subscriptions, where needed.
Second – a group of all Windows Computer objects that contain an instance of my custom class.
I will use this to scope console views so I can expose more monitoring data about the computers running my app – to app owners. It can also be used for subscriptions and overrides, since these computers host (and therefore contain) my class.
Third – a group of all Windows Computer objects AND their corresponding Health Service Watcher objects, that contain an instance of my custom class.
I will use this group when I need to allow app owners know when their computers are down – so they can see “heartbeat” and “computer down” alerts.
I have created three fragments which add these groups independently, so you can pick and choose. Don’t just add them all for every MP you make, because if you are a large enterprise, you might end up with too many groups (I’m talking >1000 here), which can cause SCOM to get overloaded.
Step 1: Download and extract the sample MP fragments. These are available here: https://gallery.technet.microsoft.com/SCOM-Management-Pack-VSAE-2c506737
I will update these often as I enhance and add new ones, so check back often for new versions.
Step 2: Open your newly created MP solution, and open Solution Explorer. This solution was created in Part 1, and the class was created in Part 2.
Step 3: Create a folder and add the fragment to it.
Create a folder called “Groups” in your MP, if you don’t already have this folder.
Right click Groups, and Add > Existing item.
Find the fragment named “Generic.Class.Group.ClassInstances.Fragment.mpx” and add it.
Select Generic.Class.Group.ClassInstances.Fragment.mpx in solution explorer to display the XML.
Step 4: Find and Replace
Replace ##CompanyID## with our company ID which is “Fab”
Replace ##AppName## with our App ID, which is “DemoApp”
Replace ##ClassID## with the custom class we created in Part 2 of the series. This was “Fab.DemoApp.Class” from our previous class fragment.
That took all of 2 minutes. Take another few minutes to review the XML we have in this fragment. It is a simple class definition for our group, a discovery to populate the group, along with DisplayStrings for displaynames for each.
Step 5: Build the MP. BUILD > Build Solution.
DOH!
Error 92 Cannot resolve identifier MSIL!Microsoft.SystemCenter.InstanceGroup in the context of management pack Fab.DemoApp. Unknown alias: MSIL C:Program Files (x86)MSBuildMicrosoftVSACMicrosoft.SystemCenter.OperationsManager.targets 255 6 Fab.DemoApp
This is because the group fragment needs a reference to the Instance Group Library.
In Solution Explorer – add a reference by right clicking “References” and choose “Add Reference”
VSAE came with a bunch of common reference files – so browse to C:Users<username>DocumentsVisual Studio 2013References folder. Pick the version of SCOM you want to be able to import this into, and select the “Microsoft.SystemCenter.InstanceGroup.Library.mp”.
Highlight this MP in Solution Explorer under References, and in the properties window you will see the default Alias used, which you can change if necessary. I used the default VSAE reference aliases in all my fragments.
Now Save All, then BUILD again.
Boom!
Step 6: Import or Deploy the management pack.
Step 7: Test the MP.
Open the Authoring pane of the console – and select “Groups”
Find your new DemoApp Instance group:
Right click and View Group Members:
(Note: This may take a few minutes in your environment for Group Population to run, and generate new config)
At this point – you can repeat these same steps for the other two group fragments:
Generic.Class.Group.WindowsComputers.Fragment.mpx
Generic.Class.Group.WindowsComputersAndHealthServiceWatchers.Fragment.mpx