Forum Discussion

Formater's avatar
Formater
Icon for Employee rankEmployee
Jan 27, 2011

How send a string to a specific IP's specific port when all pool members of a VIP are down?

I have a customer who has a pool, which includes there pool members. They want to send some special string in TCP to a specific IP's specific port when all the members of this pool are down. For example, when all members of the pool are down, just send message "down" to 10.10.10.1:12000. The VIP they uses is a Standard type, and the version is v9.3.1

 

 

I am wondering to use TCP::response to reponse, but the specific port is NOT port carrried in TCP::response.

 

 

Anyone has some idea?

 

 

Johnson

 

  • Hi Johnson,

     

     

    I wonder if you could check for [active_members [LB::server pool]] == 0 in CLIENT_ACCEPTED. If it is true, then collect the TCP payload with TCP::collect, replace all of it with TCP::payload replace and then select a new destination IP:port with the node command. Here are the wiki pages for the related commands:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/lb__server

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/active_members

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/tcp__collect

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/tcp__payload

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/node

     

     

    Aaron
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Aaron: That sounds plausible, actually. You couldn't use LB::server pool in CLIENT_ACCEPTED really, since no pool would have been selected yet, but you could certainly use active_members if you know the specific pool anyway.

    Something like (very untested):

    
    when CLIENT_ACCEPTED {
      if {[active_members yourpoolname] == 0 } {
        TCP::collect
      }
    }
    
    when CLIENT_DATA {
      TCP::payload replace 0 [TCP::payload length] "down"
      node 10.10.10.1 12000
      TCP::release
    }
    

    Worth a shot at least. Try it out on a test VIP first as it's not tested, but that's the general idea.

    Colin
  • [LB::server] and [LB::server pool] will return the virtual server's default pool name until a load balancing decision has been made. Once a load balancing decision has been made, [LB::server] will return a Tcl list with pool, node addr and port.

     

     

    I think it was Unruley who pointed this out originally a while back. It makes for a simple way to avoid having to hard code the default pool name in iRules.

     

     

    Aaron