Forum Discussion
jonathan_106468
Nimbostratus
Feb 16, 2010External Commands thru iRules
Good Morning,
I have a small question on the usage of iRules in GTM.
What we want to achieve is that if an Active Pool Member in GTM is unavailable and GTM tries to switc...
The_Bhattman
Nimbostratus
Feb 17, 2010Hi Jon,
The one thing you can't do is run unix commands through an iRule. However, what you asked can be possible triggered by a custom monitor. The custom script woud monitor the Active Pool members and upon discovering it's unavailable it would log into the remote APP server and run a command and once that is done it would would then officially report back the system is down thereby informing the GTM to fail over.
For example let's say the the GTM is monitoring a vip connected to a pool on the LTM in active site and monitoring a vip on site B (Passive). The LTM is using a custom monitor to check say DNS on the pool members
The script would look something like the following:
!/bin/sh
these arguments supplied automatically for all external monitors:
$1 = IP (nnn.nnn.nnn.nnn notation or hostname)
$2 = port (decimal, host byte order) -- not used in this monitor, assumes default port 53
$3 = name to be looked up
$4 = string in expected response
node_ip=`echo $1 | sed 's/::ffff://'`
pidfile="/var/run/`basename $0`.$node_ip..$2.pid"
if [ -f $pidfile ]
then
kill -9 `cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
dig @${node_ip} ${3} | egrep -v '^$|^;' | grep ${4} > /dev/null 2>&1
For AAAA lookups, use this instead
dig @${node_ip} ${3} AAAA| egrep -v '^$|^;' | grep ${4} > /dev/null 2>&1
status=$?
if [ $status -eq 0 ]
then
echo "UP"
else
here is the code that would remotely log in and execute the unix command
fi
rm -f $pidfile
What would happen is that if the script failed it would first run the remote command before reporting back to the GTM to fail over to the standby system
Of course this is all theory so you are definitely going to need to test it
I hope this helps
Bhattman
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects