List commands to grab VIPs and Pool members

I would like to know how to do the foolowing please.

We have a 4 main nodes with out pools & are looking to retire 2 of them.

I wanted to know if there was a list command to so the number of current configured VIPs, the pool and most importantly the pool members. I’d like a list to pass to another department.

I not a programmer but happy to learn.

Thanks in advance

tmsh list ltm virtual all

Thanks for this,

Is there a way to get it into a more readable output?

IS there a way with the grep command to get just the destination, the pool & the pool members ?

Thanks

If you’re up for some Python you can use this:

!/usr/bin/env python3

from f5.bigip import ManagementRoot

mgmt = ManagementRoot('hostname', 'username', 'password')

 CSV header
print('Partition, VS Name, Pool Name, Pool Members')

for virtual in mgmt.tm.ltm.virtuals.get_collection():
     Does the virtual server have a pool assigned?
    if not getattr(virtual, 'pool', None):
         No - print virtual server name and move on
        print('{},{},,'.format(virtual.partition, virtual.name))
        continue

     Pool partition
    pool_part = virtual.pool.split('/')[1]
     Pool name
    pool_name = virtual.pool.split('/')[2]

    pool = mgmt.tm.ltm.pools.pool.load(
        partition=pool_part,
        name=pool_name,
    )

    members = pool.members_s.get_collection()

     Loop to output the results however you'd like
     Example is CSV with pool members delimited by semicolon

     Gather members in list - makes printing easier
    pool_members = []
    for member in members:
        pool_members.append(member.name)

     Print result
    print('{},{},{},{}'.format(
        virtual.partition,
        virtual.name,
        pool.name,
        ';'.join(pool_members),
    ))

That will give you more options for formatting. The example above spits out a CSV.