Adding output filters

Ops Center Automator Service Builder User Guide

Version
11.0.x
Audience
anonymous
Part Number
MK-99AUT002-18

Standard output and standard error output are stored in the output property. Therefore, the best practice is to set filters on the standard output results to obtain the value you want by using regular expressions in the remote commands.

Example

To obtain the disk ID from the standard output property results, complete the following steps:

  1. Set a filter on the output property:

    diskid:n is the output method as the result of a script

    diskid:(.+) is the regular expression to filter the output property

  2. Create a script to pass the results.
  3. Use a remote command to set an output filter where:

    diskid:(.+) is the output filter

    diskid:1 is the standard output string

    blank is the value of the output property

Running the script gives the following results:

  • diskid:1 is the standard output string
  • 1 is the value of the output property

You specify output filters from the Remote Command tab that is accessed from the Copy/Edit Custom Plug-in dialog box.

To set an output filter:

From the Mapping Definition of Output Properties area, select and highlight the line of the output property, then click the edit (pencil) icon. Enter the details in the Edit Output Filter dialog box.

Continue to set environment variables as required.

Note: When specifying multiple groups in a regular expression, only values that match the first group are stored in the output property. In addition, If the regular expression applies to multiple value ranges, only the first range of values is stored in the output property.
Note: Regular expressions are evaluated in the multiline mode. To eliminate unwanted characters (including the line feed), you must write the regular expression specifying the single-line mode. The single-line mode is described as "(?s)" in the regular expression.

The cutout by the regular expression is the part grouped by the parentheses. The first group becomes the target of the cutout if multiple groups exist. Here are some examples of cutting out the standard output using a regular expression.

Example of extracting the string from a single line:

Standard output
server:sv001
CPU - 89%
Memory - 77%

Regular expression  
server:(.*)

Result of cutout
sv001

Example of extracting the string with multiple lines - 1:

Standard output
server:sv001
CPU - 89%
Memory - 77%

Regular expression
server:(?s)(.*)

Result of cutout
sv001
CPU - 89%
Memory - 77%

Example of extracting the string with multiple lines - 2:

Standard output
server:sv001
CPU - 89%
Memory - 77%

Regular expression  
server:(?s)(.*)\sMemory

Result of cutout
sv001
CPU - 89%