Forum Discussion

emilhag_383852's avatar
emilhag_383852
Icon for Nimbostratus rankNimbostratus
Feb 15, 2019

Mark a VS down when 1 pool member is down

Hello,

I have seen other similar topics on this but still have not solved our issue, What we want to do is mark a VS down when any pool member goes down (we have 4 members). When this happens BGP from the connected external router will determine the VS down and move traffic to the redundant F5.

I have tried with applying the following iRule to the VS with no luck. Possibly syntax issue?

when HTTP_REQUEST {

   if {[HTTP::header equals "POST"] } { 

          set poolname [URI::query [HTTP::uri]ext-pool] 

          set minmember [URI::query [HTTP::uri] 4] 

          set response "" 

          if { [active_members $poolname ] < $minmember } { 

                 append response "DOWN - $poolname" 

          } else { 

                 append response "UP - $poolname" 

          } 

   HTTP::respond 200 content $response "Content-Type" "text/html" 

   } 

}

Any assistance would be much appreciated. Is this approach feasible for my issue?

9 Replies

  • Hi Emilhag,

    For this requirement, you dont need to create an irule or sort... Just simply create a monitor as usual, but while creating the monitor, you would see the destination option.

    In the destination, give your main pool member detail. So this means, the monitor assigned to the pool will look for this pool member status and mark the other members (including this member) status as Up or Down.

    Example:

    Members: 1.1.1.1:80, 1.1.1.2:80, 1.1.1.3:80, 1.1.1.4:80

    create ltm monitor http  interval 30 timeout 91  recv "Server Up" recv-disable "Server Drain" send "GET /your string" destination 1.1.1.1:80

    So here 1.1.1.1:80 acts as the decider...

    Hope this helps.

    Edited: 19th Feb.

    Hi Emilhag,

    Sorry I misunderstood your requirement,

    So if got your requirement correctly,

    • You have 4 pool members.
    • You want the VS to be marked down, even if one of the members goes down.

    Here, you can try with an external monitor, where you define your own logic and ask the ltm to run commands to disable your virtual.

    In the below external monitor, you'd see I have hardcoded 3 parameter,

    pool=

    your-poolname

    minup=

    4

    virtual=

    your-virtualname

    So you have to update the below script according to your setup.

    !/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=your-poolname
    minup=4
    virtual=your-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
    

    Credits: Kevin Stewart from his original post.

  • Hello Michael,

     

    The GUI catches most syntax issues when you attempt to create the iRule, so I think you're good there. While your iRule is generating a response that should accurately predict whether or not 4 pool members are up, it is not actually disabling that VS, So traffic will continue on to the same VS. Unless of course you have some sort of routed fail-over based on that response; I'll admit that that's outside my wheelhouse and I can't seem to find any documentation on it.

     

    Looking quickly at the source for your code, it looked like most of the solutions revolved around a monitor on GTM specifically checking the response of the VIP, so that if GTM detected that the F5 was down, it would no longer send traffic to that F5. This is why they implemented that response code solution; GTM is no longer sending traffic to a vs based on the response it got from the VS, down or up. Thus, the VS itself would still accept traffic.

     

    So your troubleshooting depends a little on the architecture of your site. If you have just the LTMs, try looking in to commands to disable the pool members/vs. If you're using a GTM, I would double check whatever status monitor you have in place, and make sure it's listening for the right response code at the right uri. Posting a little more information about your issue might also give people more ideas to help you troubleshoot.

     

    Best of luck,

     

    Austin

     

    • emilhag_383852's avatar
      emilhag_383852
      Icon for Nimbostratus rankNimbostratus

      Hello,

       

      Thank you for the responses.

       

      @Jaikumar - the problem with this approach is that member 1.1.1.1:80 needs to go do for all to go down right? If 1.1.1.2:80 goes down it does not trigger the other members and therefore the VS to go down.

       

      @Austin - We have strictly LTM, we have another possible solution with our design that we will test today and if successful I will let you guys know.

       

  • Akeem's avatar
    Akeem
    Icon for Nimbostratus rankNimbostratus

    I have similar situation, whereby I have 2 members in a pool. I want the pool and VIP to go down if I lose one member. I don't really understand the script above as it is not my forte, could someone break it down into simple terms. I've configured the pools/members/VIPs via the GUI. Do I need to remove and configure via the CLI?

     

    Also I'm using an LDAP monitor therefore there's not an option to use an HTTP monitor. I need to understand the script and where to apply it.

     

    Thanks

  • JG's avatar
    JG
    Icon for Cumulonimbus rankCumulonimbus

    There seems to be a less resource-intensive way (for F5) of achieving this:

     

    1. Create as many pool-level health monitors as the pool members, each using an alias IP address representing one pool member;
    2. In the "Availability Requirement" field, select "At least", and then enter the minimum number required (e.g. if you have two pool members and you need to set the condition of both being up, enter "2").
  • Akeem's avatar
    Akeem
    Icon for Nimbostratus rankNimbostratus

    Hello JG,

     

    I've tried this using alias IP addresses plus setting the pool availability to 'at least 2', it doesn't appear to work. I forced one of the servers off-line, however the pool still stayed 'up'. I guess forcing the server off line is a suitable test. Once my colleague is available I can ask him to shut down the server, but not sure if this will make any difference. Have you tried this previously?

    • JG's avatar
      JG
      Icon for Cumulonimbus rankCumulonimbus

      You don't need to wait for your app admin for any action on their side, for you can fake a monitor failure by modifying the monitors with a condition (e.g. a non-existent URL) so that the monitors will definitely fail.

  • Akeem's avatar
    Akeem
    Icon for Nimbostratus rankNimbostratus

    Apologies for the late reply, I've followed your advice and it's worked. Thanks for the detail,