Automation Center Documentation

Using Variables and Functions

From OpsWise Documentation Wiki

image:pdficon_small.gif Open as PDF

Contents

Overview

OpsWise Automation Center supports the following types of variable, all of which can be used in free text fields within tasks:

  • User-Defined Variables -- These variables are created by the user.
  • Built-In Variables -- These variables are maintained by the system and allow you to access information about task instances and other related data, such as task name, task status, and trigger name.
  • Functions -- These calculate some value, such as current date and time, or perform some function, such as ReplaceAll.

Each of these is described in more detail below.

User-Defined Variables

You can define Opswise variables in four different locations:

  • Trigger variables are entered by clicking the Variables tab in a trigger. Trigger variables are stored in the table ops_local_variable.
  • Task variables are entered by clicking the Variables tab in a task. Task variables are stored in the table ops_local_variable.
  • Workflow variables are entered by clicking the Variables tab in a workflow. Workflow variables are stored in the table ops_local_variable.
  • Global variables are entered by selecting Automation Center > Variables from the Navigation Pane. Global variables are stored in the table ops_variable.

Once the task has been launched and the variables are resolved, they are referred to as task instance variables. The task instance variables are stored in hashed format in the table ops_map_table.

You can manually launch tasks and temporarily set user-defined variables. Click here for instructions.

Important Note -- Do not define OpsWise Automation Center variables with the prefix “ops_”. That prefix is reserved for built-in variables.

Resolving User-Defined Variables

When OpsWise Automation Center creates a task instance from a task definition, it also resolves all variables specified in its free text fields. Because you can define variables at four different levels (trigger, task, workflow, and global), OpsWise Automation Center follows a prescribed formula to determine which variable takes precedence if duplicate variables have been defined. The general order of precedence is: 1) task trigger, 2) task, 3) workflow trigger, 4) workflow, 5) global.

The following scenarios provide more detailed information about how OpsWise Automation Center variables are resolved.

For tasks launched by a trigger:

  1. If the trigger defines the variable in the variables tab, that value is used to resolve the variable.
  2. If the trigger does not define the variable, the value from the variable tab in the task definition is used.
  3. If neither the trigger nor the task define the variable, the variable definition in the global variables table is used.
  4. If the global variables table does not define the variable, the variable remains unresolved.

image:ops variable res launched by trigger.gif

For tasks launched by a workflow:

  1. If the task defines the variable in the variables tab, that value is used to resolve the variable.
  2. If the task does not define the variable, and the workflow was launched by a trigger, the value defined in the trigger is used.
  3. If the workflow's trigger does not define the variable or the workflow was not launched by a trigger, the value defined in the workflow is used.
  4. If the workflow does not define the variable, and there is a parent workflow, the value defined in the parent workflow's trigger is used. If the trigger does not define the variable or if there is no trigger, the value defined in the parent workflow is used. If the parent workflow does not define the variable, the system checks up a level for another parent workflow and repeats the process. This continues until the top level workflow is reached.
  5. If the top-level workflow does not define the variable, the variable definition in the global variables table is used.
  6. If the global variables table does not define the variable, the variable remains unresolved.

image:variable resolution launched by workflow.gif

For tasks launched manually:

  1. If the task defines the variable in the variables tab, that value is used to resolve the variable.
  2. If the task does not define the variable, the variable definition in the global variables table is used.
  3. If the global variables table does not define the variable, the variable remains unresolved.

image:variable resolution launched manually.gif

Format for Using Variables

When you enter a variable into a text field, precede the variable with the dollar sign ($) and enclose the variable in curly braces. You can enter a series of variables or nested variables. Examples are:

${variable_name}
${v1}${v2}
${${inner_variable}}

