Forum Discussion

Eugene_Reznik_1's avatar
Eugene_Reznik_1
Icon for Nimbostratus rankNimbostratus
Oct 24, 2013

Powershell iControl error getting pool member statistics

I am getting the error below when I am trying to get pool member statistics. I am not sure what i am doing wrong, as the error is not very descriptive.

Does anyone have any insight of why this would not be working?

  $address = New-Object -TypeName iControl.CommonAddressPort;
  $address.address =$member_name;
  $address.port = $member_port;
  $state = New-Object -TypeName "iControl.CommonEnabledState" 
  $state = "STATE_DISABLED";
  (Get-F5.iControl).LocalLBPool.set_member_monitor_state( (, $pool_name), $address,(,$state));
  Write-Host "Waiting for current connections to drop to zero..." -ForegroundColor Yellow;

  **$MemberStatisticsA = (Get-F5.iControl).LocalLBPool.get_member_statistics( ($pool_name), $address);**
  Exception calling "get_member_statistics" with "2" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/Pool
::get_member_statistics()
Exception: Common::OperationFailed
    primary_error_code   : 16908336 (0x01020030)
    secondary_error_code : 0
    error_string         : "
At line:1 char:73
+ $MemberStatisticsA = (Get-F5.iControl).LocalLBPool.get_member_statistics <<<< ( ($pool_name), $address);
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

Thanks,

4 Replies

  • Hi Ereznik, it seems that you are struggling exactly with the same things as I do :-) I have posted question with the same error here in my topic, trying to solve that but still get this error: 16908336 (0x01020030) ...THIS LINKED CONTENT HAS BEEN DELETED...
  • I was able to figure out the issue. It had to do with using a none Common partition.

     

    This code works

     

      (Get-F5.iControl).ManagementPartition.set_active_partition( (,"PARTITION_NAME") )
      Write-Host (Get-F5.iControl).ManagementPartition.get_active_partition() -ForegroundColor Yellow
      $address = New-Object -TypeName iControl.CommonAddressPort;
      $address.address ="/PARTITION_NAME/SERVE_RNAME"
      $address.port = 666;
    
      $state = New-Object -TypeName "iControl.CommonEnabledState" 
      $state = "STATE_DISABLED";
    
    
     (Get-F5.iControl).LocalLBPool.set_member_monitor_state( (, $pool_name), $address,(,$state));
    
      Write-Host "Waiting for current connections to drop to zero..." -ForegroundColor Yellow;
    
    
      $MemberStatisticsA = (Get-F5.iControl).LocalLBPool.get_member_statistics( ("/PARTITION_NAME/POOL_NAME"), $address);
          $MemberStatisticEntry = $MemberStatisticsA[0].statistics[0];
        $Statistics = $MemberStatisticEntry.statistics;
        foreach ($Statistic in $Statistics)
        {
          $type = $Statistic.type;
          $value = $Statistic.value;
    
          if ( $type -eq "STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS" )
          {
             just use the low value.  Odds are there aren't over 2^32 current connections.
             If your site is this big, you'll have to convert this to a 64 bit number.
            $cur_connections = $value.low;
            Write-Host "Current Connections: $cur_connections"
          }
        }
  • The get_member_statistics method looks like this:

     

    LocalLB.Pool.MemberStatistics [][]
    LocalLB.Pool.get_member_statistics(
      String [] pool_names,
      Common.AddressPort [][] members
    );

    the first parameter in your call looks good, but for the second you are just passing in a Common.AddressPort literal (not a 2-d array). The reason for the arrays is so you can pass in multiple pools with different members for each pool request. The first dimension of the 2-d array is for the associated pool in the first parameter and the 2nd dimension holds the list of members for that given pool. Think of it like requesting this

     

    Pool1
      member1
      member2
      member3
    Pool2
      member4
      member5

    The first parameter would be a 1-d array containing two pool names of "Pool1" and "Pool2".

     

    The second parameter would contain a 2-d array looking something like this

     

    pool_members[0] = "Pool1"
    pool_members[1] = "Pool2"
    members[0][0] = member1
    members[0][1] = member2
    members[0][2] = member3
    members[1][0] = member4
    members[1][1] = member5

    So, getting back to your code. If you just have a single pool with a single member for that pool, it would look like this

     

    pool_names[0] = $pool_name;
    members[0][0] = $address;

    Now, here's how you would do it in PowerShell

     

     1-d array of pool names
    $poolnamesA = @($pool_name);
    
     2-d array of Common.AddressPorts
    $address = New-Object -TypeName iControl.CommonAddressPort;
    $address.address =$member_name;
    $address.port = $member_port;
    $membersA = @($address);
    $membersAofA = @($membersA);
    
    $MemberStatisticsAofA = (Get-F5.iControl).LocalLBPool.get_member_statistics(
      $poolnamesA, $membersAofA);
     Loop over pools.  There will only be one here
    foreach($MemberStatisticsA in $MemberStatisticsAofA) {
       Loop over each member for current pool (again, only one here)
      foreach($MemberStatistics in $MemberStatisticsA) {
         print out results
      }
    }

    This code isn't tested, so hopefully it runs, but it should get you pointed in the right direction...

     

    -Joe

     

  • You should use partionName before pool and node name. Not to get that error.

    static String serverIP = "";
    static String user = "";
    static String pass = "";
    
    static String partionName = "";
    static String poolName = "";
    static String nodeName = "";
    
    public static Interfaces interfaces = null;
    
    public static void main(String[] args) {
        try {
            String[] poolNameArray = new String[1];
            poolNameArray [0] = "/"+ partionName + "/"+ poolName;
            CommonAddressPort[][] addressPortOutput = new CommonAddressPort[1][1];
            CommonAddressPort commonAddressPort = new CommonAddressPort("/"+ partionName + "/"+ nodeName, 80);
            addressPortOutput[0][0] = commonAddressPort;
    
            Object o = getConnection().getLocalLBPool().get_member_statistics(poolNameArray, addressPortOutput);
            o.equals(null);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    public static Interfaces getConnection() throws Exception {
        if (interfaces == null){
            interfaces = new Interfaces();
            if (!interfaces.initialize(serverIP, 443, user, pass))
                throw new Exception("Could not connect!");
        }
        return interfaces;
    }