Forum Discussion
How to use rest api to get the "Availability" attribute value about virtual server\pool\pool member
When we see a virtual server ,or a pool,or a member in a pool in the F5 console,We can see the "Availability" attribute.But when I use the restful api to query the Virtual Servers' info we can not get the value of Availability.Can you tell me we how can we to get the value of "Availability" attribute about virtual server,pool and pool member.Thanks a lot.
2 Replies
- Ed_Summers
Nimbostratus
This is available from the virtual service's statistics. Accessing statistics may have changed since I last used it, but I use a stats handler that was added per one of my questions a while back.
Here's some sample code to at least get you a value. You may find a better way to get it but this should at least get you a result. The stat you want is status_availabilityState.
from f5.bigip import ManagementRoot from f5.utils.responses.handlers import Stats from pprint import pprint mgmt = ManagementRoot(host_ip, username, password, token=True) my_virtual = mgmt.tm.ltm.virtuals.virtual.load(partition='Common', name='my_virtual') my_pool = mgmt.tm.ltm.pools.pool.load(partition='Common', name='my_pool') v_stats = Stats(my_virtual.stats.load()) p_stats = Stats(my_pool.stats.load()) pprint(v_stats.stat) pprint(p_stats.stat) print(v_stats.stat.status_availabilityState) print(p_stats.stat.status_availabilityState)
Of course make necessary changes for your environment (host_ip, user, password, etc..).
- Hygor
Nimbostratus
Maybe the curl examples bellow may help you
- curl -sku admin:
- curl -sku admin:
- curl -sku admin:
And you can see the availability checking the status.availabilityState entry:
- 'status.availabilityState': { description: 'offline' }
- 'status.availabilityState': { description: 'available' }
- 'status.availabilityState': { description: 'unknown' }
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