Forum Discussion
Andre_Muniz
Nimbostratus
Jul 01, 2011Schedule 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
15 Replies
- Colin_Walker_12Historic F5 AccountJoe actually walks through doing something like this, sort of:
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 - hoolio
Cirrostratus
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
- steve_88008
Nimbostratus
i was under the impression that setting the static end date and time the irule would no longer process a redirect or whatever method it was instrcuted. is that not the case? - steve_88008
Nimbostratus
or is this the missing piece?
set now [clock seconds]
if {$now > $static::start and $now < static::end}
- hoolio
Cirrostratus
Hi Steve,
Can you clarify what your question is?
Thanks, Aaron - steve_88008
Nimbostratus
sure, is the code that was shared capable of sending traffic to the maint_pool during the specified date/time frame? If so, after the date/time frame specified has passed, will traffic resume normally to the vip the irule is bound too? - Michael_Yates
Nimbostratus
Hi Steve,
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. - steve_88008
Nimbostratus
thanks Michael, that is what i was looking for. now i don't have a "pool" but i do have a url. do you know which command I could use other then pool that works with CLIENT_APPECTED? I tried to use HTTP::redirect but it doesn't seem to work with current event context. - Michael_Yates
Nimbostratus
Hi Steve,
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. " } } - steve_88008
Nimbostratus
so that is pretty tight script you have shared.. I can follow the logic on whats happening, but my tcl\irule chops are not even to a point where i could support that code.... thanks.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
