Forum Discussion

cmautner_16848's avatar
cmautner_16848
Icon for Nimbostratus rankNimbostratus
Apr 09, 2008

Quick question concerning active sessions

I'm looking for code which will determine if all servers are disabled AND no active sessions are in place. I know the active_members command is working properly. I'm having trouble finding an active sessions command.

 

 

My goal is to have new attempts to connect redirected to a maintenance page, but active sessions remain active until they disconnect. Any help is appreciated!

 

 

when HTTP_REQUEST {
  if {[active_members MYPOOL] == 0  && ????[active_connections/sessions] == 0}  {
    HTTP::redirect "http://www.google.com"
  }
}

4 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Since there isn't currently a command to view the number of active sessions, or to tell if a request coming in is from a currently active session, the best way to go about this would be to tag all incoming requests somehow (a cookie perhaps?) after you've checked to see if there are any active members.

    That would look something like this:

    
    when HTTP_REQUEST {
      if { [HTTP::cookie exists MYCOOKIE] } {
        pool MYPOOL
      } else {
        if { [active_members MYPOOL] == 0 } {
          HTTP::redirect "http://www.google.com"
        } else {
          HTTP::cookie insert MYCOOKIE ...
          pool MYPOOL
        }
      }
    }

    Effectively what that says is:

    If the custom cookie exists, send to pool regardless of pool status.

    If the custom cookie does not exist, check the pool status. If there are no members available, redirect to google. If there are, set the cookie and send them to the pool.

    Is that what you're trying to accomplish?

    Also - can I ask why you'd want to allow active sessions to try and connect when there are no servers available?

    HTH,

    Colin
  • We have a form that can take 30-45 minutes to fill out, so when we bring the site down for maintenance, we want to let the existing connections finish, while new connections are brought to a "sorry we're down" page.
  • when you disable a pool members it maintains by default the active and persisted connections.

     

     

    So if you configure an HTTP profile with a fallback host and you disable all the pool members you should have what you are looking for
  • Nmenant! THATS AWESOME!

     

     

    That is exactly what we need, and it was really easy to do! thanks!