Forum Discussion
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
- Michael_YatesNimbostratusHi Steve,
when RULE_INIT { Start of maintenance window in YYYY-mm-dd HH:MM format set static::start_date "2012-10-12 17:20" End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date "2012-10-12 17:22" 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 HTTP_REQUEST { set now [clock seconds] if { $now > $static::start and $now < $static::end } { HTTP::redirect "http://www.google.com" } } ------------------------------------------------------------------------------------------------------------ when RULE_INIT { Start of maintenance window in YYYY-mm-dd HH:MM format set static::start_date "2012-10-12 17:30" End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date "2012-10-12 17:32" 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 } { set maintflag "1" } else { set maintflag "0" } } when HTTP_REQUEST { if { $maintflag == 1 } { HTTP::redirect "http://www.google.com" } }
- steve_88008Nimbostratus
the first example is exactly what i have on my LTM ver 10.2.4. however the redirect piece isn't working at all, i tested the url with a simple redirect and that works fine.
when RULE_INIT { Start of maintenance window in YYYY-mm-dd HH:MM format set static::start_date "2012-10-12 03:50" End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date "2012-10-12 04:55" 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::start_end] } when HTTP_REQUEST { set now [clock seconds] if { $now > $static::start and $now < $static::end} { HTTP::redirect "http://www.orderkeystone.com/efiles/systemdown.html" } }
- steve_88008Nimbostratus
So my man Justin Clark at support got me hooked up with the correct syntax. I was running out of time to get this working....
also the LTM uses military time, i ddin't know that, so i had to adjust the time format. greatly appreciated the help, i've learned a TON from this experience.when RULE_INIT { Start of maintenance window in YYYY-mm-dd HH:MM format set static::start_date "2012-10-12 16:50" End of maintenance window in YYYY-mm-dd HH:MM format set static::end_date "2012-10-12 17:55" 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 HTTP_REQUEST { set now [clock seconds] if { $now > $static::start and $now < $static::end} { HTTP::redirect "http://www.orderkeystone.com/efiles/systemdown.html" } }
- BEdmunds_8904NimbostratusWhen I apply Steve's irule (obviously modified for my own error page) I get a page reset.
- ArieAltostratus
If there's another HTTP:respond (including redirect) that is also activated on the same connection you'll get an error. Are you seeing an error in the logs?
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