Top
PRIMECLUSTER Global Link Services Configuration and AdministrationGuide 4.3Redundant Line Control Function

3.12.2 Setting user command execution function

In NIC switching mode and GS linkage mode, a command pre-defined by a user can be executed at specific timing. For information on execution timing, see "2.8.2 User command execution function". In NIC switching mode, this function can be used to flush an ARP table, change the interface status, and change the MTU length, etc. The following settings must be made to execute a user command. See the sample files for information on creating a script file appropriate for a user's environment.

Sample file for NIC switching mode
Sample file for GS linkage mode
Sample file for Self-checking function
[Setup files]

The storage destination and file name of a setup file varies depending on the type and name of a virtual interface.

Setup file for NIC switching mode
  • /etc/opt/FJSVhanet/script/interface/shaX (When activating or deactivating an IP address)

  • /etc/opt/FJSVhanet/script/failover/shaX (When detected an error in a transfer route)

  • /etc/opt/FJSVhanet/script/patrol/shaX (When detected a standby patrol error or recovery)

* shaX is the created virtual interface name for NIC switching mode.


Setup file for GS linkage mode
  • /etc/opt/FJSVhanet/script/node_event


Setup file for Self-checking function
  • /etc/opt/FJSVhanet/script/system/monitor


Note

  • Do not call the operational command for redundancy line control function in the script file.

  • The commands executed in the script file does not output message to the standard output. When checking for the contents of the output message, set the redirect path /dev/console/ and output the message to the console display. For detail, refer to the sample script file.

  • In a clustered system, the script for NIC switching mode of activating or deactivating IP addresses is executed only by active node. It will not run for standby node.

  • Create a script file for each virtual interface. If both of IPv4 address and IPv6 address is set to a single virtual interface (or dual stack configuration), define the script file for each address family.

  • You cannot use the script for the self-checking function to automatically reboot the control daemon of GLS. Reboot the system to recover the control daemon.

  • In the environment where SElinux is enabled when executing a command which has the specific policy in the user script, the access violation for the internal log of GLS (/var/opt/FJSVhanet/log/sh.log) may be recorded. If it affects the action of the script, define the exception of the access privilege with the SElinux module to avoid it. For details, refer to "Linux documentation".

3.12.2.1 Settings for NIC switching mode

The following shows the script file call format and the definition file sample for the operation in NIC switching mode.

(1) When activated or deactivated an IP address

[Script file call format]

/bin/sh shaX param1 param2 param3 param4

param1

activate: Activated
inactivate: Inactivated

param2

before: Before activation or deactivation
after: After activation or deactivation

param3

ifname: Physical interface name

param4

inet6: Address family (IPv6 only)
* No param4 for IPv4.


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2004
#
#ident  "%W% %G% %U% - FUJITSU"
#

#
#  Control interface for HA-Net
#

#
#       Params
#
#       $1      activate or inactivate
#       $2      before or after
#       $3      physical interface name
#       $4      address family (IPv6 only)
#

#
# Set Params
#

#INTERFACE=$3
#IP_ADDR1="xx.xx.xx.xx"
#IP_ADDR2="yy.yy.yy.yy" 
#MAC_ADDR1="xx:xx:xx:xx:xx:xx"
#MAC_ADDR2="yy:yy:yy:yy:yy:yy"

cace $# in
3) 
    ADDRESS_FAMILY="inet"
;;
4)
    if [ $4 = "inet6" ]
    then
        ADDRESS_FAMILY="inet6"
    else
        ADDRESS_FAMILY="unknown"
    fi
;;
*)
    ADDRESS_FAMILY="unknown"
;;
esac

if [ $ADDRESS_FAMILY = "inet" ]
then

case "$1" in
'activate')

#
# Activate interface
#

case "$2" in
'before')
#
# script before activate interface
#

# echo "execute script before activate interface on" $INTERFACE > /dev/console

#if [ ! $INTERFACE = "ethX" ]
#then
#     ifconfig $INTERFACE
#else
#     ifconfig $INTERFACE 
#fi

;;

'after')
#
# script after activate interface
#

# echo "execute script after activate interface on" $INTERFACE > /dev/console

#if [ ! $INTERFACE = "ethX" ]
#then
#     arp -d $IP_ADDR1
#     ping $IP_ADDR2 2
#else
#     arp -d $IP_ADDR2
#     ping $IP_ADDR1 2
#fi

;;

*)
        ;;
esac

;;

'inactivate')
#
# inactivate interface
#

case "$2" in
'before')
#
# script before inactivate interface
#

# echo "execute script before inactivate interface on" $INTERFACE > /dev/console
;;

'after')
#
# script after inactivate interface
#

# echo "execute script after inactivate interface on" $INTERFACE > /dev/console

;;

*)
        ;;
esac

;;

*)
        ;;
esac

fi

if [ $ADDRESS_FAMILY = "inet6" ]
then

case "$1" in
'activate')

#
# Activate interface
#

case "$2" in
'before')
#
# script before activate interface
#

# echo "execute script before activate interface on" $INTERFACE > /dev/console

;;

'after')
#
# script after activate interface
#

# echo "execute script after activate interface on" $INTERFACE > /dev/console

;;

*)
        ;;
esac

;;

'inactivate')
#
# inactivate interface
#

case "$2" in
'before')
#
# script before inactivate interface
#

# echo "execute script before inactivate interface on" $INTERFACE > /dev/console

;;

'after')
#
# script after inactivate interface
#

# echo "execute script after inactivate interface on" $INTERFACE > /dev/console