Creating a New Variable

  1. For global variables, select Variables from the Navigation Pane. For trigger, task, or workflow variables, click on the Variables tab from the record. OpsWise Automation Center displays a list of variables, if any, as shown in the example below.
  2. image:ops_variables list.gif

  3. From the wizard, select New. OpsWise Automation Center displays the Variable screen:
  4. image:ops_variable.gif

  5. Using the field descriptions provided below as a guide, complete the fields as needed.
  6. Click the Submit button to save the record and return to the menu, or, right-click and select Save to save the record and remain on the current display.
  7. If appropriate, repeat these steps for any additional variables you want to add.

Variable Field Descriptions

The table below describes the fields and buttons on the Variables screen.

Field Name Description
Name Required. Name used within OpsWise Automation Center to identify this variable. Up to 40 alphanumerics; no spaces. It is the user’s responsibility to develop a workable naming scheme for tasks. Important Note -- Do not define OpsWise Automation Center variables with the prefix “ops_”. That prefix is reserved for built-in variables.
Value Optional. The value of the variable, if any.
Description Optional. The description of the variable, if any.
Submit button Submits the new record to the database.
Update button Saves updates to the record.
Delete button Deletes the current record.

Built-In Variables

Built-in variables are maintained by OpsWise Automation Center. They can be used in free text fields and provide information about tasks instances and triggers. They are resolved when the task is launched into a task instance. Some of them are available when a notification is created for an agent, cluster, or connector changes status. Supported built-in variables and their descriptions are provided in the table below. All built-in variables are prefixed with “ops_”.

Name Description
The following built-in variables are associated with task instances:
${ops_agent_hostname} Resolves to the agent hostname.
${ops_agent_id} Resolves to the agent connection name.
${ops_agent_ip} Resolves to the agent IP address.
${ops_agent_name} Resolves to the agent name.
${ops_cmd} Resolves to the task command.
${ops_cmd_parms} Resolves to the task command parameters.
${ops_exit_code} Resolves to the task instance exit code.
${ops_retry_count} Resolves to the current retry count.
${ops_retry_interval} Resolves to the retry interval (seconds).
${ops_retry_maximum} Resolves to the maximum retry count.
${ops_status} Resolves to the current task instance status.
${ops_task_id} Resolves to the sys_id of the task instance.
${ops_task_name} Resolves to the task instance name.
${ops_task_type} Resolves to the task instance type.
${ops_start_time} Resolves to the task starting time.
${ops_end_time} Resolves to the task ending time.
${ops_duration} Resolves to the task running time.
${ops_workflow_id} Resolves to the sys_id of the parent workflow task instance.
${ops_workflow_name} Resolves to the name of the parent workflow task instance.
When a notification is created for the status change of an agent, cluster, or connector:
${ops_agent_hostname} Resolves to the agent hostname.
${ops_agent_id} Resolves to the agent connection name.
${ops_agent_ipaddr} Resolves to the agent IP address.
${ops_agent_name} Resolves to the agent name.
${ops_agent_mode} Resolves to the agent operational mode (ACTIVE|OFFLINE).
${ops_cluster_hostname} Resolves to the cluster hostname.
${ops_cluster_id} Resolves to the cluster connection name.
${ops_cluster_ipaddr} Resolves to the cluster IP address.
${ops_cluster_name} Resolves to the cluster name.
${ops_cluster_mode} Resolves to the cluster operational mode (ACTIVE|AVAILABLE|OFFLINE).
${ops_connector_hostname} Resolves to the connector hostname.
${ops_connector_id} Resolves to the connector connection name.
${ops_connector_ipaddr} Resolves to the connector IP address.
${ops_connector_name} Resolves to the connector name.
${ops_connector_mode} Resolves to the connector operational mode (ACTIVE|AVAILABLE|OFFLINE).
When a task is launched by a trigger, the following built-in trigger variables are passed into the task instance:
${ops_trigger_name} Resolves to the name of the trigger that launched the task instance.
${ops_trigger_file_name} File Monitor trigger only. Resolves to the name of the file that fired the trigger.
${ops_trigger_file_size} File Monitor trigger only. Resolves to the file size of the file that fired the trigger.
${ops_trigger_file_date} File Monitor trigger only. Resolves to the file date of the file that fired the trigger.
${ops_trigger_file_scan} File Monitor trigger only. Resolves to the scan results.
${ops_trigger_file_owner} File Monitor trigger only. Resolves to the file owner of the file that fired the trigger.
${ops_trigger_file_group} File Monitor trigger only. Resolves to the file group of the file that fired the trigger.
${ops_trigger_task_id} Task Monitor trigger only. Resolves to the task instance sys_id that fired the trigger.
${ops_trigger_task_name} Task Monitor trigger only. Resolves to the task instance name that fired the trigger.
${ops_trigger_task_status} Task Monitor trigger only. Resolves to the task instance status that fired the trigger.
${ops_trigger_task_type} Task Monitor trigger only. Resolves to the task instance type that fired the trigger.
${ops_trigger_file_name_nopath} Resolves to the file name without any path information.
${ops_trigger_file_name_simple} Resolves to the base file name.
${ops_trigger_file_name_extension} Resolves to the file extension of a file.
${ops_trigger_file_path} Resolves to the directory where the new file was created, but not the file itself.
The following built-in variables are used to pass data into tasks that were launched by an Application Monitor trigger:
${ops_trigger_appl_name} Resolves to the name of the Application being monitored by the trigger.
${ops_trigger_appl_status} Resolves to the status of the Application being monitored by the trigger.
${ops_trigger_appl_type} Resolves to the type of Application being monitored by the trigger, as defined by the Application Type field.
${ops_trigger_appl_id} Resolves to the sys_id of the application.
The following built-in variables are used in SQL tasks and Stored Procedure tasks to collect SQLException data, if any:
${ops_sql_error_msg} Resolves to any error message generated by the database.
${ops_sql_state} Resolves to a return code that indicates the outcome of the most recently executed SQL statement.

