Forum Discussion
NzYme_68513
Nimbostratus
Jul 10, 2012Pool connection stats?
Is there a way to pull the current and maximum connections on a pool via iControl?
13 Replies
- NzYme_68513
Nimbostratus
preferably using the powershell iControl cmdlets? So far I'm not seeing anything that would give that type of insight into the pool objects. - snovakov_86258
Nimbostratus
Don't know about any PowerShell iControl cmdlets, but looking at iControl v10.0.0 SDK I see the method:
API Reference/LocalLB/Pool/get_all_statistics()
It apparently returns a PoolStaticEntry[] (which consists of a pool name + a Statistic[] in each element of PoolStaticEntry[]) as well as a timestamp (probably just a string) of when the statistics were taken.
~ snovakov - NzYme_68513
Nimbostratus
Getting closer. I'm using this code below but it's still coming up with an error. I suspect the parameters I'm passing are insufficient or in the wrong format.
$F5 = Get-F5.iControl
$F5.LocalLBPoolMember.get_statistics(("pool_x_x_x","xx.xx.xx.xx")) - snovakov_86258
Nimbostratus
Can you post the error you are receiving?
Can you also post the exact code you are trying to use?
I have never seen anything like:
$F5 = Get-F5.iControl
$F5.LocalLBPoolMember.get_statistics(("pool_x_x_x","xx.xx.xx.xx"))
as I always use the Perl interface, which requires much more code than that to do something in iControl.
~ snovakov - NzYme_68513
Nimbostratus
Looking under get_statistics after running a get-member on the object $F5.LocalLBPoolMember I see:
iControl.LocalLBPoolMemberMemberStatistics[] get_statistics(string[] pool_names, iControl.CommonIPPortDefinition[][] members)
I guess part of my problem is that I'm not quite sure what ' iControl.CommonIPPortDefinition' is. So should the correct syntax look something like this?
$F5.LocalLBPoolMember.get_statistics(pool_x_x_x, iControl.CommonIPPortDefinition, xx.xx.xx.xx) - The get_statistics method takes 2 parameters, the first is an array of pool names, the second is a 2-d array of pool members (a 1-d array for each of the pools specified in the first parameter. I wrote a tech tip a while back that included that method. Check it out and let me know if it works for you.
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/254/iControl-Apps--04--Graceful-Server-Shutdown.aspx
-Joe - NzYme_68513
Nimbostratus
Ok I got by that part after reading that tech tip but what's the syntax to grab the stats? I have the code like this:
$stats = $objiControl.LocalLBPoolMember.get_statistics( (,$pool_name), $MemberDefAofA);
How would I grab the maximum and current connections for each member of the pool? I ran another get-member and it's as:
iControl.LocalLBPoolMemberMemberStatisticEntry[] statistics {get;set;}
Kind of stuck at $stats.statistics{get;set;}.... - snovakov_86258
Nimbostratus
Joe would know better than me on this, but it seems you might be able to simply dump the '$stats' variable to the screen or to a log to see what it looks like and then figure out how to access the items in it you are looking for.
Many languages (like Perl) have some sort of "entity dumping facility". For Perl it is a module called Data::Dumper.
~ snovakov - NzYme_68513
Nimbostratus
When I output $stats to the screen I get this:
statistics time_stamp
---------- ----------
{iControl.LocalLBPoolMemberMemberStatisticEntry} iControl.CommonTimeStamp - The returned value from the PoolMember.get_statistics() method is a 1-D array of MemberStatistics structures.
MemberStatistics [] PoolMember.get_statistics( String [] pool_names, Common.IPPortDefinition [][] members ); struct MemberStatistics { MemberStatisticEntry [] statistics TimeStamp time_stamp }; struct MemberStatisticEntry { IPPortDefinition member; Statistic statistics; }; struct Statistic { StatisticType type; ULong64 value; long time_stamp; }
When calling the method, you pass in a 1-d array of pool names and a 2-d array of member definitions (an array for each of the pools passed in).
To parse the results, you need to iterate through the returned value arrays$MemberStatisticsA = (Get-F5.iControl).LocalLBPool.get_statistics(...); Iterate through each pool foreach($MemberStatistics in $MemberStatisticsA) { $MemberStatisticEntryA = $MemberStatistics.statistics; Iterate through each pool members statistics for the current pool foreach($MemberStatisticEntry in $MemberStatisticEntryA) { $IPPortDef = $MemberStatisticEntry.member; $member_addr = $IPPortDef.address; $member_port = $IPPortDef.port; $StatisticsA = $MemberStatisticEntry.statistics; foreach($Statistic in $StatisticsA) { $Type = $Statistic.type; $value = $Statistic.value; $v_high = $Statistic.high; $v_low = $Statistic.low; Need to convert low and high 32-bit values to a 64-bit number $v_64 = Convert-To64Bit $v_high $v_low; Write-Host "${Type} : $v_64"; } } } function Convert-To64Bit() { param($high, $low); $low = [Convert]::ToString($low,2).PadLeft(32,'0') if($low.length -eq "64") { $low = $low.substring(32,32) } return [Convert]::ToUint64([Convert]::ToString($high,2).PadLeft(32,'0')+$low,2); }
*NOTE, I just whipped this up and it hasn't been tested. Hopefully I didn't have any typos but it should illustrate the logic.
BTW, The tech tip I referenced shows how to pull out the values from the returned statistics array.
Hope this helps...
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
