Forum Discussion
irule not working as expected
Issue with an irule ,from tcpdump dont see traffic hitting the backend servers in the pool.
when RULE_INIT { set debug 1 }
when HTTP_REQUEST {
if {$debug} { set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "=============================================" log local0. "$LogString (request)" foreach aHeader [HTTP::header names] { log local0. "$aHeader: [HTTP::header value $aHeader]" } log local0. "=============================================" }
switch -glob [HTTP::header "SOAPAction"] { "; - "; - "; { if { [active_members qa2-pool] > 0 } { pool qa2-pool } else { pool qa1-pool } } } }
Hello sandiksk
The most likely is you are having a runtime error in your iRule.
Check your /var/log/ltm to confirm.
If you prefer to force normal execution of the load balancing in case of error, you should catch your code.
REF - https://devcentral.f5.com/articles/irules-101-07-catch
KR, Dario.
- sandiksk_35282Altostratus
this is the code i am seeing the var/log/ltm
TCL error: /Common/qa2_irule - can't read "debug": no such variable while executing "if {$debug} { set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "..."
Hello sandiksk.
You have several mistakes in your iRule.
- Set a default condition in your switch sentence (in case of no matching condition)
- Remove ';' characters in your switch options
- You should use static variables in RULE_INIT to be CMP-compatible (see THIS)
-
If you are still having problems with 'debug' variable in logs, try to use a comparation statement like this ->
"
" or "if { $debug != 0 } {
" (to be CMP-compatible)if { $static::debug != 0 } {
KR, Dario.
- Andy_McGrathCumulonimbus
Cannot access a variable set in
unless it is a global (don't do it!) or a static, better to set it inRULE_INIT
it is minor overhead and quicker to update and applyCLIENT_ACCEPTED
Some other minor changes but think the following should work for you:
when CLIENT_ACCEPTED { set debug 1 } when HTTP_REQUEST { if {$debug} { set LogString "Client [IP::client_addr]:[TCP::client_port] -> [HTTP::host][HTTP::uri]" log local0. "=============================================" log local0. "$LogString (request)" foreach aHeader [HTTP::header names] { log local0. "$aHeader: [HTTP::header value $aHeader]" } log local0. "=============================================" } switch -glob [HTTP::header "SOAPAction"] { "http://www.user.com/CustomerFacingWebsite/Customer" - "http://www.user.com/CustomerFacingWebsite/Points" - "http://www.user.com/CustomerInquiry/Balances" { if { [active_members qa2-pool] > 0 } { pool qa2-pool } else { pool qa1-pool } } } }
Recent Discussions
Related Content
* 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