Forum Discussion

name_65682's avatar
name_65682
Icon for Nimbostratus rankNimbostratus
Aug 30, 2011

Maintenance 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?

 

  • 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
  • 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_12's avatar
    Colin_Walker_12
    Historic F5 Account
    Yes, moving this to CLIENT_ACCEPTED should work for TCP connections instead of HTTP.

     

     

    Colin
  • 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