Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

F5-SDK querying specific stats with the Stats module




I am running a python script which returns the Name and the Availability State of virtual servers, pools and their respective pool members.


After adding the nested loop part for the pool members, the script usually takes around 40 seconds to run and causes around 2x-3x CPU usage increase on an LTM that has ~ 55 virtual servers and ~200 nodes and we cannot risk running this on production LTMs, where the node count is 5x higher.


My guess would be that this happens because of me pulling all of the virtual server/pool/member stats via the Stats module load() method when I technically need only the status.availabilityState?


The code:


from f5.bigip import ManagementRoot from f5.utils.responses.handlers import Stats #Authentication mgmt = ManagementRoot("***", "***", "***") #Print tmos version file = open('Availability.txt', 'w') TMOS = "TMOS version - " + mgmt.tmos_version print(TMOS) file.write(TMOS + '\n') #Get a collection of all Virtual Servers, pools all_vips = all_pools = #Loop over all virtual servers and fetch name and availability for vip in all_vips: vip_stats = Stats(vip.stats.load()) State = vip_stats.stat.status_availabilityState['description'] file.write( + " - " + State + '\n') #Loop over all pools for pool in all_pools: pool_stats = Stats(pool.stats.load()) State = pool_stats.stat.status_availabilityState['description'] file.write( + " - " + State + '\n') #Loop over all pool members for member in pool.members_s.get_collection(): member_stats = Stats(member.stats.load()) State = member_stats.stat.status_availabilityState['description'] file.write( + " - " + State + '\n')


Is there a better way to do this? In my case, would it be possible to query just the Name and the Availability from the Stats so the LTM doesn't have to spit out all of the object data?


Or any other suggestions on how to accomplish this with a totally different logic or method are also welcome.




Thank you!