Forum Discussion

rathid's avatar
rathid
Icon for Nimbostratus rankNimbostratus
Aug 03, 2017

querying Pool member stats

Hi all,

 

do we have a python script which can call each pool member availibilty stat with time stamp and current connect. need pure python code. any help is appreciated !!!!

 

2 Replies

  • Although the method below is not a Python code, this is how you can code.

      curl -sku admin: https:///mgmt/tm/ltm/pool/stats | \ python -m json.tool | \ egrep 'selfLink\:|status\.' && date 

    That is;

    1. Connect to the BIG-IP via https using Basic Authentication.
    2. GET /mgmt/tm/ltm/pool/stats. To get a specific pool, /mgmt/tm/ltm/pool/.
    3. Parse the obtained JSON object.
    4. Get the name of the pool(s) from selfLink: and their status from any of the following fields:

  • Rathid - I saw your post in my other topic. Sorry for the delay - it has been a very busy week.

     

    Below is some sample code to pull availability status and current connections for members of a particular pool. With a bit of basic knowledge on the SDK you should be able to expand this to get other statistics as needed. Of course, replace any text in <> below with actual values for your environment. Hopefully this provides enough information to build upon for your specific need.

     

    from f5.bigip import ManagementRoot
    from f5.utils.responses.handlers import Stats
    
    
    host_ip = 
    username = 
    password = 
    
     Use token auth if BIG-IP uses an external authentication service
    mgmt = ManagementRoot(host_ip, username, password, token=True)
    
    my_pool = mgmt.tm.ltm.pools.pool.load(partition='Common', name='')
    
    my_pool_mbrs = my_pool.members_s.get_collection()
    
    for pool_mbr in my_pool_mbrs:
        mbr_stats = Stats(pool_mbr.stats.load())
        print(mbr_stats.stat.status_availabilityState)
        print(mbr_stats.stat.serverside_curConns)