Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    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:

    1. Configure a JavaScript program or an external script.
    2. 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)

    3. Configure an event handler and specify the action you configured in Step 2.

      See Configuring Event Handlers (SRC CLI)

    Configuring JavaScript Programs

    Use the following statement to configure a JavaScript program for the SRC VTA:

    shared vta group name processor scripts javascript name {script script;return-type return-type;return-attribute return-attribute;}
    1. 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 js1
    2. Specify a function body in JavaScript.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set script script

      To 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.

    3. (Optional) Specify the Java type of the return attribute.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set return-type return-type

      Where the return-type is one of the following:

      • Integer
      • Long
      • Float
      • Double
      • String
      • Boolean
    4. (Optional) Specify the name of the return attribute.
      [edit shared vta group vta1 processor scripts javascript js1]user@host# set return-attribute return-attribute

      Specify 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.

    Configuring External Scripts

    Use the following statement to configure an external script for the SRC VTA:

    shared vta group name processor scripts external-script name {full-path full-path;parameters parameters;return-type return-type;return-attribute return-attribute;}
    1. 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 script1
    2. Specify the full path name to the external script.
      [edit shared vta group vta1 processor scripts external-script script1]user@host# set full-path full-path

      You must specify a fully qualified path to an executable program on the local file system.

    3. 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
    4. (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-type

      Where return-type is one of the following:

      • Integer
      • Long
      • Float
      • Double
      • String
      • Boolean
    5. (Optional) Specify the name of the return attribute.
      [edit shared vta group vta1 processor scripts external-script script1]user@host# set return-attribute return-attribute

      Specify 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.

    Published: 2014-12-16