add event trigger

Description

Adds a trigger that is executed by the RMS when a specific event occurs in the replication domain. A trigger identifies a process or script that is executed by the RMS.

Syntax

add {status | latency | size} trigger 
       [{connection | logical connection | route | queue | rep agent |
         partition} [component_name]]
       [with primary primary_connection]
       for server_name
       {status changes to state |
         size {exceeds | falls below} size_threshold |
         latency {exceeds | falls below} latency_threshold}
       [wait wait_interval]
       [continuous continuous_flag]
       execute command

Parameters

status, latency, size

Type of trigger.

connection, logical connection, route, queue, rep agent, partition

Specifies the type of component to be monitored. Components are monitored objects within a server. Replication Server components are connections, logical connections, routes, queues, and partitions; Adaptive Server Enterprise components are RepAgent threads.

component_name

Specifies the name of the component to be monitored.

with primary primary_connection

Identifies the primary connection for a connection latency trigger. The trigger executes the script if the latency threshold between the primary connection and the replicate connection is not satisfied.

for server_name

Specifies the name of the server to be monitored. If the command is to add a trigger for a component, then the server is the owner of the component.

size exceeds, falls below size_threshold

Indicates whether the trigger should execute when the size exceeds the threshold or when it falls below the threshold.

latency exceeds, falls below latency_threshold

Indicates whether the trigger should execute when the latency exceeds the threshold or when it falls below the threshold.

status changes to state

Specifies the state of the server or component to monitor. If state changes to the specified value, the trigger executes. The state value is dependent on the object type. See Appendix C, “RMS Server and Component States” for information about the state codes.

wait wait_interval

Specifies the number of seconds to wait before triggering the event. This allows the object time to recover. If you do not include the wait option, the event triggers immediately.

continuous continuous_flag

A Boolean flag that, if set to true, causes the RMS to execute the trigger’s script at every subsequent monitoring interval until the state changes. If you do not set this flag, the RMS executes the trigger script only once.

execute command

Specifies the command to be executed when the event is triggered. The command is operating-system-specific.

Examples

Example 1

Adds a trigger that executes the script email.sh when the status of the server named INVENTORY_RS is changed to “DOWN”:

add status trigger for INVENTORY_RS 
status changes to DOWN 
execute /sybase/RMS/scripts/email.sh

Example 2

Adds a trigger that executes the script email.sh after 120 seconds. Since the status of the connection “inventory_pds.pdb1” of server INVENTORY_RS is changed to “SUSPENDED”, it will execute script at every subsequent monitoring interval until the state changes:

add status trigger connection inventory_pds.pdb1 for
    INVENTORY_RS
status changes to Suspended
wait 120
continuous true
execute /sybase/RMS/scripts/email.sh

Example 3

Adds a trigger to the Replication Server INVENTORY_RS partition “p1” that executes the script email.sh when the partition usage exceeds 80 percent. The script is executed at every subsequent monitoring interval as long as the partition usage exceeds 80 percent:

add size trigger partition p1 for INVENTORY_RS
    size exceeds 80
    continuous true
    execute /sybase/RMS/scripts/email.sh

Example 4

Adds a trigger to the Replication Server INVENTORY_RS that executes the script email.sh when the sum of all partition usage exceeds 75 percent:

add size trigger partition for INVENTORY_RS
    size exceeds 75
    execute /sybase/RMS/scripts/email.sh

Example 5

Adds a trigger to the queue “inventory_pds.vendor(Inbound)” of Replication Server INVENTORY_RS that executes the script email.sh when the queue size falls below 100 megabytes. The script is executed at every subsequent monitoring interval as long as the queue size is less than 100 MB:

add size trigger queue inventory_pds.vendor(Inbound)
    for INVENTORY_RS
    size falls below 100
    continuous true
    execute /sybase/RMS/scripts/email.sh

Example 6

Adds a trigger to the replicate connection “inventory_rds.vendor” of replicate Replication Server INVENTORY_RS that will execute the script email.sh when the latency from the primary connection “inventory_pds.vendor” exceeds 5 minutes (300 seconds):

add latency trigger connection inventory_rds.vendor
    with primary inventory_pds.vendor
    for INVENTORY_RS
    latency exceeds 300
    execute /sybase/RMS/scripts/email.sh

Usage

See also

drop event trigger, get triggers