monu1
Sep 11, 2013Nimbostratus
Session count from table
Hi, I am using below iRule for limiting the no of sessions on F5. I want to know, If we can get the no of session in the table using CLI? Also if we can delete the session manually? when RULE_INIT { set static::total_active_clients 0 set static::sessionCookiePrefix "session" set static::max_active_clients 5 set static::sessionTimeout 120 } when HTTP_REQUEST { set subtableName "sessionLimit-shopMaintainence" set sessionCookieName "$static::sessionCookiePrefix-Maintainence" set need_cookie 0
if {[HTTP::cookie exists $sessionCookieName]} {
set client_id [HTTP::cookie $sessionCookieName]
set sessiondata [table lookup -subtable $subtableName $client_id]
if { $sessiondata != "" } {
return
}
}
set sessionCount [table keys -subtable $subtableName -count]
log local0. sessionCount
if {$sessionCount < $static::max_active_clients} {
set need_cookie 1
set client_id [format "%08d" [expr { int(100000000 * rand()) }]]
set sessionValue [IP::client_addr]
table add -subtable $subtableName $client_id $sessionValue $static::sessionTimeout
log local0. "[HTTP::cookie names] [IP::client_addr] NEW"
} else {
HTTP::redirect "http://www.xyz.com/"
}
}
when HTTP_RESPONSE { if {$need_cookie == 1} { HTTP::cookie insert name $sessionCookieName value $client_id path "/" } }
Thanks for your help.