Example of creating an application pattern
- UpdatedAug 3, 2023
- 10 minutes to read
- Vancouver
- Service Mapping
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
- Navigate to All > Pattern Designer > Discovery Patterns.
- Click New.
-
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.
- Click Save.
-
Create the identification section and define its basic properties:
- Under Identification Section, click New.
-
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. - Click Save.
-
Click the newly created identification section: Identification for
HTTP(S) entry point type(s).
The new identification section opens on the separate tab.
-
Activate the debug mode:
-
In the Pattern Designer, click Debug Mode.
The Debug Identification Section window is displayed.
-
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. -
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
-
In the Pattern Designer, click Debug Mode.
-
Check that the process name on the CI is Apache Web Server:
- Rename the first step of the identification section to Check process name to match Apache.
- Select Match from the Operation list.
-
Enter $process.executable in the first condition
field.
- Select Contains from the conditional operator list.
- Enter "httpd" in the second condition field.
- Click the plus icon to add another condition.
- Enter $process.executable in the first condition field.
- Select Contains from the conditional operator list.
- Enter "apache" in the second field.
- Define that this match operation must match one of these conditions: Select Any from the Meet list.
- Click Test and verify that you get the following message: No changes were made during this test.
-
Populate the label attribute for your CI:
-
In the Steps tree, click
to add a step blow the first step.
- Rename the new step to sets the display label.
- Select Set Parameter Value from the Operation list.
- Enter "Apache" in the Value field.
- Enter $name in the Name field.
-
Click Test and verify that the following message
appears:
- Click Close.
-
In the Steps tree, click
-
Populate the home directory attribute:
- In the Steps tree, add a step and rename it to Get home dir.
-
Select Parse variable from the
Operation list.
This operation extracts the value after the -d in the content box.
- Expand the process variable in the Temporary Variables pane.
-
Drag the commandLine variable from the Temporary Variables pane into
the variable field under operation.
Note: For more information on using the drag-and-drop feature, see Enter values and variables in patterns. - Select Command line Unix style from the Define Parsing list.
- In the Variables pane, add the new install_directory variable.
- Click Test.
-
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.
- 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.
-
Select Parse command output from the
Operation list.
This operation extracts the value after the -d in the content box.
- Click Precondition.
- Enter $install_directory in the condition value field.
- Select Is Empty from the conditional operator list.
- Select True from the If condition Is list.
- Enter $process.executablePath+" -V " in the Set Command Details field.
- Click Run Command.
- Select Delimited text from the Define Parsing list.
- Enter HTTPD_ROOT in the Include lines field.
-
Click the Edit button next to
Delimiters.
- Add the two delimiters: equals (=) and quotes (").
- Click OK.
- Enter 2 in the Positions field.
-
Click Test.
The Debug Results window shows the home directory attribute populated with a value.
- Click OK.
-
Populate the CI configuration file attribute:
- In the Steps tree, add a new step and rename it to Get config file
- Select Parse variable from the Operation list.
- Expand the process variable in the Temporary Variables pane.
-
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.
-
Select Command Line Unix Style from
Define Parsing list.
- Click Retrieve.
- Enter -d in the Keyword field.
- Select the value in the Output pane and create a new variable named install_directory.
- Click Test.
-
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.
- 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.
- Select Parse command output from the Operation list.
- Click Precondition.
- Enter $config_file in the condition value field.
-
Select Is Empty from the conditional operator
list.
- Enter $process.executablePath+" -V " in the Set Command Details field.
- Click Run Command.
- Select Delimited text from the Define Parsing list.
- Enter SERVER_CONFIG_FILE in the Include lines field.
-
Click the Edit button next to
Delimiters.
- Add the two delimiters: equals (=) and quotes (").
- Click OK.
- Enter 2 in the Positions field.
- If the new conf_file variable is not added automatically, create it in the Variables pane.
-
Click Test.
The Debug Results window shows the configuration file attribute populated with a value.
- Click OK.
-
If the configuration file attribute is still not populated, perform this
step:
- In the Steps tree, add a new step and rename it to default location of conf file.
- Select Set Parameter Value from the Operation list.
- Click Precondition.
- Enter $conf_file in the condition value field.
- Select Is Empty from the conditional operator list.
- Select True from the If condition is list.
- Enter $home_dir+"/conf/httpd.conf" in the Value field.
- Enter $conf_file in the Name field.
- Click Test and verify that the configuration file attribute is populated.
-
Concatenate the home directory and configuration file values:
- In the Steps tree, add a new step and rename it to check if the SERVER_CONFIG_FILE is relative or not.
- Select Set Parameter Value from the Operation list.
- Click Precondition.
- Enter $conf_file in the condition value field.
- Select Starts With from the conditional operator list.
- Enter "/" in the string value.
- Select False from the If condition is list.
- Enter $home_dir+"/"$conf_file in the Value field.
- Enter $conf_file in the Name field.
- Click Test and verify that the configuration file attribute is populated.
-
Populate the version attribute:
- In the Steps tree, add a new step and rename it to get version from version.signature (IBM HTTPSERVER).
- Select Parse file from the Operation list.
- Enter the concatenated $install_directory variable and "/version.signature" string ($home_dir+"/version.signature") in the Select File field.
- Click Retrieve File Content.
- Create the Version variable in the Variables pane.
-
Click Test and verify that the version attribute
is populated.
In this example, the version is not extracted at this stage.
-
Extract the version attribute from the HTTP daemon:
- In the Steps tree, add a step and rename it to Condition - check that version was set if not extract it from httpd -v.
- Select Parse command output from the Operation list.
- Click Precondition.
- Enter $version in the condition value field.
- Select Is Empty from the conditional operator list.
- Click the plus icon (+) to add another condition.
- Enter $version in the condition value field.
- Select Contains from the conditional operator list.
- Enter "directory" in the string value.
- Select Any from the Meet list.
-
Select true from the If precondition
is list.
- Enter $process.executablePath+" -V | grep 'Server version' | cut -d '/' -f 2 | cut -d ' ' -f 1" in the Set Command Details field.
- Click Run Command and verify that the version attribute appears in the Output pane.
- Select Position From End from the Define Parsing list.
-
Enter 1 in the Positions
field in the Variables pane.
-
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.
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.
-
If the version is still not populated, extract it from the IHS.product file:
- In the Steps tree, add a step and rename it to set version if still empty.
- Select Parse File from the Operation list.
- Click Precondition.
- Enter $version in the condition value field.
- Select Is Empty from the conditional operator list.
- Click the plus icon (+) to add another condition.
- Enter $version in the condition value field.
- Select Contains from the conditional operator list.
- Enter "directory" in the string value.
- Select Any from the Meet list.
- Select true from the If precondition is list.
- Enter $install_directory + "/properties/version/IHS.product" in the Select File field.
-
Click Retrieve File Content.
The content of the file is displayed in the Output pane.
- Select XML File from the Define Parsing list.
-
Mark the version value in the Output pane, and
then enter version in the variable pop-up.
-
Find additional attributes by reusing a shared step library.
- In the Steps tree, add a step, and rename the new step to reference to enrich library.
- Select Library reference from the Operation list.
-
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.
-
Populate process-related attributes:
- In the Steps tree, add a step and rename it to get processes.
- Select Get process from the Operation list.
- Enter "httpd" in the Command Line field.
- Enter in the $procs in the Specify Target Variable field.
-
Click Test and verify that the attributes are
displayed:
- Click Close when done.
-
Discover the process IDs:
- In the Steps tree, add a step and rename it to set process_ids.
- Select Parse variable from the Operation list.
- Enter $procs[*].pid in the Enter Variable field.
- Select Delimited text from the Define Parsing list.
-
Click Retrieve.
The content is displayed in the Output pane.
- Create the process_ids variable in the Variables pane.
-
Enter 1 in the Positions
field.
- Click Test.
-
Verify that all the necessary attributes are populated:
- Click Save.
-
Verify that Discovery and
Service Mapping can use
the identification section you defined:
- Run the horizontal discovery of an Apache Web Server using this pattern.
- Navigate to the table of Apache Web Servers and check that there is an entry for this CI.
- Run the top-down discovery of the same CI.
- Check the same Apache Web Servers table.
-
Verify that the record is 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.
Related Content
- Activate pattern Debug mode
Working in Debug mode, Pattern Designer performs all operations as you configure them. It allows you to see results immediately.