PRIMECLUSTER Global Link Services Configuration and Administration Guide: Redundant Line Control Function 4.1 (for Solaris(TM) Operating System) |
Contents
Index
![]() ![]() |
Chapter 3 Environment configuration | > 3.6 Setting Option Function | > 3.6.11 Setting User command execution function |
The following shows the script file call format and the definition file sample for the operation in NIC switching mode.
/bin/sh shaX param1 param2 param3
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.
#!/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.
[031-071]: Describe the processing of activating the interface.
[042-050]: 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.
[055-064]: 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.
[072-099]: Describe the processing of inactivating the interface.
[083-084]: Outputs a message that a command is executed before the interface is inactivated.
[090-092]: Outputs a message that a command is executed after the interface is inactivated.
/bin/sh shaX param1
param1
Primary: Error in a Primary interface
Secondary: Error in a Secondary interface
all: Error in both Primary/Secondary interfaces
#!/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 # # # Set Params # #STATE=$1 #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 # 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 |
/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 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 |
Contents
Index
![]() ![]() |