Triggering with Variables

Overview

OpsWise provides two methods that allow you to manually launch all the tasks associated with a trigger while supplying variable values used by the task(s). These options are available for all trigger types. You will use one of these methods if you want to manually launch the task(s) but cannot use the Launch Task button because you need to override one or more variables.

Two methods are available for triggering tasks while supplying variable values:

  • Using the Trigger With Variables popup window. Use this option if you do not want the values you enter for variables to persist. With this option, the values persist only for the time the task(s) is running.
  • Using the Variables tab and Trigger Now button. If you want to preserve information about the variables you are setting (the name and value), use the Variables tab.

The variable values you enter when using either option override all others. The variables in the Launch with Variables window override any specified in the Variables tab, but only for this run of the task(s).

The audit message created when you use either method to Trigger with Variables is the same as Trigger Now.

Procedure

Display the Trigger whose tasks you want to launch, and select one of the methods below.

Using the Trigger with Variables Option

  1. Click the down-arrow or right-click on the title bar to access the Right-Click menu. A menu displays showing the Trigger With Variables option.
  2. image:trigger with variables.gif

  3. Select Trigger With Variables. A pop-up window displays that allows you to enter up to six variables that will be used when executing the task(s) named in the trigger. These can be existing or new variables.
  4. image:trigger now window.gif

  5. When you are finished, click Submit in the pop-up window to launch the tasks named in the trigger. When you click Submit, the variable information in this window is used where referenced in the tasks. After launching the tasks, the system deletes the contents of the window.

Using the Variables Tab

  1. Click the Variables tab.
  2. Use the New button to add the variables you want to modify.
  3. When you are finished, return to the main Trigger page and click Trigger Now to launch the tasks named in the trigger.

Setting Variables in a Workflow

Overview

Within a workflow, you can specify instructions that set a variable to a specific value for use within the workflow. The value you set using this method exists only in memory for the period this workflow is running or until another Set Variable instruction sets it to another value. You can create the Set Variable instruction at the workflow level or task level. If you set it at the workflow level, you have the option of setting it based on the workflow, the tasks (children) in the workflow, or both. If you set it at the task level, you have the option of setting it based on information in the task, in the parent workflow, or both.

