Forum Discussion
ramann_75062
Nimbostratus
Dec 12, 2007Time & Date
Hello together,
is it possible, to define a start/stop time/date for a irule?
thanks
bjoern
JRahm
Admin
Dec 12, 2007I don't think you can selectively have the rule or not, the rule's presence against a virtual server is determined at load time. You can however, use time and date to determine on whether or not your commands fire.
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
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
