Forum Discussion
Scheduled Maintenance Window
I'm trying to create a rule to return a maintenance page every Saturday morning between 0200 and 0600. I have copied a few examples from DevCentral which work great except for any period of time that includes an 08 or 09. The log entries clearly indicate that it's having an issue with non-octal numbers being returned but I can't figure out how to get around it. I'm betting it's something hugely simple. Suggestions welcomed. Here's the rule as it's written now and the error that is received at 0208, 0209, 0308, 0309,08xx, 09xx etc. Thanks in advance.
when HTTP_REQUEST {
Change the following to set schedule
set start_time "0200";
set end_time "0600";
set day "Saturday";
set l [split [clock format [clock seconds] -format {%A %H %M}] " "]
set cur_day [lindex $l 0]
set cur_time [expr [expr {[lindex $l 1] *100}] + [lindex $l 2]]
if { ($cur_day eq $day) &&
($cur_time >= $start_time) &&
($cur_time <= $end_time) } {
HTTP::respond ----text here----
TCL error: m-window-test HTTP_REQUEST - cant use invalid octal number as operand of * while executing expr {[lindex $l 1] *100}
Also receive this error:
TCL error: m-window-test HTTP_REQUEST - expected integer but got 08 looks like invalid octal number while executing expr [expr {[lindex $l 1] *100}] + [lindex $l 2]]
29 Replies
- Kris__109062
Nimbostratus
How do you update the timezone... the clock commands don't ever seem to relate to the timezone I have set on the F5. - Michael_Yates
Nimbostratus
This should pull the local time from the device locally and format it into HH:MM:SS.
[clock format [clock seconds] -format {%H:%M:%S}] - Cyril_M
Altostratus
Thanks Aaron this rule worked fine on my 11.1 BigIP, except for this little error: you typed static::start_end instead of static::end_date in the 11th line.
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::start_end] } when CLIENT_ACCEPTED { Save the current time in seconds since the epoch set now [clock seconds] Use the maintenance pool if we're in the maintenance window if {$now > $static::start and $now < $static::end}{ pool MAINT-POOL } }Once corrected, it does the trick pretty well, even when using an european timezone
Regards !
- hoolio
Cirrostratus
Hi Cyril,
Thanks for catching that. I updated my original post as well.
Aaron - Cyril_M
Altostratus
Thanks to you for this usefull code ! As you are here I wanted to know what is, according to you, the benefit of using static variables in the Rule_Init section instead of guenuine variables in the client_accepted section ? - hoolio
Cirrostratus
It's more efficient to convert the dates to UTC once in RULE_INIT and save them to static variables compared with doing that conversion to UTC on every connection.
Aaron - dlee_302341
Nimbostratus
Guess as I am not an expert here what is the output\function of this iRule? What should I see and to what do I apply this rule too? Thanks for all the Excellent Info.
- Kevin_Stewart
Employee
Assuming you're talking about the last submission from Cyril, the iRule would be placed on the application VIP. You'd need a separate pool containing some static "We're under maintenance" webpage, so that when users make a request to the site within the start and end times defined, the request will be sent (pooled) to this static resource which will return the maintenance page.
- dlee_302341
Nimbostratus
Roger that. Thanks Kevin.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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