2 # ctdb event script for NFS tickle acks
4 PATH=/bin:/usr/bin:$PATH
12 [ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
13 [ -z "$NFS_TICKLE_SHARED_DIRECTORY" ] && exit 0
17 mkdir -p /etc/ctdb/state/nfstickle
18 mkdir -p $NFS_TICKLE_SHARED_DIRECTORY/`hostname`
19 # we rely on fast tcp wait1 recycling
20 echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
28 # send tickle acks for all the connections the old server had
29 for f in $NFS_TICKLE_SHARED_DIRECTORY/*/$ip; do
30 cat $f | while read dest; do
31 dip=`echo $dest | cut -d: -f1`
32 dport=`echo $dest | cut -d: -f2`
33 # send three, in case of lost packets
34 echo "`date` Sending NFS tickle ack for $ip to $dip:$dport"
35 for i in `seq 1 3`; do
36 ctdb tickle $dip:$dport $ip:2049
56 mydir=$NFS_TICKLE_SHARED_DIRECTORY/`hostname`
58 # record our connections to shared storage
59 netstat -tn |egrep '^tcp\s+[0-9]+\s+[0-9]+\s+[0-9\.]+:2049.*ESTABLISHED' |
60 awk '{print $4" "$5}' |
61 while read dest src; do
62 ip=`echo $dest | cut -d: -f1`
63 echo $src >> $mydir/$ip
70 # ignore unknown commands