您的位置:首页 > 其它

使用iRules在F5 LTM上实现根据不同时间段选择不同资源池

2017-10-09 11:59 986 查看
when RULE_INIT {

    array set static::timerange {

        Sunday {}

        Monday {"08:30:01" "14:00"}

        Tuesday {"08:30:01" "14:00"}

        Wednesday {"08:30:01" "14:00"}

        Thursday {"08:30:01" "14:00"}

        Friday {"08:30:01" "14:00"}

        Saturday {}

    }

}

when HTTP_REQUEST {

    set now [clock seconds]

    set current_day [clock format $now -format {%A}]

    set start [lindex $static::timerange($current_day) 0]

    set end [lindex $static::timerange($current_day) 1]

    if {($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end])} {

        set worktime 1

    } else {set worktime 1 }

    unset start end

    if {$worktime } {

        if {[active_members pool www-Silo2Master] > 0} {

        pool pool www-Silo2Master

        } else {pool www-Silo1Master}

    } else {

        if {[active_members pool www-Silo1Master] > 0} {

        pool pool www-Silo1Master

        } else {pool www-Silo1Master}

    }

}
https://devcentral.f5.com/questions/irule-help-46614
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