Forum Discussion
MR_RJ
Cirrus
Dec 20, 2008iRule gets to many hits because of bad code?
Hi,
I noticed that my iRule gets a lot of hits according to the statistics. Now I understand why. The purpose of the iRule is if no members are available in the webfarm then show a "houston we ...
hoolio
Cirrostratus
Dec 22, 2008If you add an iRule with code in an HTTP_REQUEST, it will be executed every time an HTTP request is made to the VIP and the HTTP headers are parsed. Can you explain what the issue is?
You could streamline that iRule a bit more by removing the check for the URI equaling the maintenance prefix. You could also set the time_min and time_max variables once in RULE_INIT instead of on every request where there aren't any active pool members.
when RULE_INIT {
set ::maint_prefix "/maintenancepage"
set ::maint_len [string length $maint_prefix]
set ::time_min [clock scan {06:00}]
set ::time_max [clock scan {22:00}]
}
when HTTP_REQUEST {
if { [HTTP::path] starts_with "${::maint_prefix}" } {
set uri [string range [HTTP::uri] $::maint_len end]
switch $uri {
"" {HTTP::respond 301 "Location" "${::maint_prefix}/"}
"/" -
"/index.html" { HTTP::respond 200 content [lindex $::something_something_Maintenance_index_page 0] "Content-Type" "text/html" }
"/logo.png" { HTTP::respond 200 content [b64decode [lindex $::something_something_Maintenance_png 0]] "Content-Type" "image/png" }
"/problems.html" { HTTP::respond 200 content [lindex $::something_something_driftstorningar_index_html 0] "Content-Type" "text/html" }
"/probs.png" { HTTP::respond 200 content [b64decode [lindex $::something_something_driftstorningar 0]] "Content-Type" "image/png" }
default { HTTP::respond 404 }
}
return
}
if { [active_members something_something_Online_Win2003_HTTP] == 0 } {
set current_time [clock seconds]
if {($current_time < $::time_min) or ($current_time > $::time_max)} {
HTTP::redirect "${::maint_prefix}/index.html"
log "No members in pool something_something_Online_Win2003_HTTP, redirecting to maintenancepage"
return
}
log local0. "No members in pool something_something_Online_Win2003_HTTP, redirecting to the critical state page"
HTTP::redirect "${::maint_prefix}/problems.html"
return
}
}
Aaron
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