Sample Collection Guide > Notification with Variable Message Text

Notification with Variable Message Text

Objective: The notificationAn Automation Engine object type used to send messages to users and user groups. [Formerly called "CallOperator."] given by the notification should contain a message text depending on the taskAn executable object that is running. Tasks are also referred to as activities. activating it.

Objects used: Notification

Script elements used: ACTIVATE_UC_OBJECT, :ADD_ATT, GET_ATT, :PUT_ATT, :PUT_ATT_APPEND, :PUT_READ_BUFFER, :READ, STR_FIND, SYS_ACT_PARENT_NAME, SYS_ACT_PARENT_NR and SYS_ACT_PARENT_TYPE


Example

Notifications are used for sending messages via the monitor view of the notification, email or SNMP. Creating a notification whose message text contains information about the task triggering the notification is very useful. This notification can then be used for various purposes because the message content is automatically adapted.

Task

Enter the following scriptA particular Automation Engine object type. lines in the Post-Process tab of any task to start the notification.

!Storing the agent name in the Read buffer
:
SET &att_host = GET_ATT(HOST)
:
PUT_READ_BUFFER host# = '&att_host'

!Activating the notification

:
SET &ret = ACTIVATE_UC_OBJECT('CALLOP')

Attributes can only be retrieved from the Process tab of the very same task. Therefore, this example stores the name of the 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 in the input buffer (Read buffer). The notification reads the value from there and uses it for the message to be sent.

Notification

Now create a new notification. Specify its priority and type (request, message, alert) and one or several users who should be notified.

The script structure is shown below. First, the agent name is read from the input buffer. Further information about the task is then retrieved (name, 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 . and object typeAn individual object is provided for the individual activities: There are User, UserGroup, Notification, Cockpit, CodeTable, Documentation, Event, Agent, FileTransfer, Group, Include, Job, Workflow, Calendar, Login, Client, RemoteTaskManager, Schedule, Script, Server, Sync, Variable and TimeZone objects). It is helpful to keep common naming conventions for objects because the script verifies whether the name of the task contains a particular string (ADMIN).  If so, the defined 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. and the users of the user groupA group of users who have a common profile of rights. A particular object type in the Automation Engine. User groups are an organizing construct to help you better manage users because you can grant user groups access rights the same way that you grant various access rights to a single user. All users in the user group are automatically given those access rights. This makes managing users not only more efficient but also more secure because working with user groups gives you a better overview of what rights are assigned. "ADMIN" are notified.

The message text to be output is specified with the script statements :PUT_ATT and :PUT_ATT_APPEND. A line break can be created with the functionPre-defined run book template in the Automation Engine. One single step only, e.g. Start Windows Service, Copy file,… UC_CRLF.

!Reading the agent name of the task
:
READ &host,,


:
SET &name = SYS_ACT_PARENT_NAME(ACT)
:
SET &runnr = SYS_ACT_PARENT_NR(ACT)
:
SET &typ = SYS_ACT_PARENT_TYPE(ACT)


!If 'ADMIN' is part of the task name ...

:
SET &string = STR_FIND (&name,'ADMIN')


!...all the users of the user group "ADMIN" are notified.

:
IF &string <> '0'
:  
ADD_ATT RECIPIENT, 'ADMIN'
:
ENDIF 



!Creating the message text

:
PUT_ATT CALL_TEXT = 'The following task was not successfully completed! Please check!'
:
PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
:
PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
:
PUT_ATT_APPEND CALL_TEXT = 'Name of the task: &name'
:
PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
:
PUT_ATT_APPEND CALL_TEXT = 'RunID of the task: &runnr'
:
PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
:
PUT_ATT_APPEND CALL_TEXT = 'Type of the task: &typ'
:
PUT_ATT_APPEND CALL_TEXT = UC_CRLF()
:
PUT_ATT_APPEND CALL_TEXT = 'Agent: &host'

The following illustration shows a notification called by the task "ADMIN.DB.MAINTENANCE" which notifies the user Smith. As the relevant task contains the string "ADMIN", the members of the user group ADMIN (Brown and Green) are also notified.

 

See also:

Notification - Execution

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH