iRule(1) BIG-IP TMSH Manual iRule(1)
LB::server
Returns information about the currently selected server.
SYNOPSIS
LB::server ('name' | 'pool' | 'route_domain' |
'addr' | 'port' | 'priority' |
'ratio' | 'weight' | 'ripeness')?
DESCRIPTION
This command allows you to query for information about the member selected after a load balancing decision has
been made.
If no server was selected (all servers down), this command with either no arguments or the "name" argument
will return the pool name only--useful for determining the default pool applied to a virtual server. If the
node command is called prior to this command a null string is returned as the node command overrides any prior
pool selection logic.
LB::server [name | pool | route_domain | addr | port | priority | ratio | weight | ripeness]
RETURN VALUE
LB::server
returns a Tcl list with pool, pool member address and port. If no server was selected yet or all servers
are down, returns default pool name only.
LB::server name
returns a Tcl list with pool, pool member address and port. If no server was selected yet or all servers
are down, returns default pool name only.
LB::server pool
Returns the pool of the currently selected member. If no server was selected yet or all servers are down,
returns default pool name.
LB::server addr
Returns the IP address of the currently selected pool member. If no server was selected yet or all servers
are down, returns null.
LB::server port
Returns the port of the currently selected pool member. If no server was selected yet or all servers are
down, returns null.
LB::server priority
Returns the priority of the currently selected pool member. If no server was selected yet or all servers
are down, returns null. If priority is not configured for the pool member, the default priority value of 1 is
returned.
LB::server ratio
Returns the ratio value of the currently selected pool member. If no server was selected yet or all
servers are down, returns null. If ratio is not configured for the pool member, the default ratio value of 1
is returned.
LB::server route_domainX
Returns the route domain ID of the currently selected pool member. If no server was selected yet or all
servers are down, returns null. Also returns null if the route domain is 0 (default).
LB::server weight
Returns the weighting of the currently selected pool member. If no server was selected yet or all servers
are down, returns null.
LB::server ripeness
Returns the ripeness information of the currently selected pool member. If no server was selected yet or
all servers are down, returns null.
VALID DURING
ANY_EVENT
EXAMPLES
when LB_SELECTED {
# Once pool member has been selected check if it's 10.0.0.25
if { [IP::addr [LB::server addr] equals 10.0.0.25] } {
# Reselect a new pool member within the pool
LB::reselect
# Retry the request to the new pool member
HTTP::retry
}
}
Do something if all servers are down in the default pool:
when HTTP_REQUEST {
# Check if the default pool has less than one active member
if { [active_members [LB::server pool]] < 1 } {
[do something]
}
}
Get the default pool of the VIP's name before it could have been changed by an iRule, HTTP class or other method:
when CLIENT_ACCEPTED {
# Save the name of the VIP's default pool
set default_pool [LB::server pool]
}
HINTS
SEE ALSO
Sample Code:
L
L
L
L
L
L
L
L
L