The variable need not exist in the database; you can create a new variable using the Set Variable instruction.

When creating a Set Variable instruction, you can trigger the action based on one or more of the following:

  • Status
  • Exit codes
  • Late start
  • Late or early finish

Creating a Set Variable Instruction

  1. Display the workflow for which you want to create Set Variable instructions.
  2. Click on the Actions tab. This tab displays a list of all Actions for this task, including Set Variables, Email Notifications, and Abort Actions.
  3. Click New. The Actions wizard displays.
  4. image:ops_actions wizard.gif

  5. Click Set Variable. The Set Variables screen displays.
  6. image:ops_Set Variable.gif

  7. Using the field descriptions provided below as a guide, complete the fields as needed.
  8. Click the Submit button to save the record and return to the Actions list, or, right-click and select Save to save the record and remain on the current display.
  9. If appropriate, repeat these steps for any additional Set Variable instructions you want to add.

Set Variables Field Descriptions

The table below describes the fields and buttons on the Set Variables screen.

Field Name Description
Action Inheritance Workflow tasks only. Specifies what records these instructions apply to. Options:
  • SELF - These instructions apply only to the workflow and are not inherited by its children tasks.
  • SELF/CHILDREN - These instructions apply to the workflow and its contained tasks (children).
  • CHILDREN - These instructions apply only to the tasks within the workflow (children).
Status The status of the task instance that will satisfy the trigger. You can specify as many statuses as needed. Options:
  • Defined - All task types. The new task instance has been created (the task has been launched). Not yet implemented.
  • Waiting - All task types. The task has been loaded by a workflow and is waiting to run.
  • Held - All task types. The task has been put on hold by a user.
  • Resource Wait - The task with a virtual resource defined is waiting for enough units to become available on the virtual resource.
  • Undeliverable - Agent-based tasks. The agent is unavailable.
  • Queued - Agent-based tasks only. The task has been queued on a resource.
  • Submitted - z/OS only. The task has been submitted to the z/OS Job Entry subsystem and scheduled by the z/OS Job Scheduler.
  • Action Required - Manual tasks only. When a manual task launches, it goes into Action Required status, meaning a user must perform some manual activity. For details, see Manual task.
  • Started - Agent-based and Manual tasks only. The task has started. For agent-based tasks, this means the agent has received the task.
  • Running - All task types. The task is running. For agent-based tasks, the agent has started running the program.
  • Running Problems - Workflows only. One or more tasks within the workflow has one of the following statuses:
    • Held
    • Undeliverable
    • Running Problems (for sub-workflows)
    • Cancel Pending
    • In Doubt
    • Start Failure
    • Cancelled
  • In Doubt - Agent-based tasks only. The agent is "in doubt" about the current status of the task instance. This may occur if an agent or agent connection goes down. In this case, the agent restarts and reviews its data about tasks in progress. If the agent finds a task still running, it resumes normal monitoring. If the agent cannot find the task, this usually indicates that the task completed, but the agent considers the task status to be "in doubt."
  • Start Failure - All task types. The task was unable to start.
  • Cancelled - All task types. The task was cancelled by a user.
  • Failed - All task types. The task ran to a failure status.
  • Skipped - All task types. The task was skipped by a user.
  • Finished - All task types. The task was forced by the user to finish. The user may do this in cases where the task had "Cancelled" or "Failed" status, and the user needed to release other task instances depending on the successful completion of this task instance in a workflow. For more information, see Force Finishing a Task.
  • Success - All task types. The task has completed successfully
