Forum Discussion
Question about maintenance window and time
Hello All,
So I have an iRULE for schedule maintenance window in our F5. This works great except for some reason is it removing the leading zero from minute, please see the iRULE below:
when HTTP_REQUEST {
Change the following to set schedule
set maintenance_start_time "2204";
set maintenance_end_time "2206";
set maintenance_start_day "Tuesday";
set maintenance_end_day "Tuesday";
Get time in seconds, formatted as day of week (%A) hour (%k) minute (%M)
Use scan to save output as $cur_day $cur_hour $cur_minute
scan [clock format [clock seconds] -format {%A %k %M}] {%s %d %d} cur_day cur_hour cur_minute
scan [clock format [clock seconds] -format {%s}] {%d} cur_sec
set cur_time ${cur_hour}${cur_minute}
set cur_time_sec ${cur_sec}
log local0. "\$cur_day: $cur_day, \$cur_hour: $cur_hour, \$cur_minute: $cur_minute, \$cur_time: $cur_time"
log local0. "\$cur_time_sec : $cur_time_sec"
if { ($cur_time >= $maintenance_start_time) && ($cur_time <= $maintenance_end_time) && ($cur_day >= $maintenance_start_day) && ($cur_day <= $maintenance_end_day) } {
if { [HTTP::uri] ends_with "front_image_en.png" }
So right now I cannot schedule maintenance window say where min is 00 i.e. 1500 or 1400 however when I do 1510 it works as there is no leading zero infront of the 1.
Does anyone know how can I put in the leading zero.
When there is no leading zero this is what I see in the logs
May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 22, $cur_time: 2222May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432030965May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 22, $cur_time: 2222May 19 22:22:45 info tmm3[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432030965
When there is a leading zero I see the following
May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 6, $cur_time: 226 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432029988 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_day: Tuesday, $cur_hour: 22, $cur_minute: 6, $cur_time: 226 May 19 22:06:28 info tmm2[20399]: Rule /Common/maintenance_window : $cur_time_sec : 1432029988
3 Replies
- mr_evil_116524
Nimbostratus
Think I have fixed the issue ...
scan [clock format [clock seconds] -format {%A %k %M}] {%s %d %d} cur_day cur_hour cur_minuteto
scan [clock format [clock seconds] -format {%A %k %M}] {%s %s %s} cur_day cur_hour cur_minute
after reading - https://devcentral.f5.com/questions/time-based-rule
- Samir_Jha_52506
Noctilucent
Can you please correct above irule & paste here. Is it validated?
- JRahm
Admin
I was helping on another time related thread and took some of the work here and modified. Hopefully this helps someone who has a maintenance window that crosses midnight.
when RULE_INIT { set static::start_time 221500 set static::end_time 001459 set static::days [list "Wednesday" "Thursday"] } when HTTP_REQUEST { #scan [clock format [clock seconds] -format {%A %H%M%S}] {%s %s} cur_day cur_time ### FOR TESTING PURPOSES ONLY ### #scan [clock format [clock scan "Wed Jan 20 22:14:59 CST 2021"] -format {%A %H%M%S}] {%s %s} cur_day cur_time #scan [clock format [clock scan "Wed Jan 20 22:15:00 CST 2021"] -format {%A %H%M%S}] {%s %s} cur_day cur_time #scan [clock format [clock scan "Thu Jan 21 00:14:59 CST 2021"] -format {%A %H%M%S}] {%s %s} cur_day cur_time #scan [clock format [clock scan "Thu Jan 21 00:15:00 CST 2021"] -format {%A %H%M%S}] {%s %s} cur_day cur_time ### END TESTING STRINGS ### if { !(($cur_day eq [lindex $static::days 0]) && ($cur_time >= $static::start_time)) && !(($cur_day eq [lindex $static::days 1]) && ($cur_time <= $static::end_time)) } { # NORMAL CONDITION HTTP::respond 200 content "Situation: Normal. $cur_day, $cur_time " } else { # MAINTENANCE CONDITION HTTP::respond 200 content "Situation: Maintenance. $cur_day, $cur_time " } }
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