Forum Discussion

Tuckson's avatar
Tuckson
Icon for Altostratus rankAltostratus
Jun 03, 2021

script not working under v16

Hi,

To create an external monitoring script (internal does not give enough flexibility) I downloaded a template somewhere, also downloaded a trial of andd this thingy

#!/bin/sh
# (c) Copyright 1996-2007 F5 Networks, Inc.
#
# @(#) $Id: http_monitor_cURL+GET,v 1.0 2007/06/28 16:10:15 deb Exp $
# (based on sample_monitor,v 1.3 2005/02/04 18:47:17 saxon)
#
# these arguments supplied automatically for all external monitors:
# $1 = IP (IPv6 notation. IPv4 addresses are passed in the form
#                         ::ffff:w.x.y.z
#                         where "w.x.y.z" is the IPv4 address)
# $2 = port (decimal, host byte order)
#
# Additional command line arguments ($3 and higher) may be specified in the monitor template
# This example does not expect any additional command line arguments
#
# Name/Value pairs may also be specified in the monitor template
# This example expects the following Name/Vaule pairs:
#  URI  = the URI to request from the server
#  RECV = the expected response (not case sensitive)
#
# remove IPv6/IPv4 compatibility prefix (LTM passes addresses in IPv6 format)
#
 
 
 
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 -m 5 -fNs http://10.128.182.169:8000/$(basename ${NODE_NAME}) | grep "200" 2>&1 > /dev/null
 
 
# mark node UP if expected response was received
if [ $? -eq 0 ]
then
    rm -f $PIDFILE
    echo "UP"
else
    rm -f $PIDFILE
fi
exit

Unfortunately our production loadbalancers turn out to have an older version (v12) running than the one I downloaded (v16). And appaerantly The NODE_NAME variable, which worked so fine in my own setup, is not present there, hence the script does not work.

Is there anything I can do to make this script on F5 v12 go to a target without having to setup each healthmonitor by hand en giving the name/ip as extra fixed parameter? Is the NODE_NAME variable or the ipaddress available in a different variable name or something like that?

THIA

  • Well the NODE_NAME is one of the predefined variables i what i think. But if its not working in v12, then you have to supply it as argument or update your script to define that variable manually.

     

    Can you put logging of $NODE_NAME in your script to see if it gives you something in different format compared to v12 & v16 or does it not get defined at all.

  • Well, I do not have access to that F5 myself unfortunately, but as far as I can see it is empty. The script did run but the url to be tested failed because it was not complete. I could test if I could still download a trial of of vs 12 somewhere?

    • jaikumar_f5's avatar
      jaikumar_f5
      Icon for Noctilucent rankNoctilucent

      Yes, you can download the v12, spin it up. Create that monitor, create that pool, make sure its reachable. Then you can turn on logging to see what's happening... Good Luck :)

       

      Sorry dont have v12 currently to test it out.

  • Downloaded the V12. Go it to work :-) The NODE_NAME was available however, some other changes in the script were necessary.