Andre_Muniz
Jul 01, 2011Nimbostratus
Schedule iRule
Im new in iRule. Im using a iRule and its ok, but i need to schedule this. I need that iRule to be enabled only a certain part of the day. How can I do that ? Thanks
Im new in iRule. Im using a iRule and its ok, but i need to schedule this. I need that iRule to be enabled only a certain part of the day. How can I do that ? Thanks
http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=70
http://devcentral.f5.com/wiki/default.aspx/iRules/LTMMaintenanceWindow.html
This is for bringing up a maintenance page at a given part of the day. It could be modified for your purposes, though.
Colin
Here's a simple example as well for 10.x:
when RULE_INIT {
Start of maintenance window in YYYY-mm-dd HH:MM format
set static::start_date "2011-05-29 18:45"
End of maintenance window in YYYY-mm-dd HH:MM format
set static::end_date "2011-05-29 18:50"
Convert start/end times to seconds from the epoch for easier date comparisons
set static::start [clock scan $static::start_date]
set static::end [clock scan $static::end_date]
}
when CLIENT_ACCEPTED {
set now [clock seconds]
if {$now > $static::start and $now < static::end}{
pool MAINT_POOL
}
}
Aaron
or is this the missing piece?
set now [clock seconds]
if {$now > $static::start and $now < static::end}
Can you clarify what your question is?
Thanks, Aaron
If I understand your question properly you are concerned about what will happen after the end-time has been reached.
The iRule that hoolio provided sets a start time and stop time for the maintenance window.
After the end time the traffic should no longer be sent to your maintenance pool or page since the qualifiers in the iRule are no longer true. Then traffic would flow normally as if the iRule was not applied.
If you want the maintenance page to be put up at a certain time but not be taken down until you manually remove the iRule you could make a few adjustments to make that happen.
You can look on the CLIENT_ACCEPTED event Wiki page to see a list of available commands in that event.
You are correct that you cannot use an HTTP::redirect or HTTP::respond in that event. You could however set a flag / variable in this event that is picked up in the HTTP_REQUEST event and triggers a redirect.
Here's an example:
when CLIENT_ACCEPTED {
Check Client IP Address Exclusions GO HERE!
if { !([matchclass [IP::remote_addr] equals $::MaintenancePageOverride ]) } {
If it's not on the exclusion list. Tag it here.
set rewrite_response 1
} else {
If it is to be excluded, set value here.
set rewrite_response 0
}
}
when HTTP_REQUEST {
if { [HTTP::uri] contains "maintenanceaccess" } {
set rewrite_response 3
}
}
when HTTP_RESPONSE {
if { $rewrite_response equals "1" } {
HTTP::respond 200 content "Site unavailable
System Maintenance
NOTICE: This website down for system maintenance.
"
}
elseif { $rewrite_response equals "3" } {
HTTP::respond 200 content "Maintenance Access
Maintenance Access Assistance
Your IP Address is: [IP::client_addr]
Please provide the IP Address listed above to the Support Team Representative assisting you with
your maintenance window. This will allow the Representative to grant you override access to the
maintenance page.
Thank you.
"
}
}