Forum Discussion
Irule maintenace page switches to another page after a time defined
Dear all,
I have done an Irule that switches a maintenace page to another page after a 5 min, this Irule is Work well for one Virtual Server, when i deploy it to more then one Virtual Server, the second Maintenance page don't display, because i use the global variable.
have you an idea to how can i change this iRule for working on all Virtual Server?
please find below the Irule:
when RULE_INIT {
set ::timestart [clock seconds]
}
when CLIENT_ACCEPTED {
if { [active_members [LB::server pool]] < 1 } {set lb 0}
elseif { [active_members [LB::server pool]] > 0 }{
set lb 1
set ::timestart [clock seconds]
}
}
when HTTP_REQUEST {
if {$lb ==0}{
set timenow [clock seconds]
set timeduration [expr {int($timenow) - int($::timestart)}]
switch -glob [HTTP::path] {
"*/image1.png" {
HTTP::respond 200 content [ifile get imagefile1] "Content-Type" "image/png"
}
"*/image2.png" {
HTTP::respond 200 content [ifile get imagefile2] "Content-Type" "image/png"
}
}
default {
if {$timeduration < 300}{
HTTP::respond 200 content [ifile get Sorry_Page] "Content-Type" "text/html" noserver
}
else {
HTTP::respond 200 content [ifile get Sorry_Page_5] "Content-Type" "text/html" noserver
}
}
}
TCP::close
}
}
Thank you for you help.
- jaikumar_f5
Noctilucent
Here's my understanding. When you use Global variable under an Irule, its applied for whole F5, not just for 1VS. That is why you go with a initialize (rule_init) when its invoke.
 
Hope the below also helps.
 
https://devcentral.f5.com/s/feed/0D51T00006i7V5gSAE
 
- djamil_chlih_23
Nimbostratus
Thank you for your help,
My global value indicate the first time when the all servers pool are down, then i need that value change every one that the state arrive.
if i use the global value in other Irule, i can't change it.
Have you an idea how can i have the first time when the all servers of my pool are down? i need to use this value for every VIP related to this pool of servers, (until that the state of the pool change).
- Lee_Sutcliffe
Nacreous
You shouldn't be using global variables as this will demote your CMP to one CPU. Also, as you are setting the variable in RULE_INIT and CLIENT_ACCEPTED, the set command in CLIENT_ACCEPTED will overwrite the variable in RULE_INIT. This means the set in RULE_INIT is redundant. That being the case, you could just remove the RULE_INIT event and edit CLIENT_ACCEPTED so that it sets 'timestart' as a local variable
set timestart [clock seconds]
- Stanislas_Piro2
Cumulonimbus
Hi,
use table with virtual server name as key instead of global variables
when RULE_INIT { set static::table_timeout 43200 } when CLIENT_ACCEPTED { if { [active_members [LB::server pool]] < 1 } { set lb 0 } elseif { [active_members [LB::server pool]] > 0 } { set lb 1 if {[table lookup -subtable maintenance [virtual name]] ne 1} { table set -subtable maintenance [virtual name] 1 $static::table_timeout 0 } } } when HTTP_REQUEST { if {$lb ==0}{ switch -glob [HTTP::path] { "*/image1.png" { HTTP::respond 200 content [ifile get imagefile1] "Content-Type" "image/png" } "*/image2.png" { HTTP::respond 200 content [ifile get imagefile2] "Content-Type" "image/png" } default { if {[expr {[table lifetime -subtable maintenance -remaining [virtual name]] - $static::table_timeout}] < 300}{ HTTP::respond 200 content [ifile get Sorry_Page] "Content-Type" "text/html" noserver } else { HTTP::respond 200 content [ifile get Sorry_Page_5] "Content-Type" "text/html" noserver } } } } TCP::close }
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