Forum Discussion
Satoshi_Toyosa1
Apr 16, 2018Employee
Call two endpoints:
/mgmt/tm/ltm/pool/
and /mgmt/tm/ltm/monitor///stats
.
First, get the pool member and monitor names. Because the references to the pool members are subcollections, you need to add the
expandSubcollections=true
query string to expand the references (for more information, see pp. 31-34 in iControl® REST API User Guide
Version 12.1😞 e.g.,
curl -sku admin:admin https://localhost/mgmt/tm/ltm/pool/vmnet2-80?\expandSubcollections=true
The call yields (abridged for readability sake):
{
...
"fullPath": "vmnet2-80",
...
"membersReference": {
"isSubcollection": true,
"items": [
{
"address": "10.200.20.137",
...
"fullPath": "/Common/CentOS-vmnet2:80",
...
"address": "10.200.20.80",
...
"fullPath": "/Common/Fedora-vmnet2:80",
...
"monitor": "min 1 of { /Common/gateway_icmp /Common/http }",
....
}
In this example, the pool
vmnet2-80
has two members: 10.200.20.137:80
and 10.200.20.80:80
. Two monitors are attached to the pool: gateway_icmp
and http
, and the availability requirement is "at least ... 1 health monitor(s)".
Then, get the stats from the two monitors. e.g.,
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/gateway-icmp/gateway_icmp/stats
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/http/http/stats
Note that you need to specify the monitor type (e.g., gateway-icmp) and monitor (gateway_icmp) just like the equivalent
tmsh
command. The call yields (abridged):
...
LTM::Monitor /Common/gateway_icmp
-----------------------------------
Destination: 10.200.20.80:0
State time: up for 0hr:49mins:44sec <<< This one is UP
| Last error: N/A @2018.04.16 11:34:28
Destination: 10.200.20.137:0
State time: up for 1hr:22mins:46sec <<< ditto
| Last error: N/A @2018.04.16 11:01:26
...
LTM::Monitor /Common/http
---------------------------
Destination: 10.200.20.80:80
State time: down for 0hr:41mins:52sec <<< This one is DOWN.
| Last error: Unable to connect
No successful responses received before deadline. @2018.04.16 11:45:28
Destination: 10.200.20.137:80
State time: down for 0hr:44mins:25sec <<< ditto
| Last error: Unable to connect
No successful responses received before deadline. @2018.04.16 11:42:55
As you can see, the output is exactly same as
tmsh show ltm monitor
. Because the iControl REST puts all the tmsh output in one blob to the apiAnonymous
field after converting '\n' (LF) to the literal '\n' (backslash and n), you may want to parse it using sed
or something similar: e.g.,
curl -sku admin:admin https://localhost/mgmt/tm/ltm/monitor/http/http/stats | python -m json.tool | grep apiAnonymous | sed 's/\\n/\n/g'
Because there are multiple queries and field look-ups involved, you may want to write a script. You have a number of choices: bash (call curl), PowerShell, Ansible or F5 Python SDK.