If you don't know how these expressions work: Raphael Burri has an excellent blog about Dynamic Group Population: http://rburri.wordpress.com/2009/01/14/dynamic-group-membership-authoring-and-performance-impact-on-rms/
Whenever you use Contains or Contained (or their compliments NotContains or NotContained), you should use the attribute MaxDepth to save I/O on the RMS.
But how do you know what the MaxDepth is???
You could find this info in the Service Model from the Management Pack Guide. But not every MP Guide is equiped with a Service Model.
To overcome this, you can use the Group membership rule wizard (Query Builder) in the Operations Console.
In this example I want to group all IIS 7.0 Application Pools which are hosted on computers with a specific Computer Description. In most cases MaxDepth 1 will do, but not in this case.
For the Computer Description attribute I created an extended class based on Windows Computer. The attribute is filled with the value of a registry key found locally on the agent.
Let's see.....
Start the Create Group Wizard and go the the Dynamic Members tab:
Click Create/Edit rules and select IIS 7.0 Application Pool class and click Add:
Select the property drop down list and go to the last entry, which shows the host class. This shows that the IIS 7.0 Application Pool Class is hosted by the IIS 7.0 Web Server class.
In the next steps select the parent classes until you reach the host class Windows Computer. For every host step, maxDepth is incremented.
So now you know that you'll have to use maxDepth="3" in Contains/Contained expressions on the Windows Computer class (or in my case a class which derives from this class).
The membership rule would look like this:
$MPElement[Name="Windows1!Microsoft.Windows.InternetInformationServices.2008.ApplicationPool"]$
$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$
$MPElement[Name="MyExtLib!MyExtLib.Windows.Computer.Extended"]$
$MPElement[Name="MyExtLib!MyExtLib.Windows.Computer.Extended"]/Description$
ContainsSubstring
Web Server LOB1
Of course you can create groups based on the host properties, but sadly this doesn't work on derived classes.
If you do can work with the host properties, the membership rule can look like this:
$MPElement[Name="Windows1!Microsoft.Windows.InternetInformationServices.2008.ApplicationPool"]$
$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$
$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]$
$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]/OrganizationalUnit$
ContainsSubstring
Web Servers