Freigeben über


Another post about how to create a group of Windows Computer and associated Health Service Watcher objects

The main purpose of this type of group is to enable us to create subscriptions that will not only send alerts generated by a computer, but also Health Service Heartbeat Failure alerts generated by those computers.

I know this has been posted a few times already, so I don’t take credit for ‘discovering’ this.  But sometimes it’s helpful seeing something presented slightly different than what you’ve already seen.

So here you go.  I’m keeping it simple.

Below is a working management pack.  It contains a group and a discovery.  The resultant group will contain Windows Computer and Health Service Watcher objects where computer Netbios name matches string *ABC*.  The text in red font is the only element you’ll need to change to populate the group with computers and HSW objects matching a different Netbios name.

Paste it into your favorite XML editor (notepad works fine).  Save it with file name Health.Service.Watcher.Group.ComputersStartingWithABC.xml.  Import it into a lab environment.  Play around with it.  You’ll figure it out. :)

 

<ManagementPack ContentReadable="true" xmlns:xsd="https://www.w3.org/2001/XMLSchema" xmlns:xsl="https://www.w3.org/1999/XSL/Transform">
  <Manifest>
    <Identity>
      <ID>Health.Service.Watcher.Group.ComputersStartingWithABC</ID>
      <Version>1.0.0.0</Version>
    </Identity>
    <Name>Health Service Watcher Group (Computers starting with ABC)</Name>
    <References>
      <Reference Alias="MicrosoftSystemCenterInstanceGroupLibrary6172210">
        <ID>Microsoft.SystemCenter.InstanceGroup.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SystemCenter">
        <ID>Microsoft.SystemCenter.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="MicrosoftWindowsLibrary6172210">
        <ID>Microsoft.Windows.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
      <Reference Alias="SystemLibrary6172210">
        <ID>System.Library</ID>
        <Version>6.0.5000.0</Version>
        <PublicKeyToken>31bf3856ad364e35</PublicKeyToken>
      </Reference>
    </References>
  </Manifest>
  <TypeDefinitions>
    <EntityTypes>
      <ClassTypes>
        <ClassType ID="Health.Service.Watcher.Group.ComputersStartingWithABC.Class" Accessibility="Public" Abstract="false" Base="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroup" Hosted="false" Singleton="true" />
      </ClassTypes>
      <RelationshipTypes>
        <RelationshipType ID="Health.Service.Watcher.Group.ComputersStartingWithABC.ClassContainsEntity" Accessibility="Public" Abstract="false" Base="SystemLibrary6172210!System.Containment">
          <Source>SystemLibrary6172210!System.Group</Source>
          <Target>SystemLibrary6172210!System.Entity</Target>
        </RelationshipType>
      </RelationshipTypes>
    </EntityTypes>
  </TypeDefinitions>
  <Monitoring>
    <Discoveries>
      <Discovery ID="Health.Service.Watcher.Group.ComputersStartingWithABC.Class.DiscoveryRule" Enabled="true" Target="Health.Service.Watcher.Group.ComputersStartingWithABC.Class" ConfirmDelivery="false" Remotable="true" Priority="Normal">
        <Category>Discovery</Category>
        <DiscoveryTypes>
          <DiscoveryRelationship TypeID="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities" />
        </DiscoveryTypes>
        <DataSource ID="GroupPopulationDataSource" TypeID="SystemCenter!Microsoft.SystemCenter.GroupPopulator">
          <RuleId>$MPElement$</RuleId>
          <GroupInstanceId>$MPElement[Name="Health.Service.Watcher.Group.ComputersStartingWithABC.Class"]$</GroupInstanceId>
          <MembershipRules>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="Health.Service.Watcher.Group.ComputersStartingWithABC.ClassContainsEntity"]$</RelationshipClass>
              <Expression>
                <RegExExpression>
                  <ValueExpression>
                    <Property>$MPElement[Name="MicrosoftWindowsLibrary6172210!Microsoft.Windows.Computer"]/NetbiosComputerName$</Property>
                  </ValueExpression>
                  <Operator>MatchesRegularExpression</Operator>
                  <Pattern>(?i:abc)</Pattern>
                </RegExExpression>
              </Expression>
            </MembershipRule>
            <MembershipRule>
              <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>
              <RelationshipClass>$MPElement[Name="Health.Service.Watcher.Group.ComputersStartingWithABC.ClassContainsEntity"]$</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>
          </MembershipRules>
        </DataSource>
      </Discovery>
    </Discoveries>
  </Monitoring>
  <Presentation>
  </Presentation>
  <LanguagePacks>
    <LanguagePack ID="ENU" IsDefault="false">
      <DisplayStrings>
        <DisplayString ElementID="Health.Service.Watcher.Group.ComputersStartingWithABC">
          <Name>Health Service Watcher Group (Computers starting with ABC)</Name>
        </DisplayString>
        <DisplayString ElementID="Health.Service.Watcher.Group.ComputersStartingWithABC.Class">
          <Name>Health Service Watcher Group (Computers starting with ABC)</Name>
        </DisplayString>
        <DisplayString ElementID="Health.Service.Watcher.Group.ComputersStartingWithABC.Class.DiscoveryRule">
          <Name>Populate</Name>
          <Description>This discovery rule populates the group</Description>
        </DisplayString>
      </DisplayStrings>
    </LanguagePack>
  </LanguagePacks>
</ManagementPack>

Comments

  • Anonymous
    January 01, 2003
    Correct.  The first part of the membership rule just populates the group with specific Windows Computer objects.  The second part of the membership rule (what you have pasted above) states any computer objects that are contained in THIS group, also add the associated HSW object.

  • Anonymous
    October 25, 2010
    Did you just add the following code to add the associated Health Service Watcher objects?  did you modify anything else? <MembershipRule>              <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>              <RelationshipClass>$MPElement[Name="Health.Service.Watcher.Group.ComputersStartingWithABC.ClassContainsEntity"]$</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>