Forum Discussion

raddboy_74501's avatar
Icon for Nimbostratus rankNimbostratus
Oct 01, 2010

Force Pool members offline for Nightly Maintenance?

I've searched this forum for an answer to no avail.



I'm looking to "force offline" all members of a pool at a specific time every night, say 10:00pm. This will keep users out of an application during our nightly batch process. I'll also need to "Enable" these pool members at a specific time, say 2:00am, when the batch processing has completed.



Any thoughts?



We're on LTM Big-IP 9.3.1 Build 58.0





5 Replies

  • Hey Kevin,



    I don't think this is something that you can really accomplish with iRules. In fact, I'm sure of it. You could probably accomplish this with simple cron jobs on the LTM, but this would only give you a specific window of maintenance. The best bet is probably to use iControl from your batch processing systems to do this automatically before it starts and after it finishes. There are a few samples around of doing similar things that you should be able to use to adapt it to your language of choice.



    For example:






    Hope this helps!



    // Ben


  • This should be doable with the clock command. I wrote a tech tip a while back titled "iRule Maintenance Windows" that allows you to use an iRule to enter the maintenance window times and it then stores those times in a stats profile. Then on inbound requests, if the windows are set, it uses the TCL "clock" command to get the local time of the BIG-IP. If the current time is during the window, the iRule returns a HTML response with an error indicating that maintenance mode is on.



    You should be able to easily modify this iRule to hard code in the start and stop times for your window. Let me know if you need any help.



    Here's the link to the article:







  • Well, color me wrong!



    This is pretty sweet, Joe. I guess I should have known I was too sure to trust myself to be so sure.





  • Was bored today and this looked interesting... hope it helps.


     F5 maintenance windows
     Maintenance windows are specified in a string datagroup called maintenance_windows,
     entries are space delimited in the following format, time is 24 hour.
     HH:MM HH:MM Mon [Wed] [Sat] [Any]
     Example would be
     9:00 10:00 Mon Wed Fri
     23:00 1:00 Any
     If you want a custom site down web page from your web server then create a node for the server 
     in the maintenance pool and setup the /status page on your webserver.
    when HTTP_REQUEST { 
    set data_source "maintenance_windows"
    set maint_pool "maintenance"
     current epoc time
    set cur_time [clock seconds]
     current day
    set cur_day [string tolower [clock format $cur_time -format "%a"]]
    foreach maint_window [class names $data_source] {
    scan [string tolower $maint_window] {%s %s %[^:]} min_time max_time maint_days
    log local0.debug "cur day $cur_day min $min_time max $max_time days $maint_days"
     convert time to epoc
    set min_time [clock scan $min_time]
    set max_time [clock scan $max_time]
                      if {$max_time < $min_time} { set max_time [clock scan "tomorrow" -base $max_time] }
     is it the right day?
    set groundhog_day 0
    if {$maint_days eq "any"} {
    set groundhog_day 1
    } else {
    if {$maint_days contains $cur_day} {
    set groundhog_day 1
    if {$groundhog_day eq 0} { continue }
     is it the right time?
    if {$cur_time < $min_time} { continue }
    if {$cur_time > $max_time} { continue }
     if we got this far then we are in a maintenance window
    if {[active_nodes $maint_pool] > 0} {
    HTTP::uri "/status"
    pool $maint_pool
    } else {
    HTTP::respond 200 content "Site is down for maintenance"

    Note: I did have html tags around the 200 content above but this forum affects them so they were removed. If anyone can tell me the correct html tags I should be using to display iRule code I would appreciate it. Note editing does not display well in IE (esp preview mode). Should I be using a different browser?








  • Just an update,



    For 9.3.x replace [class names $data_source] with $::maintenance_windows. You will have to check it as I do not have 9.x environment to test with.