Forum Discussion

oscarnet_69487's avatar
oscarnet_69487
Icon for Nimbostratus rankNimbostratus
Mar 21, 2017

how to check uri clock time select pool

Hi how can i use uri clock to select pool ? my irule

 

Code

when RULE_INIT {
set client_req_start_time [clock clicks -milliseconds]
}
when HTTP_REQUEST {
set http_request_time1 {[HTTP::uri] ends_with ".jpg" [clock clicks -milliseconds]}
set http_request_time2 {[HTTP::uri] ends_with ".png" [clock clicks -milliseconds]}
set http_request_time3 {[HTTP::uri] ends_with ".gif" [clock clicks -milliseconds]}
if { [expr $http_request_time1 - $client_req_start_time ] > 10 } { 
pool pool_jpgA }
if { [expr $http_request_time2 - $client_req_start_time ] > 10 } { 
pool pool_pngA }
if { [expr $http_request_time3 - $client_req_start_time ] > 10 } { 
pool pool_gifA }
    pool default_pool
}

think's

 

1 Reply

  • Hi,

    I think you want to know the time between request and response:

    when CLIENT_ACCEPTED {
        set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
        set client_req_start_time [clock clicks -milliseconds]
        switch -glob -- [HTTP::path] {
            "*.jpg" {
                set filetype "jpg"
                pool pool_jpgA
            }
            "*.png" {
                set filetype "png"
                pool pool_jpgA
            }
            "default" {
                set filetype "default"
                pool $default_pool
            }
        }
    }
    
    when HTTP_RESPONSE {
        switch -- $filetype {
            "jpg" {
                log local0. "jpg file - clock time : [expr {[clock clicks -milliseconds] - $client_req_start_time}]"
            }
            "png" {
                log local0. "png file - clock time : [expr {[clock clicks -milliseconds] - $client_req_start_time}]"
            }
            default {
                log local0. "gif file - clock time : [expr {[clock clicks -milliseconds] - $client_req_start_time}]"
            }
        }
    }