Forum Discussion
Marcus_59536
Nimbostratus
Sep 03, 2009iRUle 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
- The_Bhattman
Nimbostratus
You have to select the pool iin your code before the rest of the your code elements come together.
pool just before "set current_pool [LB::server pool] "
Hope this helps
CB - Marcus_59536
Nimbostratus
I don't know the name of the pool until I call [LB::server pool]. I changed the code to this:
when HTTP_REQUEST {
set current_pool [LB::server pool]
set response "$current_pool Pool Status - [clock format [clock seconds]]"
if {[HTTP::uri] eq "/status" } {
pool $current_pool
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 MEMBER:$current_member:$current_port
STATUS: DOWN
"
} else {
set response "$response NAME:$current_pool
CURRENT MEMBER:$current_member:$current_port
STATUS: UP
"
}
HTTP::respond 200 content $response "Content-Type" "text/html"
}
}
I still get:
when I go to the http://x.x.x.x/status page
NAME:askf5_80
CURRENT MEMBER::0
STATUS: UP
If I then go manually to the VIP normally and go back to http://x.x.x.x/status I get:
NAME:askf5_80
CURRENT MEMBER:65.61.115.222:80
STATUS: UP
Thanks
I need this to come up the first time I access this url. - The_Bhattman
Nimbostratus
I believe I see where your problem is. I think the problem stems for the actual load balancing selection that is occurring. taking that into account and doing some tweaking I think this might work nicely for youwhen HTTP_REQUEST { if {[HTTP::uri] eq "/status" } { scan [LB::select] %s%s%s%s%d command current_pool command2 current_member current_port eval [LB::select] set response "$current_pool Pool Status - [clock format [clock seconds]]" if { [active_members $current_pool] < 1 } { append response "POOL NAME:$current_pool CURRENT MEMBER:$current_member:$current_port STATUS: DOWN " } else { append response "POOL NAME:$current_pool CURRENT MEMBER:$current_member:$current_port STATUS: UP " } } HTTP::respond 200 content $response "Content-Type" "text/html" }
Keep in mind that the code is forcing the LB evaluation early so this may have impact on load balancing after the code is run.
CB - hoolio
Cirrostratus
Nice rule, CB.
To you or anyone else... I've wondered for a while what downside there could be in using LB::select. I imagine if you're using LB::select in CLIENT_ACCEPTED and trying to use cookie persistence that any cookie in the request could be ignored. But are there any issues using LB::select in HTTP_REQUEST after the HTTP headers have been parsed? And if there isn't any downside to using it in HTTP_REQUEST, why isn't the load balancing selection already available using LB::server in HTTP_REQUEST?
Thanks,
Aaron - Marcus_59536
Nimbostratus
Thanks, that works exactly as I wanted it to. - milo
Nimbostratus
Is there a way to data groups with the pool member status irule? It looks like I should be able to make the selectedpool a variable and be able to choose a data group based on a string in the requested URI. - The_Bhattman
Nimbostratus
Hi Milo,
You can certainly grab the selected pool from a variable.
Not sure if you had the chance to look at the following iRule examples
http://devcentral.f5.com/wiki/default.aspx/iRules/Monitor_pools_from_external_monitors.html
http://devcentral.f5.com/wiki/default.aspx/iRules/Pool__Member__Status__Page_on_a__Virtual__Server_v10.html
http://devcentral.f5.com/wiki/default.aspx/iRules/Pool_Member_Status_Page_on_a_Virtual_Server.html
Bhattman - milo
Nimbostratus
I apologize, I need to proofread my posts. Let's say I have 20 vips being supported by two teams, A & B. Team A supports the first 10 and team B the second 10. And, they don't care about the pool status of the vips being supported by the other team. In that case, it would be better to have two data groups that reference different external files. Can I modify the pool_member_status_page irule to select either data group to populate the status page? - The_Bhattman
Nimbostratus
Hi Milo,
Sure you can modify it so that specific datagroups are used.
Bhattman - milo
Nimbostratus
Can you provide an example on how to do that?
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
