Forum Discussion
F5 cURL Script Not Working
I have a very basic cURL script that I'm using to verify that a node is up or down but it's not working. When I test the script from the F5 and apply the necessary variables it works but when I attach it to a monitor it doesn't. When I setup the monitor I supply the URI (/css.htm) and the RECV (CSS Test file) variables. Again, if I plug these variables into the script and test from the F5 with the following command: (in the /usr/bin/monitors/ directory) "sh -x test_curl_script 172.16.101.65 10000" This results in the below. But when I use the same script (pasted at the bottom) replace the /css.htm with ${URI} and "CSS Test file" with ${RECV} and I don't specify an IP or port it doesn't work. Thoughts?
[root@F5_02:Standby:In Sync] monitors sh -x ssrs_monitor_curl 172.16.101.65 10000 + Copyright 1996-2007 F5 Networks, Inc. ssrs_monitor_curl: line 1: Copyright: command not found ++ echo 172.16.101.65 ++ sed s/::ffff:// + IP=172.16.101.65 + PORT=10000 ++ basename ssrs_monitor_curl + PIDFILE=/var/run/ssrs_monitor_curl.172.16.101.65_10000.pid + '[' -f /var/run/ssrs_monitor_curl.172.16.101.65_10000.pid ']' + echo 6529 + grep -i 'CSS Test file' + curl -fNs http://172.16.101.65:10000/css.htm + '[' 0 -eq 0 ']' + echo UP UP + rm -f /var/run/ssrs_monitor_curl.172.16.101.65_10000.pid + exit
This is the script that I have imported to the F5 and have attached to an external monitor. The variables I specify are listed above.
IP=
echo ${1} | sed 's/::ffff://'
PORT=${2}
PIDFILE="/var/run/
basename ${0}
.${IP}_${PORT}.pid"
kill of the last instance of this monitor if hung and log current pid
if [ -f $PIDFILE ] then echo "EAV exceeded runtime needed to kill ${IP}:${PORT}" | logger -p local0.error kill -9
cat $PIDFILE
> /dev/null 2>&1
fi
echo "$$" > $PIDFILE
send request & check for expected response
curl -ILs http://${IP}:${PORT}${URI} | grep -i "${RECV}" 2>&1 > /dev/null
mark node UP if expected response was receivedif [ $? -eq 0 ] then echo "UP"
rm -f $PIDFILE else rm -f $PIDFILE fiexit
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