Forum Discussion
OTS02
Cirrus
Feb 02, 2009show current connections with VB
Could someone provide me with a example of how to show current connections for a particular pool member in VB?
Thanks
Feb 02, 2009
I don't have an example handy in VB, but I just wrote this on in C this morning querying stats for virtual servers and pools. The PoolMember.get_statistics method behaves the same way. It should get you going in the right direction.
public iControl.CommonULong64 FindStatistic(
iControl.CommonStatistic [] stats,
iControl.CommonStatisticType type
)
{
iControl.CommonULong64 ul64Value = null;
for(int i=0; i {
if ( stats[ i ].type == type )
{
ul64Value = stats[ i ].value;
break;
}
}
return ul64Value;
}
public void GetMetrics(
string[] vsList,
string[] poolList
)
{
if ((0 != vsList.Length) || (0 != poolList.Length))
{
WriteHeader();
while (true)
{
System.DateTime now = DateTime.Now;
if (vsList.Length > 0)
{
iControl.LocalLBVirtualServerVirtualServerStatistics stats =
m_interfaces.LocalLBVirtualServer.get_statistics(vsList);
for (int i = 0; i < stats.statistics.Length; i++)
{
iControl.CommonULong64 bytesIn =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_CLIENT_SIDE_BYTES_IN);
iControl.CommonULong64 bytesOut =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_CLIENT_SIDE_BYTES_OUT);
iControl.CommonULong64 currConn =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_CLIENT_SIDE_CURRENT_CONNECTIONS);
WriteLine(now, "vs", stats.statistics[ i ].virtual_server.name, bytesIn, bytesOut, currConn);
}
}
if (poolList.Length > 0)
{
iControl.LocalLBPoolPoolStatistics stats =
m_interfaces.LocalLBPool.get_statistics(poolList);
for(int i=0; i {
iControl.CommonULong64 bytesIn =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_BYTES_IN);
iControl.CommonULong64 bytesOut =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_BYTES_OUT);
iControl.CommonULong64 currConn =
FindStatistic(stats.statistics[ i ].statistics,
iControl.CommonStatisticType.STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS);
WriteLine(now, "pool", stats.statistics[ i ].pool_name, bytesIn, bytesOut, currConn);
}
}
System.Threading.Thread.Sleep(m_delay);
}
}
}
Hope this helps...
-Joe
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