Forum Discussion

abeny_894's avatar
abeny_894
Icon for Nimbostratus rankNimbostratus
Dec 17, 2008

Questions for calculate concurrent session

Dear all,

 

 

 

I would like to ask how can I user iRules to check the HTTP session, and calculate the accumlate HTTP session, if the total HTTP session is reach the MAX concurrent number which defined, it will automatic reset to 0, of coz the iRules will minus concurrent session once client close the session.

 

 

 

How will the iRules look like and any suggestion on this?? Thanks a lot.

 

 

 

 

 

 

3 Replies

  • Thanks CB.

     

     

    I get the idea from the reference. Thanks. But it seems can't exactly count http session or decrease http session when client close. How can I do in the iRules if i need count the exactly HTTP session? Any examples?? Thanks so much for your help.
  • There isn't a way from an iRule to get a count of sessions stored in the session table. There is an existing CR (CR61210) requesting this functionality. You could open a case with F5 Support to ask them to build this feature in a future release.

     

     

    That said, there is a work around for this.

     

     

    You can add a session table entry by using the iRule session command:

     

     

    Generate a new 8 digit client ID

     

    set client_id "client_id_[format "%08d" [expr { int(100000000 * rand())}]]"

     

     

    Insert a cookie with the client ID

     

    HTTP::cookie insert name $::session_cookie_name value $client_id

     

     

    Add the client ID to the session table with a session timeout (in seconds). The value of "1" isn't used for anything.

     

    session add uie $client_id "1" $::session_timeout

     

     

    The session timeout will be enforced by TMM so that old session table entries are removed after the timeout expires. Using a shell script, you can get a count of the session table entries from the command line by running 'bigpipe persist':

     

     

    session_count=`b persist mode universal show all|grep -c client_id`

     

     

    You can then update a datagroup with the current count using the 'bigpipe class' command:

     

     

    b class current_sessions_count_class $session_count

     

     

    You can then reference the current_sessions_count_class from your iRule:

     

     

    set ::available_sessions [expr $::max_session_count_class - $::current_sessions_count_class]