Difference between revisions of "F5 sdk"
Jump to navigation
Jump to search
Line 13: | Line 13: | ||
https://community.f5.com/t5/technical-forum/how-do-i-get-pool-stats-using-f5-sdk/td-p/86748 | https://community.f5.com/t5/technical-forum/how-do-i-get-pool-stats-using-f5-sdk/td-p/86748 | ||
+ | |||
+ | |||
+ | # Code Examples | ||
+ | |||
+ | ``` | ||
+ | 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 = mgmt.tm.ltm.virtuals.get_collection() | ||
+ | all_pools = mgmt.tm.ltm.pools.get_collection() | ||
+ | |||
+ | #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(vip.name + " - " + 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(pool.name + " - " + 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(member.name + " - " + State + '\n') | ||
+ | ``` |
Revision as of 20:53, 3 August 2023
https://community.f5.com/t5/technical-forum/get-list-of-monitors-through-sdk/td-p/120088
Monitors
https://community.f5.com/t5/technical-forum/using-the-python-sdk-for-monitors/td-p/231801
Stats
https://community.f5.com/t5/technical-forum/how-do-i-get-pool-stats-using-f5-sdk/td-p/86748
Code Examples
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 = mgmt.tm.ltm.virtuals.get_collection() all_pools = mgmt.tm.ltm.pools.get_collection() #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(vip.name + " - " + 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(pool.name + " - " + 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(member.name + " - " + State + '\n')