rathid
Aug 03, 2017Nimbostratus
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 !!!!
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 !!!!
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;
Get the name of the pool(s) from selfLink: and their status from any of the following fields:
Get the (local) timestamp.
Sample output as below:selfLink: 'https://localhost/mgmt/tm/ltm/pool/stats?ver=11.6.1', selfLink: 'https://localhost/mgmt/tm/ltm/pool/~Common~HTTP-All/stats?ver=11.6.1', 'status.availabilityState': { description: 'available' }, 'status.enabledState': { description: 'enabled' }, 'status.statusReason': { description: 'The pool is available' }, selfLink: 'https://localhost/mgmt/tm/ltm/pool/~Common~HTTP-CentOS-vmnet2/stats?ver=11.6.1', 'status.availabilityState': { description: 'offline' }, 'status.enabledState': { description: 'enabled' }, 'status.statusReason': { description: 'The children pool member(s) are down' }, selfLink: 'https://localhost/mgmt/tm/ltm/pool/~Common~HTTP-CentOS-vmnet2-Node/stats?ver=11.6.1', 'status.availabilityState': { description: 'available' }, 'status.enabledState': { description: 'enabled' }, 'status.statusReason': { description: 'The pool is available' }, Mon Aug 7 10:15:44 NZST 2017
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)