Friday, November 2, 2012

OpsMgr 2007: More on dynamic groups and health watchers

Burn-iconEarlier this year, I blogged about creating dynamic computer groups and then adding the agent health watcher component dynamically with a bit of code magic. Many things have changed in my OpsMgr environment since then, including my OpsMgr support team, and we have recently had to add a couple of new groups to accomodate some of these changes.

The new support team wasn’t too familiar with this method of dynamic group creation, but it was easy, right, considering we have it documented all over the interwebs, and right here. Well, we picked up something new to watch out for.

So, this is the bit of code that you need to add to facilitate the agent watchers:

<MembershipRule>
    <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>
    <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
        <Expression>
            <Contains>             
                <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthService"]$</MonitoringClass>
              <Expression>
            <Contained>         
                <MonitoringClass>$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]$</MonitoringClass>
          <Expression>
            <Contained>
              <MonitoringClass>$Target/Id$</MonitoringClass>
            </Contained>
          </Expression>
        </Contained>
      </Expression>
    </Contains>
  </Expression>
</MembershipRule>

However, this only works if you are using a specific class of Windows Computer, which is referenced by this bit:

<MonitoringClass>$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]$</MonitoringClass>

 

You should see a matching class in the original membership rule in the management pack, that may look something like this (should match highlighted line):

<MembershipRule>
             <MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>
              <Expression>
                <SimpleExpression>
                  <ValueExpression>
                    <Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/OrganizationalUnit$</Property>
                  </ValueExpression>
                  <Operator>Equal</Operator>
                  <ValueExpression>
                    <Value>OU=Web,OU=Servers,DC=somedomain,DC=somecompany,DC=net</Value>
                  </ValueExpression>
                </SimpleExpression>
              </Expression>
            </MembershipRule>

 

And if it doesn’t match (like it doesn’t between the add on and the original rule example), you will receive an error on importing the management pack. Update the monitoring class and Bob’s your uncle.

Open-mouthed smile

No comments:

Related Posts with Thumbnails