Udostępnij za pośrednictwem


Creating a Group of Windows Computer and Health Service Watcher Objects

 

There are a lot of great blogs out there that discuss creating various types of groups (Kevin Holman and Jonathan Almquist have a number of them), and the stuff that I do in this post won’t be anything that hasn’t been written about before, but I wanted to have one spot to cover the questions that I get most often:

  1. How do I create a group of Windows Computer objects for specific “types” of servers (Domain Controllers, SQL Servers, etc.)?
  2. How do I include the associated Health Service Watcher objects in this group?

First, a little info about why you might need to do this.  You can easily create a group of “Active Directory Domain Controller” objects in the OpsMgr Console….just add the class to your group criteria and add additional criteria for the computer name or other property:

image

But what if you want to use this group in the criteria for an Alert Subscription?  If you create a subscription for any alert from an object in this group, the subscription will only pick up alerts that are targeted at the Domain Controller classes.  This may be just want you want, but what if you want the subscription to pick up ALL alerts from the Domain Controllers?  For that, you would need to have Windows Computer objects in the group.  Also, what if you want to use the group as a target for overrides set on workflows targeted at non-Domain Controller classes (for example, disable a Rule in the Operating System Management Pack on all Domain Controllers)?  Again, to do this, the group would need to contain Windows Computer objects.

Now, you can easily create a group of Windows Computers computer objects in the OpsMgr Console….just add the Windows Computer class to the group criteria and use the Windows Computer properties to determine which computer objects go into the group:

image

Ok, so now you have a group of Windows Computers based on Computer Name and Active Directory Site.  You then set up a subscription to get all alerts for the servers in this group.  Everything seems fine until one of the servers goes offline and you don’t get a notification about it.  In the Console, you can see the “Health Service Heartbeat Failure” alert, but no notification was sent for it.  This is because the “Health Service Watcher” object for each of the computers was not included in the group….this MUST be included if you want to include “Heartbeat Failure” alerts in the subscription.

So, now we can go back into the group criteria and add the Health Service Watcher object:

image

However, the Health Service Watcher class doesn’t include all of the Windows Computer properties, so we can basically only filter on the computer name….in the above example I cannot include the “Active Directory Site” criteria for HS Watcher like I did on Windows Computer, so this group will likely include more HS Watcher objects than you want.  Another downside to this group is that the naming standard for your servers might now always indicate if they are a Domain Controller, SQL Server, etc….so you may not be able to use any Windows Computer properties to properly identify them.

So, we want to create a group that:

  1. Contains computers of a specific class (Domain Controller, SQL, Exchange, etc)
  2. Contains Windows Computer objects (so ALL alerts for the computers will be picked up by our Alert Subscription)
  3. Contains Health Service Watcher objects for any computer object that is in the group (so Heartbeat Failure alerts will be picked up by our Alert Subscription)

In this example, the group will contain Domain Controllers that are in the NYC site.

First, we’ll create a new group in the OpsMgr Authoring Console (Jonathan covers this here ):

Open the OpsMgr Authoring Console and either create a new Management Pack or open an existing one

image

Next, we’ll need to add a reference to the System Center Instance Group Library Management Pack (so we can use the relationship types that are defined in this MP).  Go to File - Management Pack Properties - References - Add Reference and select the “Microsoft.SystemCenter.InstanceGroup.Library.mp” file (this should be in the installation directory on the RMS).  Since we’ll be using the Domain Controller classes, we’ll also need a reference to the Active Directory Library MP, so let’s go ahead and add that one now too.

image

Now we’ll create a class for the group - in OpsMgr, a group is really just a class that is populated with various objects (the group members) - Kevin Holman covers this here.  We’ll create a Discovery Rule for this next. In the Authoring Console, go to Service Model\Classes and create a new “Custom Class”.  For the Base Class, select Microsoft.SystemCenter.InstanceGroup and select “Singleton” under Attributes.  We don’t need to do anything on the other tabs….just click ok to save it.

image

Next we’ll need to create a Discovery Rule to populate the group . Go to Health Model - Discoveries and create a new “Custom Discovery”.  On the General tab, give the Discovery a name, and under “Target” select the class that you created for the group:

image

On the Discovered Classes tab ,go to the “Discovered relationships and their attributes” section, select Add - Add Discovered Relationship and select “Microsoft.SystemCenter.InstanceGroupContainsEntities”.

image

 

On the Configuration tab, select “Browse for a type” and select the “Microsoft.SystemCenter.GroupPopulator type.  In the “Module ID” section, type a name for the module

image

Click on Ok, and you will see the following error….just ignore it and click on Close

image

Next we see the Configuration tab with fields for RuleID, GroupInstanceID, and MembershipRules.  For RuleID, enter $MPElement$ .  For GroupInstanceID, enter $MPElement[Name="NAME OF THE GROUP CLASS"]$ …so in this case we would use $MPElement[Name="SAMPLE.OpsMgr.Groups.NYC.DCs"]$ .  We’ll do the rest by editing the XML directly, so just click on OK and save the Management Pack.

image

Save the MP, close the Authoring Console, and open the XML file in any XML or text editor (I like Notepad++).  In the XML, fine the Monitoring\Discoveries section and find the discovery for your group….here’s what it should look like:

