SCOM 2012: Discovering a UNIX/Linux Role

SCOM 2012: Discovering a UNIX/Linux Role

Return to section contents

Discovering the Role (application)

This example assumes the use of the UNIX/Linux Authoring Library example MP. For more information on creating and building the MP authoring project, see Getting Started.

This example demonstrates the use of a “shell command” to discover a custom Computer Role for monitored UNIX/Linux computers.  The output (StdOut) of the command is evaluated with a Regular Expression, and if the expression is matched, the Role is discovered.  The example includes definition of the class types for the role and a computer group, as well as discovery of the role and computer group.  The example shell command:  ls /opt/myapp |wc –l will return the number 1 if the directory “/opt/myapp” exists on the UNIX/Linux computer.

For additional information about “Discovery” data sources defined in the Unix.Authoring.Library, review the documentation of the following data sources in the Unix.Authoring.Library Module Reference:

  • UNIX/Linux Timed Shell Command Discovery Data Source
  • UNIX/Linux Timed Shell Command Property Bag Discovery Data Source
  • UNIX/Linux Timed Shell Script Discovery Data Source
  • UNIX/Linux Timed Shell Script Property Bag Discovery Data Source

Note:  contents located between pairs of ## characters should be customized for your environment.  This includes ID and string values. Be sure to remove the ## characters before building the MP.

<ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<TypeDefinitions>
<EntityTypes>
<ClassTypes>
  <!-- Class definition for a UNIX/Linux Computer Role -->
  <ClassType ID="##MyMP.MyCutomRole##" Abstract="false" Accessibility="Public" Hosted="true" Singleton="false" Base="Unix!Microsoft.Unix.ComputerRole">
    <Property ID="RoleName" Type="string" Key="true" />
  </ClassType>
       
  <!-- Class definition for a Computer Group -->
  <ClassType ID="##MyMP.MyCustomRole.Group##" Accessibility="Public" Abstract="false" Base="SC!Microsoft.SystemCenter.ComputerGroup" Hosted="false" Singleton="true" Extension="false" />
       
</ClassTypes>
</EntityTypes>
</TypeDefinitions>
<Monitoring>
<Discoveries>
       
<!-- Discovery to discover instances of a Computer Role on UNIX/Linux computers, using a Shell Command  -->
<Discovery ID="##MyMP.MyCustomRole.Discovery##" Target="Unix!Microsoft.Unix.Computer" Enabled="true" ConfirmDelivery="false" Remotable="true" Priority="Normal">
  <Category>Discovery</Category>
  <DiscoveryTypes>
    <DiscoveryClass TypeID="##MyMP.MyCustomRole##">
      <Property TypeID="##MyMP.MyCustomRole###" PropertyID="RoleName" />
    </DiscoveryClass>
  </DiscoveryTypes>
  <DataSource ID="DS" TypeID="UnixAuth!Unix.Authoring.TimedShellCommand.Discovery.DataSource">
    <Interval>28800</Interval>
    <TargetSystem>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</TargetSystem>
    <ShellCommand>##ls /opt/myapp |wc –l##</ShellCommand>
    <Timeout>60</Timeout>
    <UserName>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/UserName$</UserName>
    <Password>$RunAs[Name="Unix!Microsoft.Unix.ActionAccount"]/Password$</Password>
    <FilterExpression>
      <RegExExpression>
        <ValueExpression>
          <XPathQuery>//*[local-name()="StdOut"]</XPathQuery>
        </ValueExpression>
        <Operator>MatchesRegularExpression</Operator>
        <Pattern>##^1##</Pattern>
      </RegExExpression>
    </FilterExpression>
    <ClassId>$MPElement[Name="##MyMP.MyCustomRole##"]$</ClassId>
    <InstanceSettings>
      <Settings>
        <Setting>
          <Name>$MPElement[Name='##MyMP.MyCustomRole##']/RoleName$</Name>
          <Value>##MyApp##</Value>
        </Setting>
        <Setting>
          <Name>$MPElement[Name='Unix!Microsoft.Unix.Computer']/PrincipalName$</Name>
          <Value>$Target/Property[Type="Unix!Microsoft.Unix.Computer"]/PrincipalName$</Value>
        </Setting>
        <Setting>
          <Name>$MPElement[Name='System!System.Entity']/DisplayName$</Name>
          <Value>##MyApp##</Value>
        </Setting>
      </Settings>
    </InstanceSettings>
  </DataSource>
