Forum Discussion

msandeep_311359's avatar
msandeep_311359
Icon for Nimbostratus rankNimbostratus
Mar 02, 2017

fetch connection statistics of pool member from f5 python sdk

is there a f5 python sdk collection/resource to get the connection statistics of pool member? which class we need to use to fetch statistics of pool member

 

3 Replies

  • @msandeep

     

    I and you have the same problem,I don't find the python class in github.

     

    Now you find it?

     

    Thanks D.Luo

     

  • Please refer to F5 Python SDK Documentation for the iControl REST Python interface documentation.

    The sample code below is not optimal but does something similar to tmsh show ltm pool members.

     

    from f5.bigip import ManagementRoot
    
    mgmt = ManagementRoot('192.168.0.10', 'admin', 'admin')
    pool = mgmt.tm.ltm.pools.pool.load(name='CentOS-all-80', partition='Common')
    
    members = pool.members_s.get_collection()
    for member in members:
        stat = member.stats.load().raw
        url1 = stat['selfLink']
        url_nover = url1.split('?')[0]          remove the 'ver=x.x.x'
        url_dirs = url_nover.split('/')         break into path segments
        url_dirs.insert(-2, url_dirs[-2])       add extra object
        url2 = '/'.join(url_dirs)
        print url2
        nestedStatsEntries = stat['entries'][url2]['nestedStats']['entries']
        for key, value in nestedStatsEntries.iteritems():
            print '\t{} = {}'.format(key, value)