Objective: The creation of an input mask in order to select one or several agents on which a jobAn Automation Engine object type for a process that runs on a target system. should run. The available agents are dynamically retrieved from the AE databaseA database is an organized collection of data including relevant data structures. at runtimeThe duration of a task's execution. It refers to the period between a task's start and end. It does not include its activation period (see also: activation and start).. In the input dialog, you must also specify a Queue objectAutomation Engine controlled activities and processes are structured in the form of objects. See also: Task and an OS command for the jobs. As a result, you can easily define the OS command that should be processed on particular computers.
Objects used: PromptSet, Script, Job (Windows), Variable (SQL internal)
Script elements used: :SET, :PSET, :WHILE :ENDWHILE, :IF :ELSE :ENDIF, LENGTH, SYS_HOST_ALIVE, ACTIVATE_UC_OBJECT, :PRINT, :DATA, :PUT_ATT
Requirements: Creating and using internal SQL variables (the privilege and setting SQLVAR_INTERNAL = Y in the variableIt stores or retrieves values dynamically at runtime. An individual Automation Engine object type. UC_SYSTEM_SETTINGS is required).
This example describes the use of PromptSet objects, dynamic Variable objects, predefined variables and script arrays.
You can enter userIn the Automation Engine, a user is an instance of a User object, and generally the user is a specific person who works with Automic products. The User object is assigned a user ID and then a set of access rights to various parts of the Automation Engine system and product suite. These access rights come in the form of Automation Engine authorizations and privileges, Decision user roles and EventBase rights and ARA web application object rights. You can manage all these centrally in the ECC user management functions. See also, Unified user management.-defined values by using a PromptSet object which is called via a Script object. The available Queue objects and Windows agents are directly retrieved from the AE database by using SQL-internal Variable objects. Submitting the PromptSet dialog has the effect that a job starts on each selected agentA program that enables the de-centralized execution of processes (such as deployments) on target systems (computers or business solutions) or a service that provides connectivity to a target system (such as for databases or middleware). An agent is also an object type in the Automation Engine. [Formerly called "Executor."] See also: host.
PromptSet objects are user-defined input masks that can be called by using executable objects. You can use PromptSet object elements in order to enter or select values that are retrieved from a Variable object (= reference variable).
First, create the reference Variable objects: Create the following two SQLI-type Variable objects: VARA.SQLI.AGENT and VARA.SQLI.QUEUE.
The advantage of SQL-internal Variable objects is that their values are dynamically retrieved from the AE database at runtime. This means that the PromptSet elementFields/control elements that are used to query User values. They are the content of a PromptSet input mask. always shows the current values. For example, if a new agent is added, it is automatically displayed the next time the input mask is called. You can also use static variablesA Variable object with the setting "Source" - "Static": Variable values are entered by a user or with a script and remain stored in the object. but their contents must be maintained manually.
One of the two variables reads all the current clientA closed environment within an Automation Engine system where you can create and run objects. A client name consists of a 4-digit number that must be indicated when a user logs on to the Automation Engine system. Users and their rights are also defined in clients. A particular Automation Engine object type.'s Windows agents and the other one all Queue objects from the AE database. Insert the following SQL statements in the Variable objects if you use an MS SQL Server database:
If you use a different database (Oracle or DB2), adjust these SQL statements accordingly. Use the "Preview" in order to verify that the SQL statements are correct. They are correct if the values are displayed without an error.
&$CLIENT# is a predefined variable that is replaced by the current AE client's number at runtime. At least VAR_SECURITY_LEVEL = 1 (or 2, or 3) must be set in the variable UC_SYSTEM_SETTINGS in order to resolve this variable.
Create the new PromptSet object PRPT.AGENT.
Open this object and switch to its Designer tab. You can now use the drag & drop functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… in order to drag the required PromptSet elements from the right area to the center.
The following PromptSet elements are required for this example:
Elements | Description | Properties |
---|---|---|
Text field | For the job name (a fixed name in this example) |
|
Check listShows entities in a grid view | For the selection of one or several Windows agents. |
|
Combo box | For the selection of a Queue object. |
|
Text field | Input of an OS command. |
|
The Script object is used to call the PromptSet object, read its values and activate the jobs.
Create the Script object SCRI.START.JOBS.
Open this object and switch to the Variables & Prompts tab. In "PromptSets", select the created PromptSet object PRPT.AGENT. You can now overwrite the PromptSet elements' default values if necessary.
Switch to the Process tab and insert the following lines:
:SET &LEN# = LENGTH(&AGENT[])
:WHILE &LEN# > 0
: PSET &HOST# = &AGENT[&LEN#]
: IF SYS_HOST_ALIVE(&HOST#) = "Y"
: SET &RET# = ACTIVATE_UC_OBJECT(&JOB#,,,,,PASS_VALUES,&queue#,"&JOB#_&HOST#")
: P "Start Job &JOB# on agent &HOST# with RunIDShort for "run number". It is a number that provides unique information about a task's execution. The RunID can include 7 to 10 digits. It is assigned by the Automation Engine component . &RET#"
: ELSE
: P "Agent &HOST# is not active."
: ENDIF
: SET &LEN# = &LEN# - 1
:ENDWHILE
This scriptA particular Automation Engine object type. is used to retrieve the number of agents that have been selected in the PromptSet object. Subsequently, the agent names are read from the script array. If the agent is active, the Windows job starts.
The job executions start with an alias to enable them to be distinguished in the statisticsThis is a list of a task's previous runs.. This alias is composed of the job and agent names. For example: JOBS.WIN.PROMPT_WIN01.
Create the Windows Job object JOBS.WIN.PROMPT.
Open the job and enter a Login object that can be used with all Windows agents in the Attributes tab. Switch to the Pre-Process tab and insert the following line:
: PUT_ATT HOST = &HOST#
The effect is that the agent that was passed on by the Script object using an object variable is dynamically set at runtime.
The following lines are required in the Process tab in order to execute the user-defined Windows command:
:DATA &jcl#
:DATA "@set retcode=%errorlevel%"
:DATA "@if NOT %ERRORLEVEL% == 0 goto :retcode"
Start the Script object in order to call the input dialog. Select the required agent and a Queue object. In the field "JCL", enter the Windows command that should be processed on the computers of the selected agents.
In this example, the job JOBS.WIN.PROMPT starts in the queue CLIENT_QUEUE on the agents WIN01, WIN02 and WIN03. The file list C:\ is queried on the computers of these agents.
As a result, you can quickly and easily execute user-defined commands on several computers.
s
Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support |
Copyright © 2016 Automic Software GmbH |