Top
PRIMECLUSTER Global Link Services Configuration and AdministrationGuide 4.6Redundant Line Control Function
FUJITSU Software

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 Virtual NIC mode
  • /etc/opt/FJSVhanet/script/interface/sha-alive.sam (When detected an error or a recovery in the virtual interface)

Sample file for GS linkage mode
  • /etc/opt/FJSVhanet/script/host/node_event.sam

Sample file for all of Fast switching mode, Virtual NIC mode, and GS linkage mode
  • /etc/opt/FJSVhanet/script/interface/sha-NN.takeover.interface.sam (When activating and deactivating the takeover virtual interface)

Sample file for Self-checking function
  • /etc/opt/FJSVhanet/script/system/monitor.sam

[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 Virtual NIC mode
  • /etc/opt/FJSVhanet/script/alive/shaX (When detected an error or a recovery in the virtual interface)

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

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

Setup file for all of Fast switching mode, Virtual NIC mode, and GS linkage mode
  • /etc/opt/FJSVhanet/script/interface/shaX-NN (When activating and deactivating the takeover virtual interface)

* shaX-NN is the name that the colon (:) of the takeover virtual interface name is converted to the hyphen (-).

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

Note

  • Do not call the following commands for redundant line control function in the script file.

    • hanetconfig

    • strhanet

    • stphanet

    • hanetpoll

    • hanetnic

    • hanetpathmon

    • hanetobserv

    • dspobserv

    • resethanet

  • If you execute the command that operates a cluster resource in the script file, make sure to execute it on the background adding "&" at the end of the command. Do not use commands such as the "wait" command of the operating system to wait for the completion of the command that was executed on the background.

  • When the execution of the user command is set, GLS waits for the completion of the shell script. If time-consuming processing was described in the shell script, the subsequent processing may be delayed. In order to make the shell script finish immediately, make sure to describe the execution of the time-consuming processing on the background in the shell script.

  • The commands executed in the script file do not output messages to the standard output. When checking for the contents of the output messages, use commands such as the "logger" command of the operating system to output the messages.

  • 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".

Information

GLS is unaffected by the exit code of the script file because GLS does not refer the exit code.

3.12.2.1 Settings for NIC switching mode

The following shows the samples of script file call formats and definition files.

(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"

case $# 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 param2

param1

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

param2

retryout: Retry out of the ping command
linkdown: Link-down of the interface
pinghang: Hang-up of the ping command


[Definition file sample]

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

#
#       Control interface for HA-Net
#

#
#       Params
#
#       $1  communication line state    primary/secondary/all
#       $2  event exit code             retryout/linkdown/pinghang
#

#
#       Set Params
#

#STATE=$1
#EXIT_CODE=$2

#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
# if [ $EXIT_CODE = "retryout" ]
# then
#  echo "execute script Polling failover : primary retryout" > /dev/console
# elif [ $EXIT_CODE = "linkdown" ]
# then
#  echo "execute script Polling failover : primary linkdown" > /dev/console
# elif [ $EXIT_CODE = "pinghang" ]
# then
#  echo "execute script Polling failover : primary pinghang" > /dev/console
# fi
#fi

#if [ $STATE = "secondary" ]
#then
# if [ $EXIT_CODE = "retryout" ]
# then
#  echo "execute script Polling failover : secondary retryout" > /dev/console
# elif [ $EXIT_CODE = "linkdown" ]
# then
#  echo "execute script Polling failover : secondary linkdown" > /dev/console
# elif [ $EXIT_CODE = "pinghang" ]
# then
#  echo "execute script Polling failover : secondary pinghang" > /dev/console
# fi
#fi

#if [ $STATE = "all" ]
#then
# if [ $EXIT_CODE = "retryout" ]
# then
#  echo "execute script Polling failover : all retryout" > /dev/console
# elif [ $EXIT_CODE = "linkdown" ]
# then
#  echo "execute script Polling failover : all linkdown" > /dev/console
# elif [ $EXIT_CODE = "pinghang" ]
# then
#  echo "execute script Polling failover : all pinghang" > /dev/console
# fi
#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 of Virtual NIC mode

The following shows the script file call format and the definition file sample.

(1) When detected an error or a recovery in the virtual interface

[Script file call format]

/bin/sh shaX param1

param1

failed: Error in the virtual interface
recover: Recover of the virtual interface

[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2016
#

#
#       Control interface for HA-Net
#

#
#       Param
#
#       $1       failed or recover
#

#
# Set Params
#
STATE=$1
VIF=`basename $0`

case "$STATE" in
'failed')

  #
  # script communication alive state transition to 'failed'
  #

  #echo "execute script communication alive state transition. if:$VIF state:$STATE" > /dev/console

;;

'recover')

  #
  # script communication alive state transition to 'recover'
  #

  #echo "execute script communication alive state transition. if:$VIF state:$STATE" > /dev/console

;;
*)
  exit 1
;;
esac

exit 0

3.12.2.3 Settings for GS linkage mode

The following shows the script file call format and the definition file sample.

(1) When changing the remote hot-standby system, when an error is detected in remote host monitoring, and when changing nodes on the local system

[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 the route to all virtual IP addresses
# 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.4 Settings for all of Fast switching mode, Virtual NIC mode, and GS linkage mode

The following shows the script file call format and the definition file sample.

(1) When activating and deactivating the takeover virtual interface

[Script file call format]

/bin/sh shaX-NN param1 param2 param3

param1

active: Active
inactive: Inactive

param2

before: Before activated/inactivated
after: After activated/inactivated

param3

notice: Notice before activated/inactivated (only for "before")
success: Successfully activated/inactivated (only for "after")
failed: Failed to be activated/inactivated (only for "after")


[Definition file sample]

#!/bin/sh
#
#       All Rights Reserved, Copyright (c) FUJITSU LIMITED 2016
#

#
#       Control interface for HA-Net
#

#
#       Params
#
#       $1       active or inactive
#       $2       before or after
#       $3       notice or success or failed
#

#
# Set Params
#
EVENT=$1
TIMING=$2
RESULT=$3
VIF=`basename $0`

case "$EVENT" in
'active')
#
# Activate interface
#

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

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

  ;;

  'after')
    #
    # script after activate interface
    #

    #if [ "$RESULT" = "success" ]; then
    #  echo "execute script after activate interface on $VIF result:$RESULT" > /dev/console
    #else
    #  echo "execute script after activate interface on $VIF result:$RESULT" > /dev/console
    #fi

  ;;
  esac
;;

'inactive')
#
# Inactivate interface
#

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

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

  ;;

  'after')
    #
    # script after inactivate interface
    #

    #if [ "$RESULT" = "success" ]; then
    #  echo "execute script after inactivate interface on $VIF result:$RESULT" > /dev/console
    #else
    #  echo "execute script after inactivate interface on $VIF result:$RESULT" > /dev/console
    #fi

  ;;
  esac

;;
*)
  exit 1
;;
esac

exit 0

3.12.2.5 Settings for Self-checking function

The following shows the script file call format and the definition file sample.

(1) When an error and a recovery is detected in GLS

[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