Forum Discussion

Thanushka_Wije1's avatar
Icon for Nimbostratus rankNimbostratus
Jun 19, 2019

Automated F5 LTM pre and post checks


I'm trying to automate F5 check using F5sdk, unfortunately I think that sdk retrieve virtual server details via .conf file.

Reason I'm telling that is from sdk I'm unable to retrieve F5 Availability.

Below is the script I'm using to print virtual server names,

from f5.bigip import ManagementRoot

# Connect to the BigIP
hostname = input("Please Enter F5 IP: ")
mgmt = ManagementRoot(hostname, "admin", "admin")

# Get a list of all pools on the BigIP and print their names and Availability

virtuals =

for virtuals in virtuals:
   print(, virtuals.partition)

Anyone know how can I get availability status using F5 sdk ?

4 Replies

  • Hello Thanushka.

    Try this ->

    devices =
    for device in devices:
    	print("Device: {}".format(
    	print("State: {}".format(device.failoverState))


    Device: bigip1.mydomain.local
    State: active
    Device: bigip2.mydomain.local
    State: standby



  • Hi Dario


    Thanks for the responses, but this will return device HA status not the virtual server (Availability). status..



    • Dario_Garrido's avatar
      Icon for MVP rankMVP

      The availability of a virtual server resides in the stats

      from f5.bigip import ManagementRoot
      from f5.utils.responses.handlers import Stats
      # ----------------------------------------------------------
      session = ManagementRoot("F5_mgmt_IP","username","password",token=True)
      virtual ='testVS')
      virtualstats = Stats(virtual.stats.load())
      for key, value in virtualstats.stat.items():
          if value.get('description') != None:
              print("{}: {}".format(key, value.get('description')))
          elif value.get('value') != None:
              print("{}: {}".format(key, value.get('value')))
      # ----------------------------------------------------------



  • JG's avatar
    Icon for Cumulonimbus rankCumulonimbus
    for virtual in virtuals:
        if hasattr(virtual, 'subPath'):
            subp = virtual.subPath
            subp = ""
        if (subp != ""):
            print("Name: '%s' AvailabilityState: '%s'" % (, get_vs_state(, subp)))
            print("Name: '%s' AvailabilityState: '%s'" % (, get_vs_state(, "")))