Forum Discussion
How to use rest api to get the "Availability" attribute value of virtual server member without knowing its pool name
- Mar 30, 2021
Hello Kartal.
To get the state of one member only using their IP, you need to use 'jq'.
# curl -sku admin https://localhost/mgmt/tm/ltm/pool?expandSubcollections=true | jq '.items[] | select(.membersReference.items[].address == "10.100.40.112") | .membersReference.items[].state' "down"
In my case, I have one pool called P-WEB112_80 which has one member node with IP 10.100.40.112.
# tmsh list ltm pool P-WEB112_80 ltm pool P-WEB112_80 { members { N-WEB112:http { address 10.100.40.112 session monitor-enabled state down } } monitor gateway_icmp }
This solves what you are requesting, but take into account that if this member is applied to more than one pool, you will see in the output "up" "up" or "down" "down" without any information about the pool, so in this case, you could use something like this.
# curl -sku admin https://localhost/mgmt/tm/ltm/pool?expandSubcollections=true | jq '.items[] | select(.membersReference.items[].address == "10.100.40.111") | .name, .membersReference.items[].state' "P-REPO_8080" "up" "P-WEB111_80" "up"
If you need to collect any other field (like 'session'), you can extend the previous expression accordingly.
Regards,
Dario.
Hi there
You believe you have to fetch all pools including subCollections and filter the result
Example:
curl -sku admin:admin https://bigip-01.domain.com/mgmt/tm/ltm/pool?expandSubcollections=true
Worth noting:
- There are guides on filtering using $select but I've yet to encounter one that filters subcollections. You can have a look at this article or check out the documentation for OData which F5 used for this API implementation (both linked inline in this sentence). I am not sure if they have full support for OData though so keep that in mind.
- The call to the REST API above is very heavy so if you might want to avoid it if doing it often or to a device with many pools without using some kind of caching proxy.
Kind regards,
Patrik
Recent Discussions
Related Content
* 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