Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

How do I get pool stats using f5 sdk

How do I get Pool stats using f5 sdk.

https://bigip/mgmt/tm/ltm/pool/~Common~test_pool/stats

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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,

1
Comments on this Answer
Comment made 18-Jan-2017 by amintej 552

Thank you! I tested and it worked.

0
Comment made 06-Jun-2017 by Joel Breton 213

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

0
Comment made 07-Jun-2017 by Joel Breton 213

Found this thread that mentions the different format for version BIG-IP version 12

F5 Python SDK: How to get virtual server availability

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

hello,

you can use curl to get the pool stats :

curl -k -X GET https://bigip/mgmt/tm/ltm/pool/~Common~test_pool/stats

Here what I get on my lab :

{"kind":"tm:ltm:pool:poolstats","generation":1,"selfLink":"https://localhost/mgmt/tm/ltm/pool/~Common~aaa-pool/stats?ver=11.6.0","entries":{"activeMemberCnt":{"value":0},"connqAll.ageEdm":{"value":0},"connqAll.ageEma":{"value":0},"connqAll.ageHead":{"value":0},"connqAll.ageMax":{"value":0},"connqAll.depth":{"value":0},"connqAll.serviced":{"value":0},"connq.ageEdm":{"value":0},"connq.ageEma":{"value":0},"connq.ageHead":{"value":0},"connq.ageMax":{"value":0},"connq.depth":{"value":0},"connq.serviced":{"value":0},"curSessions":{"value":0},"minActiveMembers":{"value":0},"monitorRule":{"description":"none"},"tmName":{"description":"/Common/aaa-ad-basile-pool"},"serverside.bitsIn":{"value":0},"serverside.bitsOut":{"value":0},"serverside.curConns":{"value":0},"serverside.maxConns":{"value":0},"serverside.pktsIn":{"value":0},"serverside.pktsOut":{"value":0},"serverside.totConns":{"value":0},"status.availabilityState":{"description":"unknown"},"status.enabledState":{"description":"enabled"},"status.statusReason":{"description":"The children pool member(s) either don't have service checking enabled, or service check results are not available yet"},"totRequests":{"value":0}}}

0