</Discovery>
 
 
<!-- Discovery to populate a Computer Group with computers hosting the Role-->
<Discovery ID="##MyMP.MyCustomRole.Group.Discovery##" Enabled="true" Target="##MyMP.MyCustomRole.Group##" ConfirmDelivery="false" Remotable="true" Priority="Normal">
  <Category>Discovery</Category>
  <DiscoveryTypes>
    <DiscoveryRelationship TypeID="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer" />
  </DiscoveryTypes>
  <DataSource ID="GroupPopulationDataSource" TypeID="SC!Microsoft.SystemCenter.GroupPopulator">
    <RuleId>$MPElement$</RuleId>
    <GroupInstanceId>$MPElement[Name="##MyMP.MyCustomRole.Group##"]$</GroupInstanceId>
    <MembershipRules>
      <MembershipRule>
        <MonitoringClass>$MPElement[Name="Unix!Microsoft.Unix.Computer"]$</MonitoringClass>
        <RelationshipClass>
          $MPElement[Name="SC!Microsoft.SystemCenter.ComputerGroupContainsComputer"]$
        </RelationshipClass>
        <Expression>
          <Contains>
            <MonitoringClass>$MPElement[Name="##MyMP.MyCustomRole##"]$</MonitoringClass>
          </Contains>
        </Expression>
      </MembershipRule>
    </MembershipRules>
  </DataSource>
</Discovery>
 
</Discoveries>
</Monitoring>
 
<LanguagePacks>
<LanguagePack ID="ENU" IsDefault="true">
<DisplayStrings>
  <DisplayString ElementID="##MyMP.MyCustomRole##">
    <Name>##MyRole##</Name>
    <Description></Description>
  </DisplayString>
  <DisplayString ElementID="##MyMP.MyCustomRole##" SubElementID="RoleName">
    <Name>Role Name</Name>
    <Description></Description>
  </DisplayString>
  <DisplayString ElementID="##MyMP.MyCustomRole.Group##">
    <Name>##MyRole Computer Group##</Name>
    <Description></Description>
  </DisplayString>
  <DisplayString ElementID="##MyMP.MyCustomRole.Discovery##">
    <Name>##MyRole Discovery##</Name>
    <Description></Description>
  </DisplayString>
  <DisplayString ElementID="##MyMP.MyCustomRole.Group.Discovery##">
    <Name>##Populate MyRole Computer Group##</Name>
    <Description></Description>
  </DisplayString>
</DisplayStrings>
</LanguagePack>
</LanguagePacks>
 
</ManagementPackFragment>
Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post
Wiki - Revision Comment List(Revision Comment)
Sort by: Published Date | Most Recent | Most Useful
Comments
  • Ed Price - MSFT edited Revision 2. Comment: Needed the technology context in the title. Added it.

Page 1 of 1 (1 items)
Wikis - Comment List
Sort by: Published Date | Most Recent | Most Useful
Posting comments is temporarily disabled until 10:00am PST on Saturday, December 14th. Thank you for your patience.
Comments
  • Ed Price - MSFT edited Revision 2. Comment: Needed the technology context in the title. Added it.

  • Hi Kris,

    Shouldn't <ShellCommand>##ls /opt/myapp |wc –l##</ShellCommand> be <ShellCommand>##ls /opt/myapp -d |wc –l##</ShellCommand> ?

    Either way I couldn't get the linux box discovered using this template. No errors showed up in Event log. Is there a better way to track what SCOM is doing when it's trying to work through the discovery?

  • Rupert,

    You are correct, ls -d is appropriate for directories.  I can update the example.  For troubleshooting discoveries, I'd generally recommend the following:

    1) override the interval temporarily to something like 5 minutes

    2) Check the eventlog on the Mgmt Servers. An event 10801 would indicate problems in the Instance Settings or ClassId

    3) If the eventlog doesn't make it obvious, load up the Workflow Analzer.  The tool can be found as described in the debugging section here: social.technet.microsoft.com/.../18075.scom-2012-getting-started-with-the-unixlinux-authoring-library.aspx

    The WFA takes some getting used to, but is invaluable in allowing you to see the actual WS-Man data returned, the expression filter results, etc.

    It probably wouldn't hurt to check system logs on the agent to make sure you weren't attempting to use sudo when you didn't mean to.

Page 1 of 1 (3 items)