To meet your needs, you must use icall and user_ alert.conf
pool_server has 6 pool members, (A,B,C) group priortity is 10; (D,E,F) group priority is 5:
ltm pool pool_server {
members {
192.168.100.1:telnet {
address 192.168.100.1
priority-group 10
session monitor-enabled
state up
}
192.168.100.11:telnet {
address 192.168.100.11
priority-group 5
session monitor-enabled
state up
}
192.168.100.12:telnet {
address 192.168.100.12
priority-group 5
session monitor-enabled
state up
}
192.168.100.13:telnet {
address 192.168.100.13
priority-group 5
session monitor-enabled
state up
}
192.168.100.2:telnet {
address 192.168.100.2
priority-group 10
session monitor-enabled
state up
}
192.168.100.3:telnet {
address 192.168.100.3
priority-group 10
session monitor-enabled
state up
}
}
min-active-members 2
monitor tcp
}
The master member has A, B and C(firstly create a icall_pool its pool member is A,B,C). You also have to create three pools (pool_icall-1, pool_ical-2, and pool_icall-3). The members are (A, B), (A, C), and (B, C) respectively
pool_back members is (D,E,F)
user_alert.conf
alert poolicall-1-DOWN "No members available for pool /Common/pool_icall-1" {
exec command="tmsh generate sys icall event delete_backserver_session context { { name poolname value pool_ic
all } }"
}
alert poolicall-2-DOWN "No members available for pool /Common/pool_icall-2" {
exec command="tmsh generate sys icall event delete_backserver_session context { { name poolname value pool_ic
all } }"
}
alert poolicall-3-DOWN "No members available for pool /Common/pool_icall-3" {
exec command="tmsh generate sys icall event delete_backserver_session context { { name poolname value pool_ic
all } }"
}
When any of the pools has no available members, an icall event is triggered. Execute the exec linux shell in the icall script (icall script is based on tcl and wants to sleep for 120 seconds, and then execute the session action of deleting the standby node. Later, the test found that icall script deleted the after xxx ms {script} function of tcl, and cannot execute the after function. Instead, we call use exec linux shell
#!/bin/bash
#sleep 120;
count=`tmsh list ltm pool pool_icall | grep "state up" | wc -l`
if [ $count -ge 2 ]
then
for i in `tmsh show ltm pool pool_back members | grep -E "Ltm::Pool Member:" | awk '{print $NF}'`
do
address=`echo $i | awk -F ":" '{print $1}'`;
port=`echo $i | awk -F ":" '{print $2}'`
tmsh delete sys connection ss-server-addr $address ss-server-port $port
done
fi
icall config:
list sys icall handler triggered delete_backserver_session
sys icall handler triggered delete_backserver_session {
script delete_backserver_session
subscriptions {
delete_backserver_session {
event-name delete_backserver_session
}
}
}
list sys icall script delete_backserver_session
sys icall script delete_backserver_session {
app-service none
definition {
foreach var {poolname} {
set $var $EVENT::context($var)
}
puts "poolname is $poolname"
exec /bin/bash /var/tmp/delete_backserver_session.sh
}
description none
events none
}