Forum Discussion
JFC_139527
Nimbostratus
Jun 19, 2015Statistics profile issue
Hello
I would like to use statistics profile to set a field that can then ne used to select a pool depending of his value. I wrote the following iRule to test but I have an issue:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "www.test.fr"}{
set PROFILE_NAME "Branch_selection"
set TITLE "iRule Branch Control"
switch -glob [string tolower [HTTP::uri]] {
"/enable*" {
set params [split [HTTP::uri] "/"]
STATS::set $PROFILE_NAME "mode" [lindex $params 2]
HTTP::respond 200 content "
$TITLE
Branch selected: $mode
"
}
"/status*" {
set cmode [STATS::get $PROFILE_NAME "mode"]
HTTP::respond 200 content "
$TITLE
Current cmode: $mode
"
}
}
}
}
And here is the result:
jfc@ds21:~$ curl www.test.fr/status
iRule Branch Control
Current mode: 0
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/enable/1/
iRule Branch Control
Branch selected: 1
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/status
iRule Branch Control
Current mode: 0
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/status
iRule Branch Control
Current mode: 1
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/enable/1/
iRule Branch Control
Branch selected: 1
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/status
iRule Branch Control
Current mode: 1
jfc@ds21:~$
jfc@ds21:~$ curl www.test.fr/status
iRule Branch Control
Current mode: 1
jfc@ds21:~$
jfc@ds21:~$
I have to set the field profile twice to get a stable value. It seems that there're 2 fields that are set/get alternatively. Any idea? Do I miss something?
No RepliesBe the first to reply
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects