Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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>