Forum Discussion
tarsier_90410
Nimbostratus
Aug 25, 2009way 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?
62 Replies
- The_Bhattman
Nimbostratus
Here is another variation of the same type of formula for v9.x
1. Create a file in the following path
/etc/cron.daily/pool_member_status_list.cron
which contains
!/bin/bash
b pool all member all | grep pool_ | awk '{print "\""$3"\""}' | sort > /var/class/pool_member_status_list.class
b load
exit 0
2. Change the permissions by entering
chmod +755 /etc/cron.daily/pool_member_status_list.cron
3. Create a external datagroup
Main >> Local Traffic >> iRules
Select Data Group List
Click create
enter name: pool_member_status_list
enter Type: External
Path / Filename: /var/class/pool_member_status_list.class
File Content: String
4.when HTTP_REQUEST { if { [HTTP::uri] eq "/status" } { set response "BIGIP Alpharetta Pool Member Status - \ <br> [clock format [clock seconds]]BIGIP Alpharetta Pool Member Status - [clock format [clock seconds]]\ StatusPool NameMemberPort" foreach { selectedpool } $::pool_member_status_list { 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" } SECOND CONDITIONAL STATEMENT END - Catch end error in an invalid named or non-existant pool } FOR LOOP END append response "" HTTP::respond 200 content $response "Content-Type" "text/html" } FIRST CONDITIONAL STATEMENT END }
Enjoy
CB - Glen_91715
Nimbostratus
Hi,
I've used the above iRule to create a page and add a few bits to it for some prettier reporting, but I have an issue with the way LB::status works.
I have a class file with the strings:"PoolNamed_One/10.0.0.1:any", "PoolNamed_Two/10.0.0.2:http", "PoolNamed_Three/10.0.0.3:webcache", "PoolNamed_Four/10.0.0.4:3389", ...
where this is obtained from:b pool all member | grep "POOL MEMBER" | awk '{print "\""$4"\","}'
However when using the following the Service ports that are in text do not get translated, i.e:scan [split $selectedpool "/"] %s%s poolname addrport scan [split $addrport ":"] %s%d addr port
will yield a empty/non-existant variable for $port except in the case of the "PoolNamed_Four/10.0.0.4:3389"
I can changed this to two strings (%s%s) to fill the variable $port, but this creates an error with LB::status
When it gets to "switch -glob [LB::status pool $poolname member $addr $port]" it doesn't match any with text for the Service name.
Else it logs with the following error:TCL error: Pool_Member_Status_List - can't read "port": no such variable
Thanks - hoolio
Cirrostratus
Could you list all of the services as their port numbers in the datagroup?
To configure LTM to not resolve the services to names, you can set a db key: b db bigpipe.displayservicenames false
You could also use just one scan command to parse the line:
scan "PoolNamed_One/10.0.0.1:0" {%[^/]/%[0-9.]:%d} pool_name ip port
Aaron - David_Larsen
Employee
CB,
What is the content supposed to look like in /var/class/pool_member_status_list.class. When i run the command "b pool all member all | grep pool_ | awk '{print "\""$3"\""}' | sort > /var/class/pool_member_status_list.class" I get nothing. When I run the 'b pool all member all' command I am getting output as follows and a 'grep pool_' would return no values:
POOL MEMBER 192.168.148.71:any active,unchecked
| session enabled priority 1 ratio 1
| (cur, max, limit, tot) = (0, 0, 0, 0)
| (pkts,bits) in = (0, 0), out = (0, 0)
| requests (total) = 0
If you let me know what content should be in pool_member_status_list.class I can figure out the commands to get it into the file.
thanks,
David - The_Bhattman
Nimbostratus
What LTM version are you using?
Also make sure you do a b load so that the file is properly loaded for the LTM to read in the datagroup.
CB - David_Larsen
Employee
9.4.6 and 9.4.7 - The_Bhattman
Nimbostratus
I haven't really tested that version of the LTM. However, have you triedb pool all | grep "POOL MEMBER" | awk '{print "\""$4"\","}'
CB - David_Larsen
Employee
Looks like that may have worked. The output I am getting now is: "webdav/192.168.148.176:http",
which is "poolname/ip:port", Is that correct for the class file? - The_Bhattman
Nimbostratus
Correct - David_Larsen
Employee
So with some help from an awk guru we have come up with the following to fix the :any issue. There are two different options. The easiest one is to implement the 'b db bigpipe.displayservicenames false' setting then use the following to create the file:b pool all |grep "POOL MEMBER" | awk '{sub(":any",":0",$4);print "\""$4"\","}' | sort >/var/class/pool_member_status_list.class
The other option is to use the following and develop a list of services that are used in your environment and convert them to port numbers as follows:b pool all |grep "POOL MEMBER" | sort |awk ' BEGIN{ list["http"]=80 list["https"]=443 list["any"]=0 list["ftp"]=21 list["ssh"]=23 } { x=split($4,ar,":") if(list[ar[2]] == "") list[ar[2]]=ar[2] print "\"" ar[1] ":" list[ar[2]] "\"," }' >/var/class/pool_member_status_list.class
Hope this helps some. David
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
