Configuring the SRC VTA Scripts Processor (SRC CLI)
The scripts processor can invoke external executable scripts or JavaScript programs. We recommend using JavaScript programs for better performance.
External scripts are executable programs, such as shell scripts, that are available on the SRC VTA’s host. Each external script can perform a task and return a value. If the script returns a value, the value can be added to the current event as an event attribute.
JavaScript programs are used to process SRC VTA event attributes. For example, a JavaScript program can convert SRC VTA event attributes in a timestamp to a date string and add them to the event as a new attribute. The attributes can then be used for subsequent actions, such as sending an e-mail notification to the subscriber. The JavaScript program can refer to any attributes of the event being processed and return a value.
Configuring the SRC VTA scripts processor involves the following tasks:
Configuring the SRC VTA to Run Scripts
To configure the scripts processor:
- Configure a JavaScript program or an external script.
- Configure an action for the event
handler that calls the appropriate script function.
The action specifies a function that the scripts processor performs on events. You can set up an action to run either an external script or a JavaScript program.
Specify the scripts-run-javascript function if the script is a JavaScript.
Specify the scripts-run-external-script function if the script is an external script.
When you specify these functions, you need to specify the name of a script you previously configured by using the shared vta group id processor scripts statement. If the script configuration contains a return-attribute and return-type, an attribute with that name and type are added to the event after the script is executed.
See Configuring Actions for SRC VTA Event Handlers (SRC CLI)
- Configure an event handler and specify the action you configured in Step 2.
See also
Configuring JavaScript Programs
Use the following statement to configure a JavaScript program for the SRC VTA:
From configuration mode, access the statement that configures a JavaScript script and specify the name of the JavaScript program. For example, to configure a JavaScript script called js1:
[edit]user@host# edit shared vta group vta1 processor scripts javascript js1Specify a function body in JavaScript.
[edit shared vta group vta1 processor scripts javascript js1]user@host# set script scriptTo refer to the event attributes being processed, include the attribute name delimited by angle brackets (<and>). The JavaScript program can verify whether the event has the referenced attribute. If a referenced attribute does not exist in the event, the attribute’s value is null. The JavaScript program must return a value.
(Optional) Specify the Java type of the return attribute.
[edit shared vta group vta1 processor scripts javascript js1]user@host# set return-type return-typeWhere the return-type is one of the following:
Integer
Long
Float
Double
String
Boolean
(Optional) Specify the name of the return attribute.
[edit shared vta group vta1 processor scripts javascript js1]user@host# set return-attribute return-attributeSpecify an attribute that provides the return value of the script as a valid Java identifier that subsequent actions and event handlers can refer to. If this attribute is not set, the return value is not added to the event as an event attribute.
JavaScript scripts must return an attribute value. The name of a return attribute cannot start with an underscore (_) because these event attributes are reserved for internal use.
See also
Configuring External Scripts
Use the following statement to configure an external script for the SRC VTA:
From configuration mode, access the statement that configures an external script and specify the name of the external script. For example, to configure an external script called script1:
[edit]user@host# edit shared vta group vta1 processor scripts external-script script1Specify the full path name to the external script.
[edit shared vta group vta1 processor scripts external-script script1]user@host# set full-path full-pathYou must specify a fully qualified path to an executable program on the local file system.
Specify the parameters required by the script as [a b c]. When an action invokes the script, the action must supply values for these parameters in the same order as they are defined here.
[edit shared vta group vta1 processor scripts external-script script1]user@host# set parameters parameters(Optional) Specify the Java type of the return attribute.
[edit shared vta group vta1 processor scripts external-script script1]user@host# set return-type return-typeWhere return-type is one of the following:
Integer
Long
Float
Double
String
Boolean
(Optional) Specify the name of the return attribute.
[edit shared vta group vta1 processor scripts external-script script1]user@host# set return-attribute return-attributeSpecify an attribute that provides the return value of the script as a valid Java identifier that subsequent actions and event handlers can refer to. If this attribute is not set, the return value is not used by the event. The external script returns the value by printing to standard output.
Note The name of a return attribute cannot start with an underscore (_) because these event attributes are reserved for internal use.