ramann_75062
Dec 12, 2007Nimbostratus
Time & Date
Hello together,
is it possible, to define a start/stop time/date for a irule?
thanks
bjoern
when RULE_INIT {
set off_hours 0
set ::time_min [clock scan {10:00}]
set ::time_max [clock scan {17:00}]
}
when CLIENT_ACCEPTED {
set current_day [clock format [clock seconds] -format {%a} ]
set current_time [clock seconds]
if {($current_day == {Sat}) or ($current_day == {Sun})} {
set off_hours 1
} elseif {($current_time < $::time_min) or ($current_time > $::time_max)} {
set off_hours 1
}
}
when HTTP_REQUEST {
if { !$off_hours} {
log local0. "Work Hours...processing event commands."
} else { log local0. "Off Hours...exit event." }
}
when HTTP_RESPONSE {
if { !$off_hours} {
log local0. "Work Hours...processing event commands."
} else { log local0. "Off Hours...exit event." }
}
When first running this rule, I set the time min to 08:00, and the logs showed:
Dec 12 09:54:19 tmm tmm[9977]: Rule time_based : Work Hours...processing event commands.
Dec 12 09:54:19 tmm tmm[9977]: Rule time_based : Work Hours...processing event commands.
I then updated the time_min to 10:00, and the logs showed:
Dec 12 09:58:41 tmm tmm[9977]: Rule time_based : Off Hours...exit event.
Dec 12 09:58:41 tmm tmm[9977]: Rule time_based : Off Hours...exit event.
This configuration modified from the excellent contribution from Deathbywedgie here:
http://devcentral.f5.com/default.aspx?tabid=53&view=topic&forumid=5&postid=8008Click here