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.
In the BSM Connector user interface, click in the toolbar. Then click Event >
Perl Script.
In the BSM Connector user interface, click in the toolbar. Then click Metric >
Perl Script.
In the BSM Connector user interface, click in the toolbar. Then click Generic output >
Perl Script.
Alternatively, double-click an existing policy to edit it.
Click Source to open the policy Source page.
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, BSM 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 polices
Before the subroutine exits, all data to be passed to BSM 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 BSM 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 BSM Connector, contains the following attribute names:
my %BASIC_METRIC_DATA = ( "counter_name" => "<value>", "counter_value" => "<value>", "time_measured" => "<value>" );
In this case, the BSM 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
.
This task describes how configure the Perl script source and how the policy reads the data.
Provide the path to the external Perl script or click to load an embedded script.
Define the script polling interval.
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.
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.
Provide the result data array name. The name must match the name of the result data array name in the subroutine.
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:
For more information on how to write Perl scripts, see Understanding How Data is Collected and Processed using Perl Scripts. |
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 BSM Connector. |