Forum Discussion
Tim_Moomaw_9220
Nimbostratus
Nov 09, 2008Scheduled Maintenance Window
--- Obligatory "I'm new to iRules" ----
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 ...
hoolio
Cirrostratus
Jun 14, 2011Hi Jonathan,
I think it would be simpler and more efficient to convert the start and end datestamps to seconds since the Unix epoch once at rule save. You could then avoid a lot of the parsing with an iRule like this (untested):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 {
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
}
}
If you're on v9, you'd want to change the static variables to global variables by removing "static" from the variable references. This assumes you don't need CMP compatibility. If you do, then you could move the variable declarations from RULE_INIT to CLIENT_ACCEPTED or add them to the session table using the session command.
AaronHelp 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