Forum Discussion

Tommy_Phelan's avatar
Tommy_Phelan
Icon for Nimbostratus rankNimbostratus
Sep 26, 2019

Mark a VS down when 2 pool members are down

Hi,

 

We have an F5 LTM (11.6.0 Build 5.0.429 Hotfix HF5) installed and we have a Pool with 10 members. We would like to mark a VS down when 2 of those members go down. I cant see how this is possible in the F5 GUI and people on this forum talked about using an external monitor. Ive pasted a monitor script below. Does it look ok? To have the LTM run this script , ive imported it and created a monitor linked to it. Im wondering what do i do next to have this script run ?

 

!/bin/sh

pidfile="/var/run/$MONITOR_NAME.$1..$2.pid"

 

# Send signal to the process group to kill our former self and any children

# as external monitors are run with SIGHUP blocked

 

if [ -f $pidfile ]

then

   kill -9 -`cat $pidfile` > /dev/null 2>&1

fi

echo "$$" > $pidfile

 

pool=poolname

minup=8

virtual=virtualname

 

upmembers=`tmsh show /ltm pool $pool members |grep "Current Active Members" |awk -F" : " '{ print $2 }'`

 

if [ $upmembers -ge $minup ]

then

   rm -f $pidfile

   state=`tmsh show /ltm virtual $virtual |grep "State" |awk -F" : " '{ print $2 }'`

   if [ $state == "disabled" ]

   then

       logger -p local0.info -t MONITOR-ALERT "Pool $pool Monitor UP - enabling virtual $virtual"

       tmsh modify /ltm virtual $virtual enabled

   fi

   echo "up"

else

   rm -f $pidfile

   state=`tmsh show /ltm virtual $virtual |grep "State" |awk -F" : " '{ print $2 }'`

   if [ $state == "enabled" ]

   then

       logger -p local0.info -t MONITOR-ALERT "Pool $pool Monitor DOWN - disabling virtual $virtual"

       tmsh modify /ltm virtual $virtual disabled

   fi   

   echo "up"

fi

  • As an alternative, you could set up an iRule to redirect requests to a "Sorry page" if the number of active members in the pool fall below a set number. The one below is similar to what we use when performing maintenance on a pool's servers.

     

    when HTTP_REQUEST {

     if { [active_members [LB::server pool]] == 0 } {

    HTTP::redirect "http://www.mycompany.com/sorrypage.htm"

    }

    }

     

    If not, you may still find a use for it...

     

    Good luck!

    • Tommy_Phelan's avatar
      Tommy_Phelan
      Icon for Nimbostratus rankNimbostratus

      Thanks ... the iRule doesnt fit what i need to do just now but thanks anyways for the iRule as it will come in handy .

  • Hi Tommy,

     

    Script will run every 5 seconds(interval value), when you add external monitor to pool.