Hi!
Sorry for the late reply, I've been a bit busy. 🙂
I guess the iRule did a bit more than you asked, and might seem overwhelming at first. I wrote another one, more aligned to the scope of your question.
If you create a data group list and add ie. 192.168.0.0/16 as a network for internal requests and/or your Office external IP you can show the status of any pool with this iRule.
So steps to implement it:
- Create the data group list called Office_IPs (or rename it according to your liking)
- Create iRule (see code below).
- Create a virtual server with an HTTP profile
- Assign the iRule to the virtual server
How to use it:
- Open a browser.
- Navigate to the virtual server and add a query string:
If the pool exists you'll get the answer in XML
session_disabled
up
Otherwise you'll get this:
The pool /Partition/Mypool-443_pool does not exist.
Please note that you have to add the partition when using the pool name. If you don't use partitions and store everything in /Common you could always rewrite the rule to use /Common as default and skip the partition part.
The actual iRule:
when CLIENT_ACCEPTED {
Check if the request is internal or not.
Office IPs are a data group list with the IPs you want to allow.
if { [class match [IP::remote_addr] equals Office_IPs] } {
set internal 1
} else {
set internal 0
}
}
when HTTP_REQUEST {
if { $internal eq 1 } {
Save the content of the query string into selectedpool
set selectedpool [URI::query [HTTP::uri] showstatus]
Check if the showstatus query parameter exists or not
if { $selectedpool ne "" } {
Decode the parameter into readable format
set selectedpool [URI::decode $selectedpool]
Check if the pool exists, otherwise reply with a message
if { [catch { set mbrs [members -list $selectedpool] } ] } {
The pool did not exist
HTTP::respond 200 content "The pool $selectedpool does not exist." Content-Type "text/plain" Connection "Close"
} else {
The pool existed
Prepare the xml content
set xml "\n"
Get the status for each member of the pool
foreach mbr $mbrs {
set mbrlist [split $mbr " "]
set memberip [lindex $mbrlist 0]
set memberport [lindex $mbrlist 1]
set status [LB::status pool $selectedpool member $memberip $memberport]
Append the member information into the file
set xml "$xml\t$status\n"
}
Add the XML footer
set xml "$xml"
Reply with the data
HTTP::respond 200 content $xml Content-Type "text/plain" Connection "Close"
}
}
}
}