;;

*)
        ;;

esac

;;

*)
        ;;

esac

fi

exit 0

(2) When detected an error in a transfer route

[Script file call format]

/bin/sh shaX param1

param1

Primary: Error in a Primary interface
Secondary: Error in a Secondary interface
all: Error in both Primary/Secondary interfaces


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2004
#
#ident  "%W% %G% %U% - FUJITSU"
#
# Control interface for HA-Net
#
#
#     Params
#
#     $1  communication line state    primary/secondary/all
#
#
# Set Params
#
#STATE=$1
#PROC="process_name"
#kill -15 `/bin/ps -e | /bin/sed -n \
#       -e'/'$PROC'$/s/[^0-9 \t].*//p' \
#       ` > /dev/null 2>/dev/null
#if [ $STATE = "primary" ]
#then
# echo "execute script Polling fail : primary" > /dev/console
#fi
#if [ $STATE = "secondary" ]
#then
# echo "execute script Polling fail : secondary" > /dev/console
#fi
#if [ $STATE = "all" ]
#then
# echo "execute script Polling failover" > /dev/console
#fi

(3) When detected a standby patrol error or recovery

[Script file call format]

/bin/sh shaX param1 param2

param1

establish: Standby patrol established
recover: Standby NIC monitoring recovered
fail: Standby NIC error

param2

Physical interface name of standby NIC: Physical interface name such as ethX
unknown: Standby NIC undecided


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2004
#
#ident  "%W% %G% %U% - FUJITSU"
#
# Control interface for HA-Net
#
#
#     Params
#
#     $1  standby NIC state   establish/recovery/fail
#     $2  standby NIC name    ethX
#
#
# Set Params
#
#STATE=$1
#NIC=$2
#if [ $STATE = "fail" ]
#then
# echo "execute script Patrol fail ($NIC)" > /dev/console
#fi
#if [ $STATE = "establish" ]
#then
# echo "execute script Patrol establish ($NIC)" > /dev/console
#fi
#if [ $STATE = "recover" ]
#then
# echo "execute script Patrol recover ($NIC)" > /dev/console
#fi

3.12.2.2 Settings for GS linkage mode

The following shows the script file call format and the definition file sample for the operation in GS linkage mode.

[Script file call format]

/bin/sh node_event


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2005
#
#ident  "%W% %G% %U% - FUJITSU"
#

#
#  Control interface for HA-Net
#

#
#       Params
#
#       $1      local ip address
#       $2      remote ip address
#       $3      event(NODE_DOWN, POLLING_TIMEOUT, or RESOURCE_OFFLINE)
#
case $# in
3)
        LOCAL_ADDR=$1
        REMOTE_ADDR=$2
        EVENT=$3
;;
*)
;;
esac

case $EVENT in
'NODE_DOWN')
#
# NODE_DOWN invokes when failover occurs at remote host.
#
# execution format) node_event 0.0.0.0 remote ip address NODE_DOWN

;;
'POLLING_TIMEOUT')
#
# POLLING_TIMEOUT invokes when all routes to a virtual ip address
# of remote host failed to hold communication for 3 minutes.
#
# execution format) node_event 0.0.0.0 remote ip address POLLING_TIMEOUT

;;
'RESOURCE_OFFLINE')
#
# RESOURCE_OFFLINE invokes when a virtual interface changes
# its state to inactive over a cluster system.
#
# execution format) node_event local ip address 0.0.0.0 RESOURCE_OFFLINE

;;
*)
;;
esac

exit 0

Information

You can set the time from detecting monitoring failures of a communication target until executing the user command. Execute the user command with the POLLING_TIMEOUT option to the user script "node_event".

The default is 180 seconds (about 3 minutes). The setting value is specified within a range of 0 to 7200. When 0 is specified, the user script is not executed.

Since the time until the execution is controlled by the timer by 5 seconds, if you compare the setting time and the actual execution time, there is a difference up to 5 seconds.

The following shows the setting examples.

  1. Change the internal parameter of GLS.

    The value of "observ_polling_timeout" described in ctld.param is changed into the shortest value (1) from the default value (180).

    /etc/opt/FJSVhanet/config/ctld.param
    #                                 
    #  HA-Net Configuration File      
    #                                 
    #       Each entry is of the form:
    #                                 
    #       <param> <value>           
    #                                 
                                      
    observ_msg      0                 
    observ_polling_timeout  1   <-Changed
    max_node_num    4                 
  2. Restart GLS.

    Distribute the changes by restarting GLS daemon with the resethanet -s command when restarting the operating system.

3.12.2.3 Settings for Self-checking function

The following shows the script file call format and the definition file sample for the self-checking function.

[Script file call format]

/bin/sh monitor param1 param2

param1

driver: GLS driver
daemon: GLS daemon

param2

hungup: A driver or daemon hang detected.
error: A driver or daemon error detected.
process: The abnormal end of the daemon detected.


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2007
#
#ident  "%W% %G% %U% - FUJITSU"
#

#
#  Control interface for HA-Net
#

#
#       Params
#
#       $1      driver  ... sha driver
#               daemon  ... hanetctld
#       $2      hungup  ... hanetctld or driver hungup has been detected.
#               error   ... hanetctld or driver i/o error has been detected.
#               process ... hanetctld process does not exist.
#

COMPO=$1
ERRKIND=$2

case $COMPO
in
driver)
        #
        # script when a driver error is detected.
        #


;;

daemon)
        #
        # script when a daemon error is detected.
        #


;;
esac

exit 0