Exit Codes Specifies one or more exit codes that will trigger the Set Variable. If you specify an exit code, you must also specify at least one status. Use commas to separate multiple exit codes; use a hyphen to specify a range. Example: 1, 5, 22-30.
On Late Start Execute the Set Variable if the task started late, based on the Late Start Time specified in the task.
On Late Finish Execute the Set Variable if the task finishes late, based on the Late Finish time specified in the task.
On Early Finish Execute the Set Variable if the task finishes early, based on the Early Finish Time specified in the task.
Variable Scope Applies to variables associated with a task in a workflow. Options:
  • SELF - The variable is only set within the scope of the task that executes the Set Variable action.
  • PARENT - The variable is set within the scope of the (immediate) parent workflow. After it is set, any task within the parent workflow can access that variable.
  • TOP_LEVEL_PARENT - The variable is set within the scope of the top level parent. Example: Workflow A contains workflow B and workflow B contains workflow C. If a Set Variable action is executed by a task within workflow C with Variable Scope set to TOP_LEVEL_PARENT, then the variable will be set in workflow A's scope. This means that after it is set, tasks in workflow A, workflow B and workflow C can access that variable.
Name Required. Name of variable being set. Up to 40 alphanumerics.
Value Optional. The value being written to the variable.
Description Optional. The description of the variable, if any.
Submit button Submits the new record to the database.
Update button Saves updates to the record.
Delete button Deletes the current record.

Listing and Setting Variables From the Command Line

You can use the ops-variable-set command to set variables. See Command_Line_Interface_Reference#Table_of_Commands for instructions.

Functions

OpsWise Automation Center supports a number of functions that can be specified in free text fields. They are resolved when the task is launched into a task instance. They are entered using the following formats:

${_function}
${_function(arg1, … , argn)}

The following table lists and describes each supported function.

Name Description
${_currentTimeMillis} Resolves to the current time in milliseconds.
${_date([format, day_offset, hour_offset, minute_offset])} Resolves to the current date and time. All parameters are optional.

Parameters:

  • format - The date format. The default format is yyyy-MM-dd HH:mm:ss Z. For details on the format parameter, go to:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
  • day_offset - The day offset.
  • hour_offset - The hour offset.
  • minute_offset - The minute offset.

Examples:

  • ${_date} --> 2008-07-14 12:43:06 -0400
  • ${_date()} --> 2008-07-14 12:43:06 -0400
  • ${_date("yyyy-MM-dd",5)} --> 2008-07-19
  • ${_date("yyyy-MM-dd HH:mm:ss",-2,-1)} --> 2008-07-12 11:43:06
  • ${_date("",0,0,10)} --> 2008-07-14 12:53:06 -0400
${_dateadv([format, year_offset, month_offset, day_offset, hour_offset, minute_offset])} Resolves to the current date and time. All parameters are optional.

Parameters:

  • format - The date format. The default format is yyyy-MM-dd HH:mm:ss Z. For details on the format parameter, go to:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
  • year_offset - The year offset.
  • month_offset - The month offset.
  • day_offset - The day offset.
  • hour_offset - The hour offset.
  • minute_offset - The minute offset.

Examples:

  • ${_dateadv} --> 2008-07-29 09:31:42 -0700
  • ${_dateadv("yyyy-MMM",-1)} --> 2007-Jul
  • ${_dateadv("yyyy-MMM",0,-1)} --> 2008-Jun
${_guid} Resolves to a 32 byte GUID (Globally Unique ID).
${_hostname} Resolves to the hostname of the machine running the Core, if available.
${_indexOf(value, str)} Returns the index within the string value of the first occurrence of the specified substring, str.

Parameters:

  • value - Any string.
  • str - The substring to search for.

If the str argument occurs as a substring within the value, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.

${_ipaddress} Resolves to the IP address of the machine running the Core.
${_lastIndexOf(value, str)} Returns the index within the string value of the rightmost occurrence of the specified substring, str.

Parameters:

  • value - Any string.
  • str - The substring to search for.

If the str argument occurs one or more times as a substring within the value, then the index of the first character of the last such substring is returned. If it does not occur as a substring, -1 is returned.

${_random([max, min])} Generates a random number between max (inclusive) and min (inclusive).

