Example of creating a pattern

Follow this example to see a step-by-step process of creating and defining a new pattern for Service Mapping.

Before you begin

Role required: admin and sm_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 Service Mapping > Administration > Discovery Patterns.
  2. Click New.
  3. Define the basic pattern attributes as described below:
    Field Description
    Name Enter Apache Web Server on Unix pattern.
    CI type Select Apache Web Server from the list.
    Pattern type Select Service Mapping.

    Defining basic pattern attributes
  4. Click Manage Pattern.
    The Pattern Designer window opens.

    Main pattern definition window
  5. Define advanced attributes as follows:
    Field Description
    Description This pattern discovers Apache Web Servers on Unix versions up to 2.4.
    Operating system Select Unix:All from the list.
  6. Click Save.
  7. In the Pattern Designer Pattern window, click the plus icon in the Identification Sections pane.
  8. Define the identification section as follows:
    Field Value
    Name Enter Identification for HTTP(S) entry point type(s).
    Entry Point Types Select TCP, HTTP(S) from the list.
    Find Process Strategy Select LISTENING_PORT for the strategy.
  9. Click Create New.
    The new identification section appears in the Identification Sections pane.
  10. Double-click the created identification section.
    The Identification Section window opens.

    Identification Section window
  11. Activate the debug mode:
    1. In the Pattern Designer, click Debug.
      The Debug Identification Section window is displayed.
    2. Fill in the required details for the entry point type:
      Field Description
      Type Select HTTP(S) for the entry point type from the list.
      URL Enter http://10.1.1.23:6080/Trade/11.
    3. In the Debug Identification Section window, click Debug The debug button.

      The debug mode is activated and the green check mark 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
      • environmentVariables ‒ that are displayed when a process variable is displayed
  12. Check that the process name on the CI is Apache Web Server:
    1. Rename the first step to Check process name to match Apache.
    2. Select Match from the Operation list.
    3. Enter $process.executable in the process name field.
    4. Select Contains from the conditional operator list.
    5. Enter httpd in the string field.
    6. Click the plus icon to add another condition row.
    7. Enter $process.executable in the process name field.
    8. Select Contains from the conditional operator list.
    9. Enter apache in the string field.
    10. Click OR for the logical operator.

      Define the check the process name step.
    11. Click Test and verify that you get the following message: No changes were made during this test.
  13. Populate the label attribute for your CI:
    1. In the step tree, right-click the first step and select Add Step After.
    2. Rename the new step to sets the display label.
    3. Select Set variable from the Operation list.
    4. Enter "Apache" in the Value field.
      Note: Make sure to enter the value with the quote marks (").
    5. Enter $label in the Parameter field.
    6. Click Test and verify that the following message appears:

      Populate label attribute step test result
    7. Click OK.
  14. Populate the home directory attribute:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to Get home dir.
    3. Select Parse variable from the Operation list.
      This operation extracts the value after the -d in the content box.
    4. Expand the process variable in the Temporary Variables pane.
    5. 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 Useful shortcuts in Pattern Designer.
    6. Click Test.
  15. Obtain the home directory attribute if Pattern Designer from 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 step tree, right-click the last step and select Add Step After.
    2. Rename the new step to Condition – check that home dir was set if not extract it from httpd –V.
    3. Select Parse command output from the Operation list.
      This operation extracts the value after the -d in the content box.
    4. Click Set Precondition.
    5. Enter $install_directory in the condition value field.
    6. Select Is Empty from the conditional operator list.

      Defining the condition for the Parse command output operation.
    7. Enter $process.executablePath+" -V " in the Command field.
    8. Click Run Command.
    9. Select Delimited text from the Parsing strategy list.
    10. Enter HTTPD_ROOT in the Include lines field.

      Defining the command for the Parse command output operation.
    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.
  16. Populate the CI configuration file attribute:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to Get config file.
    3. Select Parse variable from the Operation list.
      This operation extracts the value after the -d in the content box.
    4. Expand the process variable in the Temporary Variables pane.
    5. 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 Useful shortcuts in Pattern Designer.
      The value is populated: /usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf.
    6. Click Test.
  17. Extract the CI configuration file attribute from 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 step tree, right-click the last step and select Add Step After.
    2. Rename the new step to Condition – check that conf_file was set if not extract it from httpd –V.
    3. Select Parse command output from the Operation list.
    4. Click Set Precondition.
    5. Enter $conf_file in the condition value field.
    6. Select Is Empty from the conditional operator list.

      Defining the condition for the Parse command output operation.
    7. Enter $process.executablePath+" -V " in the Command field.
    8. Click Run Command.
    9. Select Delimited text from the Parsing strategy list.
    10. Enter SERVER_CONFIG_FILE in the Include lines field.
    11. Click the Edit button next to Delimiters that is, to the equal sign and double quote mark, and Positions to 2

      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. If the new conf_file variable is not added automatically, create it in the Variables pane.
    16. Click Test.
      The Debug Results window shows the configuration file attribute populated with a value.
    17. Click OK.
  18. If the configuration file attribute is still not populated, perform this step:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to default location of conf file.
    3. Select Set variable from the Operation list.
    4. Click Set Precondition.
    5. Enter $conf_file in the condition value field.
    6. Select Is Empty from the conditional operator list.
    7. Enter $home_dir+"/conf/httpd.conf" in the Value field.
    8. Enter $conf_file in the Parameter field.
    9. Click Test and verify that the configuration file attribute is populated.
  19. Concatenate the home directory and configuration file values:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to check if the SERVER_CONFIG_FILE is relative or not.
    3. Select Set variable from the Operation list.
    4. Click Set Precondition.
    5. Enter $conf_file in the condition value field.
    6. Select Starts With from the conditional operator list.
    7. Enter "/" in the string value.
    8. Enter $home_dir+"/"$conf_file in the Value field.
    9. Enter $conf_file in the Parameter field.

      Defining parameters for the Set variable operation.
    10. Click Test and verify that the configuration file attribute is populated.
  20. Populate the version attribute:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to get version from version.signature (IBMHTTPSERVER).
    3. Select Parse file from the Operation list.
    4. Enter the concatenated $home_dir variable and "/version.signature" string ($home_dir+"/version.signature") in the File path field.
    5. Click Retrieve File.

      Defining parameters for the Parse file operation.
    6. Click Test and verify that the version attribute is populated.
      In this example, the version is not extracted at this stage.
  21. Extract the version attribute from HTTP daemon:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to Condition - check that version was set if not extract it from httpd -v.
    3. Select Parse command output from the Operation list.
    4. Click Set Precondition.
    5. Enter $version in the condition value field.
    6. Select Is Empty from the conditional operator list.
    7. Click the plus icon (+) to add another condition.
    8. Enter $version in the condition value field.
    9. Select Contains from the conditional operator list.
    10. Enter "directory" in the string value.
    11. Click OR for the logical operator.

      Define the check the process name step.
    12. Select True from the If precondition is list.
    13. Enter $process.executablePath+" -V | grep 'Server version' | cut -d '/' -f 2 | cut -d ' ' -f 1" in the Command field.
    14. Click Run Command and verify that the version attribute appears in the content box.
    15. Click Test and verify that the configuration file attribute is populated.
      Note: The version number is not moved into the CI Attributes pane because confirmation of its value in the Content box and the Debug Results dialog box is sufficient.
      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.

      Viewing preliminary results in the CI Attributes pane.
  22. Find additional attributes by reusing a step sequence.
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to reference to enrich library.
    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.

      Reusing preconfigured step sequence.
  23. Populate process-related attributes:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to get processes.
    3. Select Get process from the Operation list.
    4. Click Test and verify that the attributes are displayed:

      Viewing discovered process-related attributes.
  24. Discover the process IDs:
    1. In the step tree, right-click the last step and select Add Step After.
    2. Rename the new step to process_ids.
    3. Select Parse variable from the Operation list.
    4. Enter $procs[*].pid in the variable field.
    5. Select Delimited text from the Parsing strategy list.

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

      Verifying that process IDs are populated.
  25. Click Save.