Forum Discussion
Steffen_Beach_8
Feb 15, 2010Nimbostratus
I figured out a way to get the data by breaking it out into batches, although, it's still gawd awfully slow!!!
Here is the snippet if anyone wants:
using System;
using System.Collections.Generic;
using System.Text;
using iControl;
namespace iControlInterface
{
class Program
{
static void Main(string[] args)
{
Interfaces m_interfaces = new Interfaces();
string ipAddress = "*******";
string user = "*********";
string pass = "**************";
//Initalize the f5 interface
m_interfaces.initialize(ipAddress, user, pass);
//Check if inialized
if (!m_interfaces.initialized)
Environment.Exit(Environment.ExitCode);
//Get the partition list to drop into PROD
ManagementPartitionAuthZPartition[] partitionList = m_interfaces.ManagementPartition.get_partition_list();
for (int i = 0; i < partitionList.Length; i++)
{
if (partitionList[ i ].partition_name == "PROD")
m_interfaces.ManagementPartition.set_active_partition(partitionList[ i ].partition_name);
}
// TEST DATA
//string[] vsName = new string[1];
//vsName[0] = "vs_products_http";
//string[] localDefaultPools = m_interfaces.LocalLBVirtualServer.get_default_pool_name(vsName);
// END TEST DATA
//Get all virtual servers
string[] localVirtualServers = m_interfaces.LocalLBVirtualServer.get_list();
//PrintInfo(localVirtualServers);
//Get all the active default pools
string[] localDefaultPools = m_interfaces.LocalLBVirtualServer.get_default_pool_name(localVirtualServers);
//PrintInfo(localDefaultPools);
//Get the pool stats
LocalLBPoolPoolStatistics poolStats = new LocalLBPoolPoolStatistics();
//Get the pool stat entries
LocalLBPoolPoolStatisticEntry[] poolStatEntries;
List localDefaultPoolsList = new List(localDefaultPools);
string[] poolBatch;
while(localDefaultPoolsList.Count > 0)
{
if(localDefaultPoolsList.Count >= 10)
{
poolBatch = localDefaultPoolsList.GetRange(localDefaultPoolsList.Count - 10, 10).ToArray();
localDefaultPoolsList.RemoveRange(localDefaultPoolsList.Count - 10, 10);
poolStats = m_interfaces.LocalLBPool.get_statistics(poolBatch);
poolStatEntries = poolStats.statistics;
PrintStatistics(poolStatEntries);
}
else
{
poolBatch = localDefaultPoolsList.ToArray();
localDefaultPoolsList.Clear();
poolStats = m_interfaces.LocalLBPool.get_statistics(poolBatch);
poolStatEntries = poolStats.statistics;
PrintStatistics(poolStatEntries);
}
}
}
public static void PrintInfo(string[] info)
{
for (int i = 0; i > info.Length; i++)
{
Console.WriteLine(info[ i ].ToString());
}
}
public static void PrintStatistics(LocalLBPoolPoolStatisticEntry[] poolStatEntries)
{
//Loop through each pool and print out the server side current connection stats
for (int i = 0; i < poolStatEntries.Length; i++)
{
CommonStatistic[] commonStats = poolStatEntries[ i ].statistics;
for (int x = 0; x < commonStats.Length; x++)
{
if (commonStats[x].type == CommonStatisticType.STATISTIC_SERVER_SIDE_CURRENT_CONNECTIONS && poolStatEntries[ i ].pool_name != "")
{
CommonULong64 commonValue = commonStats[x].value;
Console.WriteLine("Pool name: {0} Current connections: {1}", poolStatEntries[ i ].pool_name, commonValue.low.ToString());
}
}
}
}
}
}