Search This Blog

Monday 9 June 2014

Creating Dynamic Groups With Windows Computer Objects and Health Service Watcher Objects


As of 01/05/2017, this blog will not be updated or maintained

It has been a well known requirement for most customers, to be able to Create Groups of Windows Computers that also contain corresponding Health Service Watcher objects. This was needed for Alert Notification subscriptions so that different teams could receive alert notifications filtered by groups, but also include alerts from the Watcher, such as Heartbeat failure and Computer Unreachable.

Below you will find the code for SCOM 2007x and SCOM 2012x.

Let's start at the beginning:
1. Create the dynamic group, using the group wizard.

  • Give your dynamic group a name and select the unsealed management pack you want to store the group in.
  • On the Explicit Members tab click next.
  • On the Dynamic Members tab click  and create the formula you want to use to create you dynamic group. I used a simple one that dynamically includes all of my exchange servers.
  • From the groups window, right click to verify that your dynamic group includes the computers you want.
As you can see the dynamic group only contains windows servers and does not contain the heartbeat object (or agent watcher as it is know in SCOM).

2. Export the Management pack that you saved the group too.
3. Open up the Management pack in any xml editor. I am using NotePad ++.

4. Search for <MembershipRules>. The membership rules make up the dynamic group. As you can see the first membership rule between <MembershipRule> and </MembershipRule> contains the formula that creates my dynamic group.

5. Now we need to add the code to include the health watchers.
(SCOM 2007x or SCOM 2012x. Depending on your environment.)

Here is the code for SCOM 2007x:
<MembershipRule>
  <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>
  <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6062780!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
    <Expression>
      <Contains>            
        <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthService"]$</MonitoringClass>
        <Expression>
          <Contained>        
            <MonitoringClass>$MPElement[Name="MicrosoftWindowsLibrary6062780!Microsoft.Windows.Computer"]$</MonitoringClass>
              <Expression>
                <Contained>
                  <MonitoringClass>$Target/Id$</MonitoringClass>
                </Contained>
              </Expression>
          </Contained>
        </Expression>
      </Contains>
    </Expression>
</MembershipRule>

Here is the code for SCOM 2012x:
<MembershipRule>
  <MonitoringClass>$MPElement[Name="SC!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>
  <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
    <Expression>
      <Contains>
        <MonitoringClass>$MPElement[Name="SC!Microsoft.SystemCenter.HealthService"]$</MonitoringClass>
        <Expression>
          <Contained>
            <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
            <Expression>
              <Contained>
                <MonitoringClass>$Target/Id$</MonitoringClass>
              </Contained>
            </Expression>
          </Contained>
        </Expression>
      </Contains>
    </Expression>
</MembershipRule>

6. Paste this code after the first </MembershipRule> and before </MembershipRules> then save the file.

7. Save the Management Pack and re-import the Management Pack into SCOM

8. Go back to your group and view group members.
Note: Depending on the size of your environment, it will take a bit of time to populate the group with the correct amount of Health Service Watcher Objects.

Now when we create a subscription to this group and a server in the group goes down we will now get the heartbeat failure alert.

Hope that this post was helpfull.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.