Forum Discussion

msaud's avatar
msaud
Icon for Cirrus rankCirrus
Jan 22, 2024

Want  to pull all of the VS's and pools  members (nodes) in a table

Hi Team,

I wanted to pull all of the VS's and pools  members (nodes) in a table, Can you please share working script.

Device: i5600

 

Thanks in advance!

  • There is a nice solution in the codeshare that will do reporting for you called BIG-IP Report. You could also use chatGPT to generate a script for you as that functionality is fairly well known and tested. For example, in python from chatGPT (this logic is sound but you might need to massage the data gathering a little bit, I did not test it):

    import requests
    import csv
    from requests.auth import HTTPBasicAuth
    
    # BIG-IP API credentials and address
    bigip_address = 'https://<your-big-ip-address>'
    username = '<your-username>'
    password = '<your-password>'
    
    # Disable warnings for self-signed certificates
    requests.packages.urllib3.disable_warnings()
    
    # Function to get data from BIG-IP
    def get_bigip_data(url):
        response = requests.get(
            url,
            auth=HTTPBasicAuth(username, password),
            verify=False
        )
        if response.status_code == 200:
            return response.json()
        else:
            print(f"Error fetching data: {response.status_code}")
            return None
    
    # Fetch Virtual Servers
    vs_data = get_bigip_data(f'{bigip_address}/mgmt/tm/ltm/virtual')
    
    # Initialize CSV data
    csv_data = [['Virtual Server', 'Pool', 'Pool Members']]
    
    # Process each Virtual Server
    for vs in vs_data.get('items', []):
        pool_name = vs.get('pool', '').split('/')[-1]
        pool_members = []
    
        # Fetch Pool Members if Pool exists
        if pool_name:
            pool_members_data = get_bigip_data(f'{bigip_address}/mgmt/tm/ltm/pool/{pool_name}/members')
            pool_members = [member['name'] for member in pool_members_data.get('items', [])]
    
        # Add row to CSV data
        csv_data.append([vs['name'], pool_name, ', '.join(pool_members)])
    
    # Write data to CSV
    with open('bigip_virtual_servers.csv', 'w', newline='') as file:
        writer = csv.writer(file)
        writer.writerows(csv_data)
    
    print("Data exported to bigip_virtual_servers.csv")
    

     

  • Using tmsh from the CLI you can do this to obtain the data. Then you'll have to format it into a table using whatever technique you prefer.

    tmsh list ltm pool members ; tmsh list ltm virtual destination