Forum Discussion
Hannes_Rapp
Nimbostratus
f5-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,
Joel_Breton
Jun 06, 2017Nimbostratus
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