19-May-2015
13:03
- last edited on
02-Jun-2023
17:26
by
JimmyPackets
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
19-May-2015
16:05
- last edited on
05-Jun-2023
14:49
by
JimmyPackets
Think I have fixed the issue ...
scan [clock format [clock seconds] -format {%A %k %M}] {%s %d %d} cur_day cur_hour cur_minute
to
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
19-May-2015 20:24
22-Jan-2021
20:11
- last edited on
04-Jun-2023
21:06
by
JimmyPackets
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 "
}
}