Forum Discussion
Lee_Sutcliffe_5
Feb 15, 2013Nimbostratus
Health monitors - XML API
Hi,
I'm trying to write a health monitor that sends an XML string, in order to receive some specific information. I've successfuly been able to replicate the query using cURL by replicating cature...
Kevin_Stewart
Feb 15, 2013Employee
You could possibly alleviate some of your troubles by using an external monitor and cURL, which you know works.
Create a copy of /config/monitors/sample_monitor and make the following changes:
pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"
if [ -f $pidfile ]
then
kill -9 -`cat $pidfile` > /dev/null 2>&1
fi
echo "$$" > $pidfile
node_ip=`echo $1 | sed 's/::ffff://'`
RESULT=`curl -N -H 'Connection: Keep-Alive' -H 'Content-Type: text/xml; charset=utf-8' --ntlm -u 'username:password' -o /dev/null -s -w %{http_code} http://$node_ip:$2`
if [ $RESULT -eq 200 ]
then
echo "up"
fi
rm -f $pidfile
The external monitor consumes the IP address of the server to test in the first parameter ($1) and the port in the second ($2). The beauty of this approach is that you can go absolutely nuts with cURL. In my example I did a simple GET request and returned the HTTP status code using --write-out %{http_code}, but you could just as easily return the entire payload and check for a given value.
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