Forum Discussion
DevBabu_124276
Nimbostratus
Mar 21, 2016How do I get pool stats using f5 sdk
How do I get Pool stats using f5 sdk.
Hannes_Rapp_162
Nacreous
Jan 18, 2017f5-sdk 2.2.0 ; Python v3.4.3 ; BigIP 11.5.4
from f5.bigip import ManagementRoot
def get_pool_stats(p_name, p_partition):
"""Return all pool stats object (dict of dicts)"""
pool = API_ROOT.tm.ltm.pools.pool.load(name=p_name, partition=p_partition)
return pool.stats.load()
API_ROOT = ManagementRoot("bip-01", "admin", "admin")
POOL_STATS = get_pool_stats('pool_somepool', 'Common')
EXAMPLES OF USE:
1. Print all stats (complete dictionary of dictionaries, inclusive of irrelevant bulk)
print(POOL_STATS.raw)
2. Print all stats (entries dictionary - all key/value pairs of actual stats)
print(POOL_STATS.entries)
3. Print a specific extraction from entries dictionary
print(POOL_STATS.entries.get('curSessions'))
4. Print a specific extraction from entries dictionary (just value of a specific key)
print(POOL_STATS.entries.get('curSessions')['value'])
Regards,
- amintej_297711Jan 18, 2017
Nimbostratus
Thank you! I tested and it worked.
- Joel_BretonJun 06, 2017
Nimbostratus
I'm testing the example above and I'm getting None for 3 and 'NoneType' object is not subscriptable for 4.
I'm running Python 3.6.1, BIG-IP 12.1.2 and f5-sdk 2.3.3
- Joel_BretonJun 07, 2017
Nimbostratus
Found this thread that mentions the different format for version BIG-IP version 12
F5 Python SDK: How to get virtual server availability
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