Forum Discussion

Drew_Michel_116's avatar
Drew_Michel_116
Icon for Nimbostratus rankNimbostratus
Apr 29, 2013

Subtable Value

Hi All,

 

 

I have a working iRule that throttles http requests which is working a 100%.

 

 

I would like to go one step further and add logic that will allow me to log the when the throttle is enabled/disabled. However to no avail, I'm unable to get it to work.

 

 

If I lookup a value from a key that does't exist, does that return null or an empty string? I can't get it to enter the conditional that logs "Enabled"

 

 

 

if { [table keys -subtable "reqs" -count] > $static::max_hits_per_window } {

 

 

 

log local0. "test: [table lookup -subtable "throt_active" "active"]"

 

The above prints...

 

: test:

 

 

 

 

if { [table lookup -subtable "throt_active" "active"] != "" } {

 

 

log local0. "Throttle enabled: [STATS::get stats count_throt]"

 

table add -subtable "throt_active" "active" "true"

 

 

}

 

 

STATS::incr stats count_throt

 

HTTP::respond 200

 

 

}

 

 

else {

 

set id [table incr "ids"]

 

table set -subtable "reqs" $id "" $static::time_window $static::time_window

 

 

if { [table lookup -subtable "throt_active" "active"] equals "true" } {

 

 

log local0. "Throttle disabled: [STATS::get stats count_throt]"

 

table add -subtable "throt_active" "active" "false"

 

 

}

 

 

 

}

 

 

 

Thanks,

 

Drew

 

No RepliesBe the first to reply