<Monitoring>
  <Discoveries>
    <Discovery ID="SAMPLE.OpsMgr.Groups.NYCDCs.GroupPopulation" Enabled="true" Target="SAMPLE.OpsMgr.Groups.NYC.DCs" ConfirmDelivery="true" Remotable="true" Priority="Normal">
      <Category>Discovery</Category>
      <DiscoveryTypes>
        <DiscoveryRelationship TypeID="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities" />
      </DiscoveryTypes>
      <DataSource ID="GroupPopulator" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
        <RuleId>$MPElement$</RuleId>
        <GroupInstanceId>$MPElement[Name="SAMPLE.OpsMgr.Groups.NYC.DCs"]$</GroupInstanceId>
        <MembershipRules>
          <MembershipRule>
            <MonitoringClass>MonitoringClass</MonitoringClass>
            <RelationshipClass>RelationshipClass</RelationshipClass>
          </MembershipRule>
        </MembershipRules>
      </DataSource>
    </Discovery>
  </Discoveries>
</Monitoring>

Next, we need to create membership rules for the Windows Computer and Health Service Watcher classes….the discovery already has one membership rule pre-created, so we’ll use this for the Windows Computer objects….here’s what the rule currently looks like:

<MembershipRules>
<MembershipRule>
<MonitoringClass>MonitoringClass</MonitoringClass>
<RelationshipClass>RelationshipClass</RelationshipClass>
</MembershipRule>

First, replace MonitoringClass with the Windows Computer Class, and RelationshipClass with InstanceGroupContainsEntities, so now it will look like this:

<MembershipRules>
  <MembershipRule>
    <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
<RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
  </MembershipRule>

This part of the membership rule just says that the group will contains Windows Computer objects…..next we’ll add criteria to include only Domain Controller computer objects.  Here, we’re just adding an expression that says “Only include Windows Computer objects that contain the Domain Controller Role class”.  The next XML for the membership rule will look like this:

            <MembershipRule>
              <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
              <Expression>
<Contains>
<MonitoringClass>$MPElement[Name="MicrosoftWindowsServerADLibrary!Microsoft.Windows.Server.AD.DomainControllerRole"]$</MonitoringClass>
</Contains>
</Expression>
            </MembershipRule>

Next, we’ll add a second membership rule for the Health Service Watcher objects.  Here is the XML for this membership rule…it is basically saying “Include Health Service Watcher Objects for the computers that are already in this group”

<MembershipRule>
  <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>
  <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
  <Expression>
    <Contains>
      <MonitoringClass>$MPElement[Name="SystemCenter!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>

So, here’s what the whole discovery looks like now:

      <Discovery ID="SAMPLE.OpsMgr.Groups.NYCDCs.GroupPopulation" Enabled="true" Target="SAMPLE.OpsMgr.Groups.NYC.DCs" ConfirmDelivery="true" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryRelationship TypeID="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities" />
        </DiscoveryTypes>
        <DataSource ID="GroupPopulator" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="SAMPLE.OpsMgr.Groups.NYC.DCs"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
              <Expression>
                <Contains>
                  <MonitoringClass>$MPElement[Name="MicrosoftWindowsServerADLibrary!Microsoft.Windows.Server.AD.DomainControllerRole"]$</MonitoringClass>
                </Contains>
              </Expression>
            </MembershipRule>
            <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>
          </MembershipRules>
        </DataSource>
      </Discovery>

This group will include all Domain Controllers and their Health Service Watcher objects.  Next, we’ll add criteria to only include Domain Controllers that are in the NYC Site.  For this I’ll go back to the first membership rule and add an expression for the AD Site name and enclose this and the original expression in an AND expression.  Here’s what the new xml for the discovery will look like (changes highlighted):

      <Discovery ID="SAMPLE.OpsMgr.Groups.NYCDCs.GroupPopulation" Enabled="true" Target="SAMPLE.OpsMgr.Groups.NYC.DCs" ConfirmDelivery="true" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryRelationship TypeID="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities" />
        </DiscoveryTypes>
        <DataSource ID="GroupPopulator" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="SAMPLE.OpsMgr.Groups.NYC.DCs"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
              <Expression>
               <And>
              <Expression>
                <Contains>
                  <MonitoringClass>$MPElement[Name="MicrosoftWindowsServerADLibrary!Microsoft.Windows.Server.AD.DomainControllerRole"]$</MonitoringClass>
                </Contains>
              </Expression>
                  <Expression>
<SimpleExpression>
<ValueExpression>
<Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/ActiveDirectorySite$</Property>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value>NYC</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
              </Expression>
            </MembershipRule>
            <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>
          </MembershipRules>
        </DataSource>
      </Discovery>

Now I just save the MP and import into my Management Group and verify the group membership is correct

image

 

The MP that I created is attached, as well as MPs that created Computer/HSW groups for Domain Controllers, SQL servers and Exchange 2010 servers.

Sample Group MPs.zip

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    This was really helpful

  • Anonymous
    October 28, 2015
    SCOM can be quite complicated!
    One of the biggest confusions is around why agents go gray, why you