Hi 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.
Aaron