Forum Discussion
Monitoring one node to control the status of another. Feasible?
Okay, just a thought, but it seems like you'd need some way to map a given test page to a pool member. I put the below together using an external monitor script applied to the 5th server (status server) pool.
!/bin/sh
pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"
if [ -f $pidfile ]
then
kill -9 -`cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
=================================
User-defined: app-server pool name
web_server=webserver-pool
User-defined: array list to map test page to pool respective pool member
arr=(
"test1.html=10.1.10.90:80"
"test2.html=10.1.10.91:80"
"test3.html=10.1.10.92:80"
)
=================================
This is the status server IP and port
stat_server=`echo $1 | sed 's/::ffff://'`
port=$2
Looping through the array
for item in ${arr[*]}
do
test=$(cut -d '=' -f1 <<< $item)
mbr=$(cut -d '=' -f2 <<< $item)
status=$(curl -s -o /dev/null -w "%{http_code}" http://${stat_server}:${port}/${test})
mbr_state=$(tmsh list ltm pool ${web_server} members { ${mbr} { state } } |grep state |awk -F" " '{ print $2 }')
if [ "$status" != "200" ]
then
if [ "$mbr_state" == "up" ]
then
Status is not 200 - if the pool member is up, send it down
tmsh modify ltm pool ${web_server} members modify { ${mbr} { state user-down } }
fi
else
if [ "$mbr_state" != "up" ]
then
Status is 200 - if the pool member is down, send it up
tmsh modify ltm pool ${web_server} members modify { ${mbr} { state user-up } }
fi
fi
done
rm -f $pidfile
Echo "up" to keep the status server pool alive
echo "up"
I'd also recommend pushing the monitor interval and timeout values out a bit, maybe 15-50 seconds.
This script effectively loops through the array and requests each test page from the status server in order. If the result is not 200, the corresponding member from the app server pool is marked down. This could definitely use some tweaking, but should otherwise work.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
