Forum Discussion

corpkid_17486's avatar
corpkid_17486
Icon for Nimbostratus rankNimbostratus
Oct 24, 2012

PS script to display member states of all pools?

Does anyone know of or have a sample of a powershell script that will allow me to display the enabled/disabled state of ALL of the pools' members? We have many pools, and each has several members, and I'd like to be able to quickly see what's up and what's down.

 

I've searched the devcentral and don't see anything quite like this (I can report NUMBER of up/down (e.g. 2/3 or 0/3, etc.)) but I want to actually have the pool names listed and then the member's statuses under each.

 

 

MANY THANKS!

 

Dominic

 

3 Replies

  • I used this as a model for what I needed, similar to your needs:

     

     

    https://devcentral.f5.com/wiki/iControl.PowerShellPoolMemberAvailability.ashx

     

  • Thanks Tim! I'm actually messing with that one right now. I'm trying to figure out how to enumerate all the pools and members automatically based off that script.

     

     

    Guess I'll have to keep messing around (pretty new to scripting coming from the Cisco world).
  • All of the methods take arrays as parameters. So, let's say you want to get the object status for all members of all pools, you could do something like this:

     

    $pool_list = (Get-F5.iControl).LocalLBPool.get_list();

     

    $MemberObjectStatusAofA = (Get-F5.iControl).LocalLBPoolMember.get_object_status($pool_list);

     

    The returned value in $MemberObjectAofA will be a 2-d Array. The first dimension associating with the pools. The second dimension would be the members for that given pool.

     

    for($i=0; $i -lt $pool_list.Length; $i++)

     

    {

     

    $pool = $pool_list[$i];

     

    $MemberObjectStatusA = $MemberObjectStatusAofA[$i]

     

    Write-Host "POOL '$pool':";

     

    for($j=0; $j -lt $MemberObjectStatusA.Length; $j++)

     

    {

     

    $MemberObjectStatus = $MemberObjectStatusA[$j];

     

    $member = $MemberObjectStatus.member;

     

    $member_ip = $member.address;

     

    $member_port = $member.port

     

    $ObjectStatus = $MemberObjectStatus.object_status;

     

    $availability = $ObjectStatus.availability_status;

     

    $enabled = $ObjectStatus.enabled_status;

     

    $description = $ObjectStatus.description;

     

     

    Write-Host " + ${member_ip}:${member_port} -> $availability, $enabled, $description";

     

    }

     

    }

     

    Warning, this isn't tested, but it should be close...

     

    Hope this helps!

     

    -Joe