Forum Discussion
Ed_Summers
Jan 19, 2017Nimbostratus
F5 Python SDK: How to get virtual server availability?
Due to my limited Python and SDK experience I am finding it difficult to easily obtain the availability state of a virtual server. Given a 'virtual' object, what is the best/easiest way to return the...
Rob_74473
Cirrus
This is brutal to work with!
partition = 'C25'
pool_name = 'temp_test'
pool = mgmt.tm.ltm.pools.pool.load(name=pool_name, partition=partition)
stats = pool.stats.load()
for item in stats.entries:
params = stats.entries.get(item).get('nestedStats').get('entries')
stuff = ['activeMemberCnt','curSessions','serverside.curConns','serverside.maxConns','serverside.totConns','status.enabledState','status.availabilityState']
for item in stuff:
for key in ('value','description'):
if key in params[item]:
print("'{}': {}".format(item,params[item][key]))
OUTPUT:
'activeMemberCnt': 1
'curSessions': 0
'serverside.curConns': 0
'serverside.maxConns': 0
'serverside.totConns': 0
'status.enabledState': enabled
'status.availabilityState': available
JRahm
Apr 30, 2018Admin
Have you tried the Stats module?
>>> from f5.utils.responses.handlers import Stats
>>> p = b.tm.ltm.pools.pool.load(name='testpool')
>>> ps = Stats(p.stats.load())
>>> ps.stat.curSessions['value']
0
>>> ps.stat.status_availabilityState['description']
u'offline'
>>> ps.stat.status_enabledState['description']
u'enabled'
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