A common scenario is that you want to group computers in groups based on SLA, responsibility or server teams. Groups are used to for example filter views and boundary in notifications. When looking at the Windows computer object you see everything you are monitoring on that machine (that rolls-up health to the Windows computer object). But you don’t get heartbeat missing alerts, as these are generated by the health service watcher for that machine. In the console you can build a group and dynamically include windows computer objects and health service objects. But an challenge is that for the health service objects there are not many attributes to filter on, and there is no feature in the console to do “put these machines and associated health service watchers in this groupâ€. The Windows Computer class we can extend with new attributes and it also includes a lot of attributes out of the box, but we cant do the same with health service. Building a suitable dynamic formula for the Windows Computer class is often not a challenge, the issue is to get associated health service watcher in there.
In this post I will group Windows computer objects and associated health service watcher together in a group, based on a registry string. The goal is to build one dynamic group for each SLA level. Each group should contain all machines that has that SLA level and also associated health service watchers. These groups can later be used of views and notification. I will start by extending the Windows Computer class with a new attribute. This attribute will be populated with a register string from each machine.
 To extend the Windows Class to discover a SLA string follow these steps
- In the Operations Manager Console navigate to Authoring, Management Pack Objects, Attributes
- Right-click Attributes and select Create a New Attribute…
- In the Create Attribute Wizard, General Properties, input a name, for example Contoso – SLA attribute
- In the Create Attribute Wizard, Discovery Method, select Registry as discovery type. Select Windows Computer as Target. Select suitable management pack or create a new management pack, for example Contoso – SLA
- In the Create Attribute Wizard, Registry Probe Configuration, input a path to the registry key and change attribute type to string.
- In production you should not run the discovery to often, often per 12 hour or 24 hours is fine. In a sandbox you could change it a bit to avoid waitning.
- Click Finish and close the Create Attribute Wizard
- Navigate to the Monitoring workspace. Create a new state view in the same management pack as you stored the new attribute. Configure the state view to show data related to Windows Computer_Extended, in my example from the Contoso – SLA management pack. Make sure you select to display the SLA attribute, Contoso – SLA Attribute, on the Display tab.
- Verify that you see your servers and a value in the Contoso – SLA column
The next step is to create a dynamic group, that includes all windows computers with Gold as SLA.
- Navigate to the Authroing workspace, select Groups, right-click and select Create a new Group
- In the Create Group Wizard, General Properties, input a name, for example Contoso – Gold Servers. Select the same management pack as your attribute
- In the Create Group Wizard, Dynamic Members, click Create/Edit rules
- In the Create Group Wizard – Query Builder, input the same settings as in the image below
- In the Create Group Wizard, Exclude Members, click Create
- Right-click the new group, View Group Members, verify that all your gold servers are in the group
The next step is a bit more complicated. We now need to export the new management pack, edit the XML code and import it again. Export the management pack under Management Packs in the Administration workspace. Make an extra copy of the XML file to make sure you have a backup. Open the exported management pack, the XML file, and search for <MembershipRules>. We need to add a second membership rule that groups associated health service watchers with computers already grouped by first membership rule. This second membership rule will add Health Service Watcher objects associated with a computer that is contained by this group. The management pack should look like this when you export it
we add the second discovery rule (see attached MP for code)
Save the management pack and import it into Operations Manager again. Repeat all steps for servers with silver SLA level. After you have imported the management pack, wait a couple of minutes (to let RMS re-calc group members) and then look at the members in the group.
You know have two groups, one for servers with silver SLA and one for servers with gold SLA. Both groups contains windows computer objects and health service watcher objects. You can use your new groups for example notification and views.You can download my MP here, Contoso.SLA  , please note that this is provided “as is†with no warranties at all. Thanks to Steve for ideas.
Great!!
Anders,
it works! I just didn’t wait long enough for the group to populate with the objects…
I’m sorry for the confusion!
Hej Anders,
thanks for this post, this is really essential!
I tried your approach with SCOM 2012 SP1 CU2, using the same code snippet, just replacing the library versions to match the ones in my SCOM 2012 installation.
Unfortunately, the HSW objects are not showing up in the group membership, just the computer objects.
Have you done this successfully on SCOM 2012 as well?
Awesome post Anders. For all of our customers who are running the Veeam MP for VMware v5.7, you can easily extend this to VMGuest Virtual Machine objects as well. Please check out our Veeam Forums on how to do this.
http://forums.veeam.com/viewtopic.php?f=1&t=12125
Hi
After making this change while opening the discovery or group properties getting an error like
“The given key was not present in the dictionary”
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary
what could be the issue
Is there a way to populate a group of Health Service Watcher objects through a discovery script?
Outstanding information, this was very helpful and something every environment needs if they are truly using the product appropriately.