Forum Discussion
name_65682
Nimbostratus
Aug 30, 2011Maintenance iRule with time period
Hi,
I'm trying to write iRule which will allow some ip's (f.e. 10.10.10.101) to get to my pools, for any other ip's it should redirect to maintenance page. But I wont it to work only during time periods f.e. from 22:00 29.08.2011 to 6:00 30.08.2011. Is it possible?
5 Replies
- nitass
Employee
is it similar to this one?
Schedule an iRule for specific date/time
http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/51/aft/13201/showtab/groupforums/Default.aspx - name_65682
Nimbostratus
Yes, I think it will do ;], thanks for help - name_65682
Nimbostratus
Hi again,
This rule works ok
when HTTP_REQUEST {
"clock seconds" will return the time in seconds
"clock format" will format the previous value with it's date/time components
split will chop the returned string into a list of elements.
Change the following to determine pool used and schedule
set PoolID "test_pool";
set StartTime "1030";
set StopTime "1430";
set StartDay "Thursday";
set StopDay "Thursday";
set l [split [clock format [clock seconds] -format {%A %H %M} ] " " ]
Next add the time check logic:
This example will process the log statement on Wednesday between 10:30 PM and 11:30 PM.
if {[lindex $l 0] eq "$StartDay" } {
set comptime [expr [lindex $l 1] * 100]
set comptime [expr $comptime + [lindex $l 2]]
if {($comptime >= $StartTime) && ($comptime <= $StopTime)} {
Put in iRule logic here
if { [IP::addr [IP::client_addr] equals XX.XX.XXXXX] } { pool $PoolID }
elseif { [IP::addr [IP::client_addr] equals XX.XXX.XXX.XXX] } { pool $PoolID }
else {reject}
}
}
}
but i need rule which will works with tcp(ssh virtual server), what should i change to use with CLIENT_ACCEPTED event(or any else event, I need it's functionality)? - Colin_Walker_12Historic F5 AccountYes, moving this to CLIENT_ACCEPTED should work for TCP connections instead of HTTP.
Colin - hoolio
Cirrostratus
As Colin said, you can just change the event from HTTP_REQUEST to CLIENT_ACCEPTED. As you're not using any HTTP commands or responses it should just work.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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