For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

JFC_139527's avatar
JFC_139527
Icon for Nimbostratus rankNimbostratus
Jun 19, 2015

Statistics 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