tarsier_90410
Aug 25, 2009Nimbostratus
way to list pools?
I am trying to find a way for an irule (9.x LTM) to query for a list of all pools on the system, but so far have not found a way to do so. Is this possible?
Hope this helps
CB
In general, you can get a list of configured pools using iControl. You can check to see if a pool exists by trying to assign it and handle an error for a pool not existing using catch (Click here). You could create a datagroup which contains all of the configured pool names and update that datagroup periodically using an iControl script. But again, it would help to know what you're trying to do and why.
Aaron
when HTTP_REQUEST {
set POOLS {
"http_pool"
"https_pool"
}
set response "BIGIP Pool Status - [clock format [clock seconds]]"
foreach { curpool } $POOLS {
pool $curpool
if { [active_members [LB::server pool] ] < 1 } {
set response "$response DOWN - $curpool
"
} else {
set response "$response UP - $curpool
"
}
}
set response "$response "
HTTP::respond 200 content $response "Content-Type" "text/html"
}
I think a few people have worked to create an iControl-based web dashboard. You do have iControl available--it's part of any LTM installation. You might try searching the iControl forum for examples.
Aaron
http://devcentral.f5.com/wiki/default.aspx/iRules/pool_status_page.html
CB
http://devcentral.f5.com/wiki/default.aspx/iControl/VirtualServerPoolMemberStatusAndControl.html
It's a client side application (using iControl) where any client can log into the LTM (with readme only account) and list the vips and pools and their status. It actually does more then list the virtuals and pools, but if they have a readme account they cannot do more then look at the status.
Another item that is close to what you are asking is based on Python
http://devcentral.f5.com/wiki/default.aspx/iControl/pyControl_nodeAlert.html
Hopefully this might help you obtain what you are looking for.
CB
So the class might look like this:
"apache_pool",
"iis_pool",
"coldfusion_pool",
"java_pool",
In v10 the iRule might look like this:
when HTTP_REQUEST {
set response "BIGIP Pool Status - [clock format [clock seconds]]"
if { [HTTP::uri] eq "/status" } {
foreach { selectedpool } [class get pooltest] {
set thispool [getfield $selectedpool " " 1]
if { [catch {
if { [active_members $thispool] < 1 } {
set response "$response DOWN - $thispool
"
} else {
set response "$response UP - $thispool
"
}
} errmsg ] } {
set response "$response INVALID POOL NAME - $thispool
"
}
}
set response "$response "
HTTP::respond 200 content $response "Content-Type" "text/html"
}
}
Kevin
!/bin/bash
b pool all name |awk '{ print "\"" $2 "\","}' >/var/class/testclass
tmsh show ltm pool |grep Pool: |awk '{ print "\"" $2 "\"," }' >/var/class/testclass
b load
Kevin
http://bigip-vip/status
when HTTP_REQUEST {
set response ""
set response "$response BigIP Server Pool Status"
set response "$response Server Pool Status"
set response "$response en"
set response "$response [clock format [clock seconds]]"
set response "$response 60"
if { [HTTP::uri] eq "/status" } {
foreach { selectedpool } [class get pooltest] {
set thispool [getfield $selectedpool " " 1]
if { [catch {
if { [active_members $thispool] < 1 } {
set response "$response "
set response "$response $thispool status"
set response "$response $thispool is DOWN"
set response "$response "
} else {
set response "$response "
set response "$response $thispool status"
set response "$response $thispool is UP"
set response "$response "
}
} errmsg ] } {
set response "$response "
set response "$response $thispool ERROR"
set response "$response Invalid pool name: $thispool"
set response "$response "
}
}
set response "$response "
set response "$response "
HTTP::respond 200 content $response "Content-Type" "text/xml"
}
}
Kevin