Does anyone know how to get the number of tcp connections on a pool member using iControl in java?
i’m lost in the API trying to find out
Does anyone know how to get the number of tcp connections on a pool member using iControl in java?
i’m lost in the API trying to find out
use LocalLB.PoolMember.get_statistics() for the given pool member and look through the returned statistics for the STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS statistic.
I wrote a tech tip on graceful server shutdowns that query the current connections for a specific pool member. It’s written in PowerShell but you should be able to extract the logic for use in Java.
http://devcentral.f5.com/Default.aspx?tabid=63&articleType=ArticleView&articleId=254
Look for the Disable-Member code snippet.
Hope this helps…
-Joe
hey Joe i’m kinda stuck trying to convert this line in java
$MemberStatisticsA = (Get-F5.iControl).LocalLBPoolMember.get_statistics( (, $pool_name), $MemberDefAofA);
I tried to use:
iControl.LocalLBPoolMember lb;
but when I tested lb.get_statistics, it does not exist.
I tried using this one here:
iControl.LocalLBPoolMemberMemberStatistics ms;
ms.getStatistics();
but that method does not have any input parameters
and it returns a LocalLBPoolMemberMemberStatisticEntry[] array
The lb.get_statistics() method should exist. Did you pass in the correct parameters (a 1-D array of pool names, and a 2-D array of pool members for each pool in the first parameter)?
Your second example is referencing a structure (LocalLBPoolMemberMemberStatistics). The getStatistics() is a local member accessor. The structure is what is returned from the get_statsitics() method.
I’ll whip you up some java code in the morning.
-Joe
Oops, forgot that Axis1 has no direct conversion from the PortType class. You’ll need to create local variables for the *PortType classes to make the method calls.
Here’s some code that will take a bigip, it’s credentials, as well as a pool name and then enumerate through all pool members for their statistics and print it all to the console.
public void GetPoolMemberStats(String bigip, String username, String password, String pool_name)
throws RemoteException, java.lang.Exception {
iControl.Interfaces interfaces = new iControl.Interfaces();
if (interfaces.initialize(bigip, (long)443, username, password) ) {
String [] pool_list = new String[] {pool_name};
iControl.LocalLBPoolMemberPortType t = interfaces.getLocalLBPoolMember();
iControl.LocalLBPoolMemberMemberStatistics [] memberStatsA =
t.get_all_statistics(pool_list);
for(int i=0; i {
System.out.println("Pool " + pool_list[ i ]);
iControl.LocalLBPoolMemberMemberStatisticEntry [] statEntryA = memberStatsA[ i ].getStatistics();
for(int j=0; j {
iControl.CommonIPPortDefinition memberDef = statEntryA[j].getMember();
System.out.println("+ " + memberDef.getAddress() +
memberDef.getPort());
iControl.CommonStatistic[] statisticsA =
statEntryA[j].getStatistics();
for(int k=0; k {
iControl.CommonStatisticType type = statisticsA[k].getType();
iControl.CommonULong64 ul64 = statisticsA[k].getValue();
long value = (long)(ul64.getHigh()<<32) + (long)ul64.getLow();
System.out.println(" " + type.toString() + " -> " + value);
}
}
}
}
}
If you need to request a specific pool member, you can go this route and just filter out the other ones, or you could call the get_statistics() method instead of the get_all_statistics() method and pass in a second parameter that is a 2-d array with the first dimension for each requested pool, and a second dimension for the list of pool members for each respective pool.
Hope this helps and please post if you get stuck again.
-Joe
this really helped! thanks Joe!