A user-defined command can be executed at a specific timing. For information on execution timing, see "2.2.12 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. In GS/SURE linkage mode, this function can be used to send a signal to a specific process, 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.
/etc/opt/FJSVhanet/script/interface/sha.interface.sam (When activating or deactivating an IP address)
/etc/opt/FJSVhanet/script/failover/sha.failover.sam (When detected an error in a transfer route)
/etc/opt/FJSVhanet/script/patrol/sha.patrol.sam (When detected a standby patrol error or recovery)
/etc/opt/FJSVhanet/script/host/host.sam
The storage destination and file name of a setup file varies depending on the type and name of a virtual interface.
/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.
/etc/opt/FJSVhanet/script/host/hostIP
* hostIP is the host name or IP address of the virtual interface of the communication target.
/etc/opt/FJSVhanet/script/init.sh
Note
Do not call the operational command for redundancy line control function in the script file.
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 the "logger(1)" command of the operating system to output the messages to syslog.
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.
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
/bin/sh shaX param1 param2 param3
activate: Activated
inactivate: Inactivated
before: Before activation or deactivation
after: After activation or deactivation
ifname: Physical interface name
inet6: Address family (IPv6 only)
* No param4 for IPv4.
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2001 # #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 = "hmeX" ] #then # ifconfig $INTERFACE ether $MAC_ADDR1 #else # ifconfig $INTERFACE ether $MAC_ADDR2 #fi ;; 'after') # # script after activate interface # # echo "execute script after activate interface on" $INTERFACE > /dev/console #if [ ! $INTERFACE = "hmeX" ] #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 |
The following shows an example of outputting a message when a command is executed, change the MTU length, deleting the concerned information from the ARP table, and checking the communication (executes the ping command).
Note that three-digit numbers placed on the left end of this example need not be placed in the actual script file because they just indicate line numbers for the purpose of explanation.
* An example of setting operated only in IPv4.
001 #!/bin/sh 002 # 003 # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2001 004 # 005 #ident "%W% %G% %U% - FUJITSU" 006 # 007 008 # 009 # Control interface for HA-Net 010 # 011 012 # 013 # Params 014 # 015 # $1 activate or inactivate 016 # $2 before or after 017 # $3 physical interface name 018 # 019 020 # 021 # Set Params 022 # 023 024 INTERFACE=$3 025 IP_ADDR1="192.1.1.1" 026 IP_ADDR2="192.1.2.1" 027 MAC_ADDR1="02:00:00:00:00:00" 028 MAC_ADDR2="02:00:00:00:00:01" 029 030 case "$1" in 031'activate') 032 033 # 034 # Activate interface 035 # 036 case "$2" in 037 'before') 038 # 039 # script before activate interface 040 # 041 042 echo "execute script before activate interface on" $INTERFACE > /dev/console 043 if [ ! $INTERFACE = "hmeX" ] 044 then 045 ifconfig $INTERFACE ether $MAC_ADDR1 046 else 047 ifconfig $INTERFACE ether $MAC_ADDR2 048 fi 049 ;; 050 051 'after') 052 # 053 # script after activate interface 054 # 055 echo "execute script after activate interface on" $INTERFACE > /dev/console 056 ifconfig $INTERFACE mtu 1454 057 if [ ! $INTERFACE = "hmeX" ] 058 then 059 arp -d $IP_ADDR1 060 ping $IP_ADDR2 2 061 else 062 arp -d $IP_ADDR2 063 ping $IP_ADDR1 2 064 fi 065 ;; 066 *) 067 ;; 068 esac 069 070 ;; 071 072 'inactivate') 073 # 074 # inactivate interface 075 # 076 077 case "$2" in 078 'before') 079 # 080 # script before inactivate interface 081 # 082 083 echo "execute script before inactivate interface on" $INTERFACE > /dev/console 084 ;; 085 086 'after') 087 # 088 # script after inactivate interface 089 # 090 091 echo "execute script after inactivate interface on" $INTERFACE > /dev/console 092 ;; 093 094 *) 095 ;; 096 esac 097 098 ;; 099 100 *) 101 ;; 102 esac 103 104 exit 0 |
The following explains this setting example. In the explanation, [xxx] represents a line number in this setting example.
Describe the processing of activating the interface.
Outputs a message that a command is executed and sets the interface information (MAC address) depending on the interface type to be processed before the interface is activated.
Outputs a message for executing command. Then, changes the length of MTU after activating the interface. Finally, it deletes the corresponding ARP information and checks for a communication.
Describe the processing of inactivating the interface.
Outputs a message that a command is executed before the interface is inactivated.
Outputs a message that a command is executed after the interface is inactivated.
(2) When detected an error in a transfer route
/bin/sh shaX param1
Primary: Error in a Primary interface
Secondary: Error in a Secondary interface
all: Error in both Primary/Secondary interfaces
retryout: Retry out of the ping command
pinghang: Hang-up of the ping command
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2002 # #ident "%W% %G% %U% - FUJITSU" # # Control interface for HA-Net # # # Params # # $1 communication line state primary/secondary/all # $2 event exit code retryout/pinghang # # # Set Params # #STATE=$1 #EXIT_CODE=$2 #PROC="process_name" #kill -15 `/usr/bin/ps -e | /usr/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 = "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 = "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 = "pinghang" ] # then # echo "execute script Polling failover : all pinghang" > /dev/console # fi #fi |
Note
param2 is only enabled when the patch 914233-10 or later is applied in Solaris 10 environment.
(3) When detected a standby patrol error or recovery
/bin/sh shaX param1 param2
establish: Standby patrol established
recover: Standby NIC monitoring recovered
fail: Standby NIC error
Physical interface name of standby NIC: Physical interface name such as hmeX
unknown: Standby NIC undecided
#!/bin/sh # # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2002 # #ident "%W% %G% %U% - FUJITSU" # # Control interface for HA-Net # # # Params # # $1 standby NIC state establish/recovery/fail # $2 standby NIC name hmeX # # # 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 |
The following shows the script file call format and the definition file sample for the operation in GS/SURE linkage mode.
/bin/sh hostIP
# # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2001 # #ident "%W% %G% %U% - FUJITSU" # # # Control interface for HA-Net # # # Set Params # #PROC="process_name" # # Procedure # # #kill -15 `/usr/bin/ps -e | /usr/bin/sed -n \ # -e'/'$PROC'$/s/[^0-9 \t].*//p' \ # ` > /dev/null 2>/dev/null # |
The following shows an example of sending a signal (SIGHUP) to the DUMY process. Note that three-digit numbers placed on the left end of this example need not be placed in the actual script file because they just indicate line numbers for the purpose of explanation.
001 # 002 # All Rights Reserved, Copyright (c) FUJITSU LIMITED 2001 003 # 004 #ident "%W% %G% %U% - FUJITSU" 005 # 006 007 # 008 # Control interface for HA-Net 009 # 010 011 # 012 # Set Params 013 # 014 015 PROC="DUMY" 016 017 # 018 # Procedure 019 # 020 020 # 030 kill -1 `/usr/bin/ps -e | /usr/bin/sed -n \ -e'/'$PROC'$/s/[^0-9 \t].*//p' \ ` > /dev/null 2>/dev/null |
The following explains this setting example. In the explanation, [xxx] represents a line number in this setting example.
Specifies a process name to be stopped.
Acquires the process ID of a concerned process from the process list and send SIGTERM for the process.
The following shows the script file call format and a setting example when configuring the service for Redundant Line Control function.
/bin/sh init.sh
When restarting a network service svc:/network/serviceX in conjunction with starting the service for Redundant Line Control function, define the script as follows:
#!bin/sh # #logger -p daemon.notice "execute script for fjsvhanet service" # svcadm restart svc:/network/serviceX # exit 0 |