JAMA00

SCOM 2007 R2

Archive for April, 2010

Creating computergroups Part 2

Posted by rob1974 on April 21, 2010

In this article i described how to generate the xml code for groups based on a registry property. Allthough it works fine we did run into some new insights. Previously we decided not to seal the mp and we didn’t have nesting of groups because we thought it wasn’t possible with generating the xml.

You probably need to read the previous article as well to understand how to group based on a reg property and then script this. This is just a supplement on that part.

Sealing the group xml

The primary reason for not sealing the xml was the ability to remove groups with upgrades of the xml. Once you seal it and a group can be removed an upgrade will just fail as some id doesn’t exist anymore. This is actually the strength of sealing, but in our case not very handy.

However, leaving the xml unsealed we aren’t able to set overrides based on those groups (e.g. for 1 customer only), unless we would save the override in the same mp. That won’t be very handy as we generate the xml again when a new group is needed and of course you don’t want hundreds of overrides to different monitors and rules in the same mp.

The alternative would be to recreate a group manually in the same mp as the override. But this could create a lot of groups that already exist. Besides group discovery does impact the rms, so cutting down on groups where possible is something to strife for.

The solution for unneeded groups is not to delete them but set the discovery to disabled. We’ve also removed the xml code for fulling the group. So even if it was to be enabled it would be an empty group.

<Discovery ID=”jamaGroupCUSTOMERSUB1SUB2.Group.DiscoveryRule” Enabled=”false” Target=”jamaGroupCUSTOMERSUB1SUB2.Group” ConfirmDelivery=”false” Remotable=”true” Priority=”Normal”>
  <Category>Discovery</Category>
  <DiscoveryTypes>
    <DiscoveryRelationship TypeID=”MSSCIGL!Microsoft.SystemCenter.InstanceGroupContainsEntities” />
  </DiscoveryTypes>
  <DataSource ID=”GroupPopulationDataSource” TypeID=”MSSCL!Microsoft.SystemCenter.GroupPopulator”>
    <RuleId>$MPElement$</RuleId>
    <GroupInstanceId>$MPElement[Name=”jamaGroupCUSTOMERSUB1SUB2.Group”]$</GroupInstanceId>
    <MembershipRules>
      <MembershipRule Comment=”Obsolete_Group_CUSTOMERSUB1SUB2″>
        <MonitoringClass>$MPElement[Name=”MSSCL!Microsoft.SystemCenter.AllComputersGroup”]$</MonitoringClass>
        <RelationshipClass>$MPElement[Name=”MSSCIGL!Microsoft.SystemCenter.InstanceGroupContainsEntities”]$</RelationshipClass>
        <Expression>
          <SimpleExpression>
            <ValueExpression>
              <Value>True</Value>
            </ValueExpression>
            <Operator>Equal</Operator>
            <ValueExpression>
              <Value>False</Value>
            </ValueExpression>
          </SimpleExpression>
        </Expression>
      </MembershipRule>
    </MembershipRules>
  </DataSource>
</Discovery>

The red “false” is to disable group discovery. in your console you’ll see this as an unchecked box:

nodiscovery

In blue “true equals false” is the code to generate an empty group. It still strikes me a bit as funny, but it is effective.

The rest of the necessary xml parts should remain the same. But you can change the displayname in the languagepacks part.

<DisplayString ElementID=”jamaGroupCUSTOMERSUB1SUB2.Group”>
  <Name>obsolete group customer-sub1-sub2</Name>
</DisplayString>

The display name can be set to whatever you like, but changing the elementid would result in a failure to upgrade the mp.

Sealing of the generated xml isn’t hard. Either use the commandline tool or load your creating xml in the (r2) authoring console and save as > sealed. Just remember the path to the sealkey can’t have a space in it or it will fail :).

Adding nested groups

As explained in the previous article you can’t use nested groups when you generate the xml code. The reason was that nesting works with an id and the id isn’t known before importing the xml. But, there’s another way.

The trick is to include the groups as dynamic members and not to use subgroups (the dns mp uses the same principle).

image

When you’ll go to the xml it will look something like the code below. For each subgroup you’ll add in this way, you’ll need to repeat the membershiprule in blue.

<Discovery ID=”jamaGroupCUSTOMER.Group.DiscoveryRule” Enabled=”true” Target=”jamaGroupCUSTOMER.Group” ConfirmDelivery=”false” Remotable=”true” Priority=”Normal”>
  <Category>Discovery</Category>
  <DiscoveryTypes>
    <DiscoveryRelationship TypeID=”MSSCIGL!Microsoft.SystemCenter.InstanceGroupContainsEntities” />
  </DiscoveryTypes>
  <DataSource ID=”GroupPopulationDataSource” TypeID=”MSSCL!Microsoft.SystemCenter.GroupPopulator”>
    <RuleId>$MPElement$</RuleId>
    <GroupInstanceId>$MPElement[Name=”jamaGroupCUSTOMER.Group”]$</GroupInstanceId>
    <MembershipRules>
      <MembershipRule>
        <MonitoringClass>$MPElement[Name=”jamaGroupCUSTOMERSUB1.Group”]$</MonitoringClass>
          <RelationshipClass>$MPElement[Name=”MSSCIGL!Microsoft.SystemCenter.InstanceGroupContainsEntities”]$</RelationshipClass>
            <IncludeList>
              <MonitoringObjectId>$MPElement[Name=”jamaGroupCUSTOMERSUB1.Group”]$</MonitoringObjectId>
            </IncludeList>
       </MembershipRule>
    </MembershipRules>
  </DataSource>
</Discovery>

 

Create the xml

Unfortunately i can’t give the full vbs code to generate the xml. allthough it’s probably needs adjusting anyway. But here’s my main function which hopefully helps a bit when you need to create your own script.

sub main
‘ calls several functions to find the appropriate groupnames to be generated.
‘ calls several functions to actually write the xml code

    Dim arrRawGroups
    Dim arrTopGroups
    Dim arrSubGroups
    Dim arrEndGroups
    Dim arrObsoleteGroups
    Dim strINIFile
    dim strObsoleteGroup

    strINIFile = findini(“ini”)
    arrRawGroups = readINIFile(strINIFile)
    arrTopGroups = findTopLevelGroups(arrRawGroups)
    arrSubGroups = findSubLevelGroups(arrRawGroups)
    arrEndGroups = findEndLevelGroups(arrRawGroups)

    arrObsoleteGroups = findObsoleteGroups(strINIFile, arrTopGroups, arrSubGroups)

    createMP
    createManifest INTALIASQUANTITY
    createTypeDefinitions arrTopGroups, arrSubGroups, arrEndGroups, arrObsoleteGroups
    createmonitoring arrTopGroups, arrSubGroups, arrEndGroups, arrObsoleteGroups
    createlanguagepacks arrTopGroups, arrSubGroups, arrEndGroups, arrObsoleteGroups
    closemp
    wscript.echo “DONE!”
end sub

Posted in grouping and scoping | 1 Comment »