Administer > Policies > Perl Script Policies > Perl Policy User Interface > Configuring the Data Source in Perl Policies

Configuring the Data Source in Perl Policies

The source page of the Perl Script policy editor enables you to set up the path to the Perl script or upload an embedded Perl script, define the polling interval, specify the subroutine that transfers the data and send any options to it, and specify the result data array and keys.

To access

  • In the Operations Connector user interface, click Create in the toolbar. Then click Event > REST Web service listener Perl Script.

  • In the Operations Connector user interface, click Create in the toolbar. Then click Metric > REST Web service listener Perl Script.

  • In the Operations Connector user interface, click Create in the toolbar. Then click Generic output > REST Web service listener Perl Script.

Alternatively, double-click an existing policy to edit it.

Click Source to open the policy Source page.

Understanding How Data is Collected and Processed using Perl Scripts

Collecting and processing data

The Perl script that is run periodically can be either loaded from an external location or embedded in the policy. You must also provide the name of the subroutine (sub) that is executed and any parameters that are passed to it.

During the execution of the script, Operations Connector initializes an embedded Perl interpreter (the Operations Agent Perl runtime), and passes all provided parameters to the Perl subroutine. The subroutine then collects and processes the data.

Parallel processing of the Perl script is not supported.

Passing data to policies

Before the subroutine exits, all data to be passed to Operations Connector must be present in the transfer data structure. This data structure must be an array of hash references and available as a global variable in the Perl script. You can define the name of this array, but it must match the name that you specify in the policy configuration.

Each hash inside the array indicates a single record of information. The hash is formed by pairs of an attribute name (the hash key) and a value, both represented as strings. In Operations Connector terminology, the attribute name is an input property and can be accessed as <$DATA:<attribute_name>> in set operations and as '<attribute_name>' in conditions.

Assuming that the hash %BASIC_METRIC_DATA, which you use to pass data to Operations Connector, contains the following attribute names:

my %BASIC_METRIC_DATA = (
    "counter_name"  => "<value>",
    "counter_value" => "<value>",
    "time_measured" => "<value>"
);

In this case, the Operations Connector input properties are:

<$DATA:counter_name>
<$DATA:counter_value>
<$DATA:time_measured>

If the execution is successful, the subroutine should return 0. Any other value indicates an error in the script execution and is logged to system.txt.

Tasks

How to configure the Perl script source

This task describes how configure the Perl script source and how the policy reads the data.

  1. Provide the path to the external Perl script or click to load an embedded script.

  2. Define the script polling interval.

  3. Provide the name of the subroutine that is executed. The name of the subroutine must match the name of the subroutine in the Perl script.

  4. Optionally, provide a list of parameters that are passed to the subroutine. Click to add a new parameter and to remove it.

    The parameters can be saved to the policy encrypted and are decrypted only before the subroutine is called. To encode the parameter values, right-click the parameter and select the option Encode as password.

  5. Provide the result data array name. The name must match the name of the result data array name in the subroutine.

  6. Provide a list of result data key names. Click to add a new key name and to remove it.

Related tasks

UI Descriptions

Perl Source Page

UI Element

Description

Script

The Perl script to be executed by the opcgeni runtime. The script can either be embedded or loaded from an external file:

  • Load Perl script file from filesystem path

    The path to the external Perl script that is run. The file is taken from the system on which the policy is executed; this might be the Operations Connector server or the OMi managed node.

  • Use embedded script

    Click to upload the Perl script file to the Perl Script policy.

Polling interval

Specifies the interval between two script executions in days, hours, minutes, and seconds.

Subroutine name The name of the Perl function (subroutine) which is called to perform data collection.
Input parameters

An ordered list of input parameters, passed as arguments to the Perl sub function in the configured order.

The parameters can be saved encrypted to the policy and are decrypted before the sub function is called. To encode the parameter values, click the parameter and then click the arrow that is displayed on the right of the parameter name and select the option Encode as password.

Result data array name The name of the Perl array of hash references used to transfer data between the embedded Perl interpreter and the opcgeni pipeline. They must match the ones in the Perl script.
Result data key names

A list of attribute names of interest for each hash element contained in the created Perl array of hashes. These make up the input properties to the policy processing pipeline.

Data source tag A user defined descriptive name for the collected data. This tag can be used to distinguish data sets generated by different policies. This may be useful in data forwarding scenario, for example for consumer applications that receive data from Operations Connectorthe agent.