Not directly answering the thread, but need to repost my EAV posted above (original copy/paste issue.)
Anyway, here is the EAV based on 2 AWS DNS server lookups, to avoid resolver delays if down
Resolve name to IP address
Do a curl against the site to see if it is up .. based on DNS lookup above
* If it is up, then iRule will return CNAME to send client tot he cloud
If curl fails, means the cloud site is down, and then irule will return wideip from GTM pool for internal resorce
==================
!/bin/bash
For Bip-IP v11 use GUI to import EAV
For Big-IP pre v11
Save as /usr/bin/monitors/custom_monitor.bash
or
Save as /config/monitors/custom_monitor.bash
Make executable using chmod 755 custom_monitor.bash
The below arguments are supplied automatically
based on the pool members that the EAV is assigned to
$1 = IP (::ffff:nnn.nnn.nnn.nnn notation or hostname)
$2 = port (decimal, host byte order)
Log debug to /var/log/ltm
Check if a variable named DEBUG exists from the monitor definition
The following must be set in the EAV GUI
DEBUG=0 or 1
RESPONSE_CHECK
FQDN_TO_RESOLVE
DNS_SERVER_1
DNS_SERVER_2
if [ -n "$DEBUG" ]
then
if [ $DEBUG -eq 1 ]; then echo "EAV `basename $0`: \$DEBUG: $DEBUG" | logger -p local0.debug; fi
fi
Remove IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)
We are not actually using it in this monitor
IP=`echo $1 | sed 's/::ffff://'`
Save the port for use in the shell command
PORT=$2
Check if there is a prior instance of the monitor running
pidfile="/var/run/`basename $0`.$IP.$PORT.pid"
if [ -f $pidfile ]
then
kill -9 `cat $pidfile` > /dev/null 2>&1
echo "EAV `basename $0`: exceeded monitor interval, needed to kill ${IP}:${PORT} with PID `cat $pidfile`" | logger -p local0.error
fi
Add the current PID to the pidfile
echo "$$" > $pidfile
Resolve name to IP address
QUERY_RESULT=$(dig @${DNS_SERVER_1} +time=1 +tries=1 +short ${FQDN_TO_RESOLVE} IN A | head -n1)
if [[ $QUERY_RESULT =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
if [ $DEBUG -eq 1 ]; then echo "EAV `basename $0`: Succeeded for ${MY_FQDN} from ${DNS_SERVER_1}" | logger -p local0.debug; fi
Do a curl against the site to see if it is up .. based on DNS lookup above
curl -fNs ${QUERY_RESULT} --header 'Host: ${FQDN_TO_RESOLVE}' | grep -i "${RESPONSE_CHECK}" 2>&1 > /dev/null
if [ $? -eq 0 ]
then
echo "up"
fi
rm -f $pidfile
else
QUERY_RESULT=$(dig @${DNS_SERVER_2} +time=1 +tries=1 +short ${FQDN_TO_RESOLVE} IN A | head -n1)
if [[ $QUERY_RESULT =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
if [ $DEBUG -eq 1 ]; then echo "EAV `basename $0`: Succeeded for ${MY_FQDN} from ${DNS_SERVER_2}" | logger -p local0.debug; fi
curl -fNs ${QUERY_RESULT} --header 'Host: ${FQDN_TO_RESOLVE}' | grep -i "${RESPONSE_CHECK}" 2>&1 > /dev/null
if [ $? -eq 0 ]
then
echo "up"
fi
rm -f $pidfile
else
rm -f $pidfile
if [ $DEBUG -eq 1 ]; then echo "EAV `basename $0`: Failed for ${MY_FQDN} across all DNS servers ${DNS_SERVER_1} and ${DNS_SERVER_2} and ${DNS_SERVER_3}" | logger -p local0.debug; fi
fi