Forum Discussion

Marcus_59536's avatar
Marcus_59536
Icon for Nimbostratus rankNimbostratus
Sep 03, 2009

iRUle to check current pool member and show if its up.

I currently can see if the current pool is up and name, but I can't see the pool server IP until I actually manually make the F5 make a LB decision.

 

 

How can I make that decision within/before this HTTP_REQUEST?

 

 

HTTP_REQUEST:

 

when HTTP_REQUEST {

 

set current_pool [LB::server pool]

 

set response "$current_pool Pool Status - [clock format [clock seconds]]"

 

if {[HTTP::uri] eq "/status" } {

 

set current_port [LB::server port]

 

set current_member [LB::server addr]

 

if { [active_members [LB::server pool] ] < 1 } {

 

set response "$response POOL NAME:$current_pool

 

CURRENT SERVER:$current_member:$current_port

 

STATUS: DOWN

 

"

 

} else {

 

set response "$response NAME:$current_pool

 

CURRENT SERVER:$current_member:$current_port

 

STATUS: UP

 

"

 

}

 

HTTP::respond 200 content $response "Content-Type" "text/html"

 

}

 

}

 

 

These all show up as NULL until I manually make a LB decision. How can I change this to work as I planned?

 

 

Thanks

13 Replies

  • Here is one example. Keep in mind that this is not dynamic. You have to add to the class object everytime you want something monitored.

         
        class xpools {    
                  "pool_1/192.168.12.1:80"    
                  "pool_1/192.168.12.3:80"    
                  "pool_3/192.168.13.1:80"    
        }    
       

       
        when HTTP_REQUEST {    
            
                if { [HTTP::uri] eq "/status" } {    
                        set response "BIGIP Pool Member Status - \    <br>                    [clock format [clock seconds]]BIGIP Pool Member Status - [clock format [clock seconds]]\    
                        StatusPool NameMemberPort"                                                foreach { selectedpool } $::xpools {                                if { [catch {                                        scan [split [getfield $selectedpool " " 1] "/"] %s%s poolname addrport                                        scan [split $addrport ":"] %s%d addr port                                        switch -glob [LB::status pool $poolname member $addr $port] {                                                "up" {                                                        append response "UP\                                                        [string tolower $poolname]$addr$port"                                                }                                                "down" {                                                         append response "DOWN\                                                        [string tolower $poolname]$addr$port"                                                }                                                "session_enabled" {                                                         append response "ENABLED\                                                        [string tolower $poolname]$addr$port"                                                }                                                "session_disabled" {                                                         append response "DISABLED\                                                        [string tolower $poolname]$addr$port"                                                }                                                Default {                                                        append response "INVALID\                                                        [string tolower $poolname]$addr$port"                                                }                                        }                                        SWITCH END                                } errmsg] } {                                         append response "INVALID\                                                [string tolower $poolname]$addr$port"                                        }                        }                        append response ""      
                        HTTP::respond 200 content $response "Content-Type" "text/html"    
                }    
        

    I hope this helps

    Bhattman

  • You can save a bit on parsing the pool name, IP and port:

     

     

    test

     

    set selectedpool "pool_1/192.168.12.1:80"

     

     

    replace this:

     

    scan [split [getfield $selectedpool " " 1] "/"] %s%s poolname addrport

     

    scan [split $addrport ":"] %s%d addr port

     

     

    with this:

     

    scan $selectedpool {%[^/]/%[^:]:%s} poolname addr port

     

     

    log sample

     

    puts "$poolname $addr $port"

     

    pool1 1.1.1.1 80

     

     

    Aaron
  • Interesting. Tried parsing from a single line befpre and from the CPU process it took longer then the 2 statements. It would be nice of someone else to see if what I was experience was just my test box.

     

     

    Thanks,

     

    Bhattman