Forum Discussion
renchao_312407
Nimbostratus
Aug 08, 2017How 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 ge...
Ed_Summers
Nimbostratus
Aug 08, 2017This 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..).
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