Parameters:

  • max - The upper bound (inclusive) on the random number (default 9).
  • min - The lower bound (inclusive) on the random number (default 0).
${_replaceAll(value, regex, replacement)} Replaces each substring of value that matches the specified regular expression, regex, with the specified replacement, replacement.

Parameters:

  • value - The input string.
  • regex - The regular expression.
  • replacement - The replacement string.
${_resolve(variable_name, default_value)} Resolves the variable specified by name variable_name and substitutes the default value default_value if the variable cannot be resolved.

Parameters:

  • variable_name - The variable name.
  • default_value - The default value to use if the variable cannot be resolved.
${_resultsAllFromTask(name[, separator])} Returns all SQL results from a SQL or Stored Procedure task. Columns are separated by the specified separator and rows are separated by a new line.

Parameters:

  • name - When you use this function within the SQL or Stored Procedure task itself, specify an empty string. When using the function in a task other than the SQL or Stored Procedure task, specify the name of the SQL or Stored Procedure task, which must be a sibling contained within the same workflow.
  • separator - The column separator (default = comma).
${_resultsColumn(name, colname[, rownum, default_value])} Returns the string value of a row/column from a previously executed SQL task.

Parameters:

  • name - SQL task name in workflow containing results (use empty string for name if used outside of a workflow within a SQL task notification, etc).
  • colname - Name of column to retrieve.
  • rownum - Numeric row number in result set to retrieve (default 1).
  • default_value - The default value to return if result not found.
${_resultsColumnByNo(name, colnum[, rownum, default_value])} Returns the string value of a row/column from a previously executed SQL task.

Parameters:

  • name - SQL task name in workflow containing results (use empty string for name if used outside of a workflow within a SQL task notification, etc).
  • colnum - Number of column to retrieve. First column in result is 1, 2nd is 2, etc
  • rownum - Numeric row number in result set to retrieve (default 1).
  • default_value - The default value to return if result not found.
${_resultsColumnsCSV(name[, rownum])} Returns the string values of columns in a specific row in CSV(comma separated values) format.

Parameters:

  • name - SQL task name in workflow containing results (use empty string for name if used outside of a workflow within a SQL task notification, etc).
  • rownum - Numeric row number in result set to retrieve (default 1).
${_scope} This displays all the defined and built-in variables associated with the task instance.

Example:

  • ${_scope} --> {ops_workflow_id=, ops_task_type=Unix, ops_status=DEFINED, ops_retry_interval=60, ops_exit_code=0, ops_retry_maximum=0, ops_cmd_parms=, ops_cmd=ls -la; exit ${_random('9')};, ops_retry_count=0, ops_agent_id=67e4994143d2617201cdf4ba9df9ab0a, ops_task_id=84880af243d26172019aa1d25988a8f9, ops_task_name=Opswise - Linux Ls}
${_siblingid(sibling_name)} Resolves to the sys_id of the first task instance found within the same workflow specified by the sibling name.

Parameters:

  • sibling_name - the sibling name.

Example:

  • ${_siblingid("Sleep 60")} --> 5dbaaab943d26172015e10ab3e894e10
${_substring(value, beginIndex[, endIndex])} Returns a new string that is a substring of value. The substring begins at the specified beginIndex and extends to the character at index endIndex -1.

Parameters:

  • value - the string to make a substring from.
  • beginIndex - the beginning index, inclusive.
  • endIndex - the ending index, exclusive.

Examples:

  • ${_substring("hamburger", 4, 8)} resolves to "urge".
  • ${_substring("smiles", 1, 5)} resolves to "mile".
${_toLowerCase(value)} Converts all of the characters in the value to lower case using the rules of the default locale.

Parameters:

  • value - the string to convert to lower case.
${_toUpperCase(value)} Converts all of the characters in the value to upper case using the rules of the default locale.

Parameters:

  • value - the string to convert to upper case.
${_trim(value)} Returns a copy of value, with leading and trailing whitespace omitted.

Parameters:

  • value - the string to trim.
Personal tools