During OpenSwitch configuration, you specify one action for each failure type parameter. This section describes each available action.
When a user-created script executes, OpenSwitch suspends all pools and puts all threads to sleep. OpenSwitch resumes the pools and wakes all threads when the specified action completes execution.
Because only one of the companions may execute a script
that notifies the administrator or restarts the server, the scripts
for both OpenSwitch companions should perform the same action.
For details about each action’s specific use with each failure type, refer to “CMON_FAIL_ACTION”, “CMP_FAIL_ACTION”, “NET_FAIL_ACTION”, and “SVR_FAIL_ACTION”.
Invokes the default OpenSwitch behavior for the failure type. The activity that occurs depends on the failure type. See “Failure types”.
When you specify CUSTOM for a problem parameter, the path of the script is retrieved from the CUSTOM_SCRIPT parameter, and the custom script is executed with the appropriate server name and reason code that OpenSwitch passed as arguments. The custom script should process the server name and reason code to determine the nature of the failure and the appropriate solution.
When the failure type is SRV_FAIL_ACTION or CMON_FAIL_ACTION, the
first argument passed to the user action script is the server name.
When the failure type is CMP_FAIL_ACTION, the first argument passed to the script is the name of the companion OpenSwitch.
When the failure type is NET_FAIL_ACTION, the first argument passed to the script is “NET.”
The second argument passed to the script is always the reason code.
Based on the specified reason code provided by the user in the custom script, the script can perform the appropriate actions—restart an Adaptive Server that has stopped running, perform operating system-level checks, or notify the system administrator via an e-mail message that a problem has occurred.
When the custom script completes execution, the exit code of the script is returned in the return code argument.
When you set MUTUAL_AWARE to
1, the scripts for both OpenSwitch companions must contain the same
information. This is because during a server failover, if you have
set SVR_FAIL_ACTION to MANUAL
or CUSTOM, only one of the companions executes the script that notifies
the administrator or restarts the server.
See “CMP_FAIL_ACTION”, “SVR_FAIL_ACTION”, and “NET_FAIL_ACTION” for details.
The following code is a sample of a custom script.
# Sample custom script for OpenSwitch #!/bin/sh server=$1 reason=$2 case "$reason" in "1000") mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The OpenSwitch CMON thread failed to start because $server is not running. EOF r=0 ;; "1001") mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The OpenSwitch CMON thread failed to start because the maximum connection on $server has been exceeded. EOF r=0 ;; "1004") # Remotely restart the ASE server. rsh bluebird /sybase/ASE-15_0/scripts/RUN_$server & if ( $? != 0) then mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The Adaptive Server $server went down, and the effort to restart it failed. EOF r=1 else mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The Adaptive Server $server went down and was successfully restarted. EOF r=0 fi sleep 10 ;; "1005") mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The Mutually-aware OpenSwitch detected a complete network failure. Please check the network of the OpenSwitch server hosts. EOF r=5 #Example of nondefault return code. ;; "1006") mailx -s "OpenSwitch failure Alert!" osw_dba << EOF The Mutually-aware OpenSwitch has encountered a network failure with its companion OpenSwitch host. Please check the network between the two mutually-aware OpenSwitch servers hosts. EOF r=0 ;; *) mailx -s "OpenSwitch failure Alert!" osw_dba << EOF A problem was encountered and an invalid reason code $reason was received. Please check the OpenSwitch error log for any failure messages. EOF r=99 ;; esac exit $r
This example invokes a custom user script, specified by the CUSTOM_SCRIPT parameter in the OpenSwitch configuration file, that performs different tasks depending on the reason code passed into the script.
When you specify MANUAL, the path of the manual script is retrieved from the MANUAL_SCRIPT parameter in the configuration file and executed. While the script is executed, OpenSwitch locks all pools and prevents new clients from logging in to the server, while existing client are unaffected and continue normal operation. Similar to a custom script, you must pass in arguments to help the script determine the action to take and the object on which to take that action.
When the failure type is SRV_FAIL_ACTION or CMON_FAIL_ACTION, the first argument passed to the user action script is the server name.
When the failure type is CMP_FAIL_ACTION, the first argument passed to the script is the name of the companion OpenSwitch.
When the failure type is NET_FAIL_ACTION, the first argument passed to the script is “NET.”
The second argument passed to the script is always the reason code.
OpenSwitch is suspended until the system administrator executes rp_go. After the script finishes execution, the exit code of the script is returned in the return code argument.
If an administrator misses the message issued from MANUAL, issue rp_pool_help to see if the status is SUSPENDED. If the status is SUSPENDED, fix the problem and issue rp_go.
When MUTUAL_AWARE is set to 1, the scripts
for both OpenSwitch companions must contain the same information.
This is because during a server failover, if you have set SVR_FAIL_ACTION to
MANUAL or CUSTOM, only one of the companions executes the script
that notifies the administrator or restarts the server.
Useful to perform a manual intervention and suspend the entire OpenSwitch if a custom script fails.
When you specify CUSTOM_MANUAL, the custom script is executed first. The manual script is executed only if the custom script fails with an exit code nonzero.