Getting started with the python SDK part 3: working with statistics
Published Jun 07, 2018
Version 1.0Was this article helpful?
I'm posting this here to hopefully help someone else out on how to iterate through the pool member stats. The F5 Python SDK: How to get virtual server availability article was useful in figuring this out.
 
This executes much slower than I would like it to, but at least I can get to the data now.
 
I was after the number of server side connections, the availability state and enabled state values of each pool member.
 
load the pool
p1 = mgmt.tm.ltm.pools.pool.load(name='TEST-POOL', partition='Common')
get the pool members
members = p1.members_s.get_collection()
Iterate through each pool member
for member in members:
load the pool member and stats for the member
pm = p1.members_s.members.load(name=member.name, partition="Common")
pmstats = pm.stats.load()
Get the selfLink to be used later.
for k in pmstats.entries:
selflink = k
statentries will contain a list with the correct data
statentries = pmstats.entries.get(selflink).get('nestedStats').get('entries')
for i in statentries:
Numbers entries contain information in 'value'
Text entries contain information in 'description'
if i == 'serverside.curConns':
connections = statentries[i].get('value')
if i == 'status.availabilityState':
availability = statentries[i].get('description')
if i == 'status.enabledState':
enabled = statentries[i].get('description')
print("{}, {:3}, {}, {}".format(member.name, connections, availability, enabled))