Forum Discussion
F5 Python SDK: How to get virtual server availability?
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
- DMA_95966Apr 30, 2018Nimbostratus
Thanks a lot Rob , let me test it as well ..will update you on this..
- JRahmApr 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'
- DMA_95966May 01, 2018Nimbostratus
Hi Jason ,
I am going to test this and update the thread shortly .
- DMA_95966May 01, 2018Nimbostratus
Hi Jason ,
I tested this for VIP stats and its not working ...
vis = vip.tm.ltm.virtuals.get_collection()
vi = vis.virtual.load()
ps = Stats(vi.stats.load())
error :
vi = vis.virtual.load()
AttributeError: 'list' object has no attribute 'virtual'
Can you please help me on this .. i know in earlier posts it was mentioned about F5 versions... just checking if that has been fixed ?
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