Oracle Solaris Cluster Generic Data Service (GDS) Guide

Exit Print View

Updated: July 2014, E48652-01
 
 

ORCL.gds_proxy Demo Scripts

The following demo scripts have been provided for a resource of type ORCL.gds_proxy:

  • /opt/ORCLscgds/demo/demo_proxy_prenet_start

  • /opt/ORCLscgds/demo/demo_proxy_postnet_stop

  • /opt/ORCLscgds/demo/demo_validate


Note -  The RGM will execute the demo_proxy_prenet_start script before any logical host network interfaces are configured up and execute demo_proxy_postnet_stop after any logical host network interface are configured down. Nevertheless, it is still possible to set the interpose_logical_hostname property, which will return the exported SC_LHOSTNAME variable value as the interposed host name even though that host name may not be configured up.

Demo_proxy_prenet_start Script

The demo_proxy_prenet_start script is executed as a daemon and checks the state of the system log. Additionally, it prints out debug messages to the system log to show Begin and End messages and the hostname or interposed host name.

01 #
02 # Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
03 #
04 #ident  "@(#)demo_proxy_prenet_start.ksh 1.2     14/02/10"
05 #
06 
07 . /opt/ORCLscgds/lib/gds_functions
08 get_opts "$@"
09 
10 debug_message "Script: demo_prenet_start_proxy - Begin"
11 ${DEBUG}
12 trap 'debug_message "Script: demo_prenet_start_proxy - End (${rc})"' EXIT
13 trap 'errtrap "Script: demo_prenet_start_proxy" ${LINENO}; rc=1; exit 1' ERR
14 
15 typeset -i rc=0
16 typeset -r scha_control=/usr/cluster/bin/scha_control
17 typeset -r set_status=/usr/cluster/bin/scha_resource_setstatus
18 typeset -r rs_get=/usr/cluster/bin/scha_resource_get
19 typeset status
20 typeset interval
21 
22 debug_message "Script: demo_prenet_start_proxy - hostname is $(/usr/bin/hostname)"
23 
24 if [[ -f ${DEBUG_LOGFILE} ]]; then
25     /usr/bin/printf "--- $(date) - rc=${rc} \n" >> ${DEBUG_LOGFILE}
26     printf "Script: demo_prenet_start_proxy - hostname is $(/usr/bin/hostname) \n" >>
            ${DEBUG_LOGFILE}
27 fi
28 
29 interval=$(/usr/cluster/bin/scha_resource_get -O extension -R ${RESOURCE} -G ${RESOURCEGROUP}
     proxy_interval)
30 interval=$(echo ${interval} | /usr/xpg4/bin/awk '{print $2}')
31 
32 while :
33 do
34     status=$(/usr/bin/svcs -Ho state system-log)
35 
36     case ${status} in
37         disabled)   ${scha_control} -O CHANGE_STATE_OFFLINE -R ${RESOURCE} -G ${RESOURCEGROUP}
38                ${set_status} -R ${RESOURCE} -G ${RESOURCEGROUP} -s OFFLINE -m "System-log is
                       offline"
39                ;;
40       online   ${scha_control} -O CHANGE_STATE_ONLINE -R ${RESOURCE} -G ${RESOURCEGROUP}
41                ${set_status} -R ${RESOURCE} -G ${RESOURCEGROUP} -s OK -m "System-log is online"
42                ;;
43       *)       ${scha_control} -O CHANGE_STATE_OFFLINE -R ${RESOURCE} -G ${RESOURCEGROUP}
44                ${set_status} -R ${RESOURCE} -G ${RESOURCEGROUP} -s DEGRADED -m "System-log is
                       degraded"
45                ;;
46     esac
47 
48     sleep ${interval}
49 done
50 
51 exit ${rc}
  • Lines 07-09 – The function get_opts will process all the arguments that GDSv2 passes to demo_proxy_prenet_start. Those arguments are processed as upper case KSH variables. Property values are as defined (for example, RESOURCE=mysrs).

  • Lines 10-11 – The function debug_message is called to output a Begin debug message to the system log. Additionally, the ${DEBUG} variable is set. See Debug_level Property for more information.

  • Lines 12-13 – KSH trap built-in command is used to output an End debug message to the system log whenever the script exists. Additionally, if a command returns a non-zero exit status the KSH fake signal ERR is trapped and the function errtrap is called. Function errtrap will output an error message to the system log that contains the script name, line number of the command that returned a non-zero exist status and the exit status that was returned by that command.

  • Line 22 – Output a debug message to the system log that contains the script name and value from the hostname command. If environment variables for SC_LHOSTNAME exist, then the value for SC_LHOSTNAME is output.

  • Lines 24-27 – If variable ${DEBUG_LOGFILE} is set, then output some debug_messages to that file. When function debug_messages was first called on line 10, ${DEBUG_LOGFILE} was set to /var/cluster/logs/DS/RT/message_log/.RS. RT equals ORCL.gds_proxy and RS equals your resource name.

  • Lines 29-30 – The Oracle Solaris Cluster program scha_resource_get retrieves the proxy_interval extension property, which is saved into the variable interval.

  • Lines 32-49 – Perform a while loop sleeping for the duration of ${interval} on every iteration. During each iteration, check the state of the system log using the svcs(1) command and reflect that state as an Oracle Solaris Cluster resource state and status.

Demo_proxy_postnet_stop Script

The demo_proxy_postnet_stop script is executed when the daemon that was started by demo_proxy_prenet_start is being stopped. Additionally, it prints out debug messages to the system log to show Begin and End messages and the hostname or interposed host name.

01 #
02 # Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
03 #
04 #ident  "@(#)demo_proxy_postnet_stop.ksh 1.3     14/02/10"
05 #
06 
07 . /opt/ORCLscgds/lib/gds_functions
08 get_opts "$@"
09
10 debug_message "Script: demo_postnet_stop_proxy - Begin"
11 ${DEBUG}
12 trap 'debug_message "Script: demo_postnet_stop_proxy - End (${rc})"' EXIT
13 trap 'errtrap "Script: demo_proxy_postnet_stop" ${LINENO}; rc=1; exit 1' ERR
14 
15 typeset -i rc=0
16 typeset -r set_status=/usr/cluster/bin/scha_resource_setstatus
17 
18 debug_message "Script: demo_postnet_stop_proxy - hostname is $(/usr/bin/hostname)"
19 
20 ${set_status} -R ${RESOURCE} -G ${RESOURCEGROUP} -s OFFLINE
21 
22 if [[ -f ${DEBUG_LOGFILE} ]]; then
23     /usr/bin/printf "--- $(date) - rc=${rc} \n" >> ${DEBUG_LOGFILE}
24     /usr/bin/printf "Script: demo_postnet_stop_proxy - hostname is $(/usr/bin/hostname) \n" >>
            ${DEBUG_LOGFILE}
25 fi
26 
27 exit ${rc}
  • Lines 07-27 – All these lines are explained with the demo_proxy_prenet_start script.