Example of creating an application pattern

Follow this example to see a step-by-step process of creating and defining the identification section for a new application pattern.

Before you begin

Basic knowledge of programming is desirable.

Role required: pd_admin

About this task

This example shows how to create a mapping pattern using the debug mode.

The pattern is for Apache Web Server on Unix.

Procedure

  1. Navigate to Pattern Designer > Discovery Patterns.
  2. Click New.
  3. Define the basic pattern attributes as follows:
    Field Description
    Pattern type Select Application.
    Name Enter Apache Web Server on Unix Pattern.
    CI Type Select Apache Web Server from the list.
    Operating system [Application patterns only] Clear the All check box and select the following check boxes from the list:
    • AIX Server
    • HPUX Server
    • Linux Server
    • Solaris Server
    • UNIX Server
    Run Order [Application patterns only] Leave the default None setting.
    Description This pattern discovers Apache Web Servers on Unix versions up to 2.4.

    Defining basic attributes for an application pattern
  4. Click Save.
  5. Create the identification section and define its basic properties:
    1. Under Identification Section, click New.
    2. Configure the following parameters:
      Field Value
      Name Enter Identification for HTTP(S) entry point type(s).
      Entry Point Types [Application patterns only] Select the following check boxes from the list:
      • HTTP(S) Endpoint
      • TCP Endpoint
      Find Process Strategy [Application patterns only] Select Listening Port.
      Order Enter 1.
    3. Click Save.
  6. Click the newly created identification section: Identification for HTTP(S) entry point type(s).
    The new identification section opens on the separate tab.
  7. Activate the debug mode:
    1. In the Pattern Designer, click Debug Mode.
      The Debug Identification Section window is displayed.
    2. Fill in the required details for the entry point type:
      Field Description
      Debug Type Select Top down for performing top-down discovery with Service Mapping or
      Type Select HTTP(S) for the entry point type from the list.
      URL Enter http://10.196.39.244:6080/ITO.
    3. Click Connect.

      The debug mode is activated and the green dot appears on the debug button: .

      Notice that the following variables are populated with values once the debug mode is active:
      • computer_system ‒ the Apache host information
      • entry_point ‒ identified by the URL in this case
      • process ‒ the Apache process information
  8. Check that the process name on the CI is Apache Web Server:
    1. Rename the first step of the identification section to Check process name to match Apache.
    2. Select Match from the Operation list.
    3. Enter $process.executable in the first condition field.

      Defining conditions
    4. Select Contains from the conditional operator list.
    5. Enter "httpd" in the second condition field.
    6. Click the plus icon to add another condition.
    7. Enter $process.executable in the first condition field.
    8. Select Contains from the conditional operator list.
    9. Enter "apache" in the second field.
    10. Define that this match operation must match one of these conditions: Select Any from the Meet list.
    11. Click Test and verify that you get the following message: No changes were made during this test.
  9. Populate the label attribute for your CI:
    1. In the Steps tree, click to add a step blow the first step.
    2. Rename the new step to sets the display label.
    3. Select Set Parameter Value from the Operation list.
    4. Enter "Apache" in the Value field.
    5. Enter $name in the Name field.
    6. Click Test and verify that the following message appears:

      Populate label attribute step test result.
    7. Click Close.
  10. Populate the home directory attribute:
    1. In the Steps tree, add a step and rename it to Get home dir.
    2. Select Parse variable from the Operation list.
      This operation extracts the value after the -d in the content box.
    3. Expand the process variable in the Temporary Variables pane.
    4. Drag the commandLine variable from the Temporary Variables pane into the variable field under operation.

      Populating the variable value from the Temporary Variables pane
      Note: For more information on using the drag-and-drop feature, see Enter values and variables in patterns.
    5. Select Command line Unix style from the Define Parsing list.
    6. In the Variables pane, add the new intall_directory variable.
    7. Click Test.
  11. Obtain the home directory attribute from the HTTP daemon.
    If the previous step populated the home directory attribute, skip this step. In this example, it is necessary to perform it.
    1. In the Steps tree, add a new step and rename it to Condition – check that home dir was set if not extract it from httpd –V.
    2. Select Parse command output from the Operation list.
      This operation extracts the value after the -d in the content box.
    3. Click Precondition.
    4. Enter $install_directory in the condition value field.
    5. Select Is Empty from the conditional operator list.
    6. Select True from the If condition Is list.
    7. Enter $process.executablePath+" -V " in the Set Command Details field.
    8. Click Run Command.
    9. Select Delimited text from the Define Parsing list.
    10. Enter HTTPD_ROOT in the Include lines field.
    11. Click the Edit button next to Delimiters.

      Defining the delimiters for the Parse command output operation.
    12. Add the two delimiters: equals (=) and quotes (").
    13. Click OK.
    14. Enter 2 in the Positions field.
    15. Click Test.
      The Debug Results window shows the home directory attribute populated with a value.
    16. Click OK.
  12. Populate the CI configuration file attribute:
    1. In the Steps tree, add a new step and rename it to Get config file
    2. Select Parse variable from the Operation list.
    3. Expand the process variable in the Temporary Variables pane.
    4. Drag the commandLine variable from the Temporary Variables pane into the Enter Variable field.
      The value is populated: /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf.
    5. Select Command Line Unix Style from Define Parsing list.

      Populating the variable value from the Temporary Variables pane
    6. Click Retrieve.
    7. Enter -d in the Keyword field.
    8. Select the value in the Output pane and create a new variable named install_directory.
    9. Click Test.
  13. Extract the CI configuration file attribute from the HTTP daemon:
    If the previous step populated the configuration file attribute, skip this step. In this example, it is necessary to perform it.
    1. In the Steps tree, add a new step and rename it to Condition – check that conf_file was set if not extract it from httpd –V.
    2. Select Parse command output from the Operation list.
    3. Click Precondition.
    4. Enter $config_file in the condition value field.
    5. Select Is Empty from the conditional operator list.

      Defining the condition for the Parse command output operation.
    6. Enter $process.executablePath+" -V " in the Set Command Details field.
    7. Click Run Command.
    8. Select Delimited text from the Define Parsing list.
    9. Enter SERVER_CONFIG_FILE in the Include lines field.
    10. Click the Edit button next to Delimiters.

      Defining the delimiters for the Parse command output operation.
    11. Add the two delimiters: equals (=) and quotes (").
    12. Click OK.
    13. Enter 2 in the Positions field.
    14. If the new conf_file variable is not added automatically, create it in the Variables pane.
    15. Click Test.
      The Debug Results window shows the configuration file attribute populated with a value.
    16. Click OK.
  14. If the configuration file attribute is still not populated, perform this step:
    1. In the Steps tree, add a new step and rename it to default location of conf file.
    2. Select Set Parameter Value from the Operation list.
    3. Click Precondition.
    4. Enter $conf_file in the condition value field.
    5. Select Is Empty from the conditional operator list.
    6. Select True from the If condition is list.
    7. Enter $home_dir+"/conf/httpd.conf" in the Value field.
    8. Enter $conf_file in the Name field.
    9. Click Test and verify that the configuration file attribute is populated.
  15. Concatenate the home directory and configuration file values:
    1. In the Steps tree, add a new step and rename it to check if the SERVER_CONFIG_FILE is relative or not.
    2. Select Set Parameter Value from the Operation list.
    3. Click Precondition.
    4. Enter $conf_file in the condition value field.
    5. Select Starts With from the conditional operator list.
    6. Enter "/" in the string value.
    7. Select False from the If condition is list.
    8. Enter $home_dir+"/"$conf_file in the Value field.
    9. Enter $conf_file in the Name field.
    10. Click Test and verify that the configuration file attribute is populated.
  16. Populate the version attribute:
    1. In the Steps tree, add a new step and rename it to get version from version.signature (IBM HTTPSERVER).
    2. Select Parse file from the Operation list.
    3. Enter the concatenated $install_directory variable and "/version.signature" string ($home_dir+"/version.signature") in the Select File field.
    4. Click Retrieve File Content.
    5. Create the Version variable in the Variables pane.
    6. Click Test and verify that the version attribute is populated.
      In this example, the version is not extracted at this stage.
  17. Extract the version attribute from the HTTP daemon:
    1. In the Steps tree, add a step and rename it to Condition - check that version was set if not extract it from httpd -v.
    2. Select Parse command output from the Operation list.
    3. Click Precondition.
    4. Enter $version in the condition value field.
    5. Select Is Empty from the conditional operator list.
    6. Click the plus icon (+) to add another condition.
    7. Enter $version in the condition value field.
    8. Select Contains from the conditional operator list.
    9. Enter "directory" in the string value.
    10. Select Any from the Meet list.
    11. Select true from the If precondition is list.

      Configuring precondition for extracting the version attribute from the HTTP daemon.
    12. Enter $process.executablePath+" -V | grep 'Server version' | cut -d '/' -f 2 | cut -d ' ' -f 1" in the Set Command Details field.
    13. Click Run Command and verify that the version attribute appears in the Output pane.
    14. Select Position From End from the Define Parsing list.
    15. Enter 1 in the Positions field in the Variables pane.

      Defining parameters for extracting the version from HTTPD
    16. Click Test and verify that the configuration file attribute is populated.
      Note:

      The version number appears only in the Temporary Variables pane, not in the CI Attributes pane.


      Viewing preliminary results in the CI Attributes pane.
      Notice that at this stage you have successfully identified the Apache Web Server and populated its various attributes except the version attribute that is left blank on purpose.
  18. If the version is still not populated, extract it from the IHS.product file:
    1. In the Steps tree, add a step and rename it to set version if still empty.
    2. Select Parse File from the Operation list.
    3. Click Precondition.
    4. Enter $version in the condition value field.
    5. Select Is Empty from the conditional operator list.
    6. Click the plus icon (+) to add another condition.
    7. Enter $version in the condition value field.
    8. Select Contains from the conditional operator list.
    9. Enter "directory" in the string value.
    10. Select Any from the Meet list.
    11. Select true from the If precondition is list.
    12. Enter $install_directory + "/properties/version/IHS.product" in the Select File field.
    13. Click Retrieve File Content.
      The content of the file is displayed in the Output pane.
    14. Select XML File from the Define Parsing list.
    15. Mark the version value in the Output pane, and then enter version in the variable pop-up.

      Defining parameters for setting version
  19. Find additional attributes by reusing a shared step library.
    1. In the Steps tree, add a step, and rename the new step to reference to enrich library.
    2. .
    3. Select Library reference from the Operation list.
    4. Select Apache Enrich Attributes from the Library list.
      This operation inserts a sequence of preconfigured substeps into the step tree. For information on how to create shared step libraries, see Reuse a shared step library.

      Reusing preconfigured step sequence.
  20. Populate process-related attributes:
    1. In the Steps tree, add a step and rename it to get processes.
    2. Select Get process from the Operation list.
    3. Enter "httpd" in the Command Line field.
    4. Enter in the $procs in the Specify Target Variable field.
    5. Click Test and verify that the attributes are displayed:

      Viewing discovered process-related attributes.
    6. Click Close when done.
  21. Discover the process IDs:
    1. In the Steps tree, add a step and rename it to set process_ids.
    2. Select Parse variable from the Operation list.
    3. Enter $procs[*].pid in the Enter Variable field.
    4. Select Delimited text from the Define Parsing list.
    5. Click Retrieve.
      The content is displayed in the Output pane.
    6. Create the process_ids variable in the Variables pane.
    7. Enter 1 in the Positions field.

      Defining parameters for discovering process IDs.
    8. Click Test.
    9. Verify that all the necessary attributes are populated:

      Verifying that process IDs are populated.
  22. Click Save.
  23. Verify that Discovery and Service Mapping can use the identification section you defined:
    1. Run the horizontal discovery of an Apache Web Server using this pattern.
    2. Navigate to the table of Apache Web Servers and check that there is an entry for this CI.
    3. Run the top-down discovery of the same CI.
    4. Check the same Apache Web Servers table.
    5. Verify that the record is not duplicated.

      Checking that the CI records are not duplicated.
      It means that the results of both horizontal and top-down discovery are written in the CMDB under the same record. The identification section of the pattern is correct.