Forum Discussion

Ricardo_Raza_14's avatar
Ricardo_Raza_14
Icon for Nimbostratus rankNimbostratus
Jul 04, 2018

irule time based to select pool

Hi I need to configure an irule based in time for select one pool, I need to configure the rule start at 7 pm and finish at 2 am of the next day each day, I configure the next irule

 

when RULE_INIT {

 

set static::start [clock scan "7:00 pm"] set static::end [clock scan "2:00 am"] } when CLIENT_ACCEPTED {

 

Get the current time in seconds since the Unix epoch of 0-0-1970 set now [clock seconds] Check if the current time is between the start and end times if {$now > $static::start and $now < $static::end}{ pool pool_gw log local0. " pool navegacion" } }

 

If I change the start time for example at 10 am and the end time 11 am all work the problem is because the start time begin one day and finish the other day.

 

Do you have any idea to solve this?

 

6 Replies

  • The problem is the event you use to store date!

     

    RULE_INIT is evaluated only once when you load the irule (change or service restart)

     

    You store the time of 2:00 the day of the last irule load.

     

    You must create variables and not static variables in CLIENT_ACCEPTED event!

     

  • Hi thanks for your help, all work fine now.

     

    But I have another error now, when I attach the irule to the virtual servers all work fine. but I have another irule to control of bandwidth. the irule is the next.

     

    when CLIENT_ACCEPTED { set mycookie [IP::remote_addr]:[TCP::remote_port] BWC::policy attach dynamic_BC $mycookie }

     

    But when I apply the second Irule to the virtual server the users that have the ips of this vs don't have internet, and if I disable this second rule all work fine.

     

    I try to change the order of the irules, but the behavior is the same. Do you know if 2 irules can coexist together or if I need to have any consideration for this configuration.

     

    Thanks for your help

     

    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus

      I never had such issue!

       

      Do you have this issue every time or only when the irule change the pool?

       

    • Ricardo_Raza_14's avatar
      Ricardo_Raza_14
      Icon for Nimbostratus rankNimbostratus

      Hi not really about tcl not exist any error, only in the logs I can see: RST sent from x.x.x.178:60229 to x.x.x.226:54485, [0x2afbce1:135] Port denied Jul 4 23:44:15 LPE-ADM-F501 err tmm[9880]: 01230140:3: RST sent from x.x.x.178:46274 to x.x.x.10:443, [0x29f7703:716] {peer} Flow expired (sweeper) (idle timeout) Jul 4 23:44:15 LPE-ADM-F501 err tmm[9880]: 01230140:3: RST sent from x.x.x.10:443 to x.x.x.131:46274, [0x29f7703:716] Flow expired (sweeper) (idle timeout)