Forum Discussion
Itamar_39103
Nimbostratus
Dec 21, 2009disable virtual server if active members less than x
Hi all,
I am configuring a GTM machine to load balance DNS requests between virtual servers running on viprion machines.
One of the requirements of the configuration needs to be that the GTM will not issue DNS replies with IP addresses of Virtual servers that hold less than x number of nodes.
I figure that I need to create an irule on the Viprion that will monitor active_members of the pool and disable the pool once the minimum is breached.
Or can I do this on the Virtual Server level?
Could you good people give me a nudge in the right direction?
Thanks,
Itamar
13 Replies
- The_Bhattman
Nimbostratus
Hi Itamar,
In version 10 there is a irule commandnodes_up [ | ]
Which allows you to determine the of the nodes behind a virtual server
In version 9, you could do this in an iRule if the GTM and LTM were running on the same box. However, if you are not(sounds like you are not) then you could do it indirectly. You could create the same pools on the GTM with the same monitors and then use active_members (v9.2.2 or above).
I hope this helps
Bhattman - Itamar_39103
Nimbostratus
Thanks Bhattman!
Indeed, in my configuration the GTM is separate (even geographically) from the Viprions (LTMs).
I am running 9.4.7 on teh GTM and 9.6.1 on the Viprions.
I must say I missed you on the "create the same pools" part of the answer. the GTM is not able to reach the servers behind the VSs in the Viprion. How would it monitor them?
I guess a simpler way would be to create the IRule on the LTM and make the LTM mark its own VS as down once the lower limit was breached. This way we will not need to configure anything out of the ordinary on the GTM.
Any simple way of doing that?
Thanks,
Itamar - The_Bhattman
Nimbostratus
Hi Itamar,
My last suggestion won't work if the GTM cannot reach the servers for whatever reason. (Firewall or routing not allowing it).
Since you are Viprion prior to v10 what you can do is monitor is have the GTM monitor the virtual address
For example the GTM monitors the vip http://vip_address/status. Where the status page displays a message telling the GTM's monitor that it's down when it X amount of nodes are left.
The GTM will then mark it down and thus you will achieve your objective.
Here is a simple example
LTM irule on virtual address port 80 you are monitoringwhen HTTP_REQUEST { if {[HTTP::uri] eq "/status" } { set response "BIGIP Pool Status - [clock format [clock seconds]]" if { [active_members [LB::server pool] ] < 2 } { set response "$response DOWN - $selectedpool " } else { set response "$response UP - $selectedpool " } HTTP::respond 200 content $response "Content-Type" "text/html" } }
Then create a HTTP monitor on the GTM that looks at http://vip_address/status for an UP or DOWN string on the virtual address.
Does that help?
Bhattman - Itamar_39103
Nimbostratus
Thanks Bhattman,
That's a cool IRule there.. Nevertheless I am load balancing with a Performance Layer 4 type Virtual Server. It does not hold an HTTP profile..
Any other method I can use?
Thanks,
Itamar - The_Bhattman
Nimbostratus
Hi Itamar,
Actually it wouldn't matter if your using Performance Layer 4 type virtual server. Because all you are doing is creating a virtual address to run an irule on the LTM that will look at any pool and provide you an UP or down based on active members.
Reworking my example you could also use an iRule that can query any pool within the LTM for up or down status based on their custom minimum members active. All you need is to create a custom monitor for each pool you want a status.
For example let's say you set up a monitor on GTM to look at
http://domainname.com/status?p=pool_layer4&mmember=2
Where p = pool member name and mmember = the minimum members active in the pool
The irule would return back an UP or DOWN on pool_layer4 based on the minimum. In the URL example string above if the members dropped below 2 then respond back with a DOWN.
Here is the iRule for the LTM.when HTTP_REQUEST { if {[URI::query] [HTTP::uri] p] starts_with "?p=" } { set poolname [URI::query] [HTTP::uri] p] set minmember [URI::query] [HTTP::uri] mmember] set response "BIGIP Pool Status - [clock format [clock seconds]]" if { [active_members [LB::server $poolname] ] < $minmember } { set response "$response DOWN - $poolname " } else { set response "$response UP - $poolname " } HTTP::respond 200 content $response "Content-Type" "text/html" } }
You might need to tweak it, since I have not tested it yet.
I hope this helps
Bhattman - Itamar_39103
Nimbostratus
Bhattman, you are the king of IRules!
I had to fix a few bugs - the p of URI doesn't start wit a ? and there is no need for the LB::server..
here is the revised code:
when HTTP_REQUEST {
if {[URI::query [HTTP::uri] ] starts_with "p=" } {
set poolname [URI::query [HTTP::uri] p]
set minmember [URI::query [HTTP::uri] mmember]
set response "BIGIP Pool Status - [clock format [clock seconds]]"
if { [active_members $poolname ] < $minmember } {
set response "$response DOWN - $poolname
"
} else {
set response "$response UP - $poolname
"
}
HTTP::respond 200 content $response "Content-Type" "text/html"
}
}
What I have done is to set up a VS for HTTP with no members and an HTTP profile on the LTM and assigned the above Irule to the created VS.
then I have created a monitor on the GTM that monitors http with "GET ?p=TMs_blades&mmember=2 HTTP/1.0" in the send string and "/.*UP.*/" on the Receive strig.
on the alias address of the monitor I have entered the IP address of the http VS created above.
This works like a charm!
Thanks a million! - The_Bhattman
Nimbostratus
Glad it's working out for you.
I tweaked the code a bit for optimizationwhen HTTP_REQUEST { if {[URI::query [HTTP::uri] ] starts_with "p=" } { set poolname [URI::query [HTTP::uri] p] set minmember [URI::query [HTTP::uri] mmember] set response "BIGIP Pool Status - [clock format [clock seconds]]" if { [active_members $poolname ] < $minmember } { append response "DOWN - $poolname " } else { append response "UP - $poolname " } HTTP::respond 200 content $response "Content-Type" "text/html" } }
Bhattman - The_Bhattman
Nimbostratus
HI Itamar,
Had another question. Is the pool up regardless of the what is in the irule is querrying (with the exception that all pool members down)?
thanks,
Bhattman - The_Bhattman
Nimbostratus
This code has been published under samples:
http://devcentral.f5.com/wiki/default.aspx/iRules/Monitor_pools_from_external_monitors.html
Bhattman - Itamar_39103
Nimbostratus
Hi Bhattman,
Yes, the pool on the LTM needs to stay up as users that were previously referred to it may still be using it.
I want to just stop resolving it's IP address on the GTM so no further users get referred to it.
Best regards,
Itamar
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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